Handle missing font system error on Java 21#578
Handle missing font system error on Java 21#578liff wants to merge 1 commit intoapache:trunkfrom liff:java21-missing-fontsystem
Conversation
In Java 21 the RuntimeException from `sun.awt.FontConfiguration` is not wrapped in an `InternalError` anymore and appears directly as a `RuntimeException` when constructing a `TextLayout`. So, when `ignoreMissingFontSystem` is set also allow a `RuntimeException` to indicate a missing font system.
|
@centic9 - is ok to treat all non-fatal exceptions in this try block as meaning we are likely to be missing fonts? So far, trying to specify specific exception types is just running into issues with different JDK setups. We have an ExceptionUtil that can be used to check if a Throwable is fatal or not. |
|
I think here it will be fine as we only handle it when the system property is set to true and only some JDK code for computing the text-length is called at that point, so the chance for other unexpected exceptions is low. |
|
Unfortunately the check on The change actually reverted the behavior for the three types of exception that were handled before.. We will need to rework this so that the three types of exception which were caught before are still seen as "font libraries missing". |
…ndicate that the fonts are probably not installed. This closes apache#578 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1915397 13f79535-47bb-0310-9956-ffa450edef68
In Java 21 the RuntimeException from
sun.awt.FontConfigurationis not wrapped in anInternalErroranymore and appears directly as aRuntimeExceptionwhen constructing aTextLayout.So, when
ignoreMissingFontSystemis set also allow aRuntimeExceptionto indicate a missing font system.A demonstration of the difference (without POI and assuming JDK >=17 and Docker are available):
Test.javawith content:docker run -it --rm -v $(pwd)/Test.class:/Test.class amazoncorretto:17-alpine java Testdocker run -it --rm -v $(pwd)/Test.class:/Test.class amazoncorretto:21-alpine java TestOn Java 17, you’ll see:
On Java 21, the result is: