-
Bug
-
Resolution: Fixed
-
P3
-
11, 12, 13, 14, 15
-
The issue was found on AIX, however, it's possible to get this error on a Linux system.
-
b10
-
linux, aix
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8240354 | 14.0.2 | Christoph Langer | P3 | Resolved | Fixed | b01 |
JDK-8246564 | 13.0.4 | Christoph Langer | P3 | Resolved | Fixed | b04 |
JDK-8281528 | 11.0.16-oracle | Alexey Ivanov | P3 | Resolved | Fixed | b01 |
JDK-8284464 | 11.0.15.0.1-oracle | Alexey Ivanov | P3 | Closed | Fixed | b01 |
JDK-8240717 | 11.0.8 | Christoph Langer | P3 | Resolved | Fixed | b01 |
=======
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap')
at java.desktop/sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1081)
at java.desktop/sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:960)
at java.desktop/sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:898)
at java.desktop/sun.font.SunFontManager.findDeferredFont(SunFontManager.java:914)
at java.desktop/sun.font.SunFontManager.findFont2D(SunFontManager.java:2105)
at java.desktop/java.awt.Font.getFont2D(Font.java:500)
at java.desktop/java.awt.Font$FontAccessImpl.getFont2D(Font.java:237)
at java.desktop/sun.font.FontUtilities.getFont2D(FontUtilities.java:139)
at java.desktop/sun.font.FontUtilities.fontSupportsDefaultEncoding(FontUtilities.java:316)
=======
I could recreate by attached testcase on Linux platform.
In case of AIX platform without fontconfig, defaultFontName was defined as "Dialog".
$ $HOME/jdk-14+16/bin/java --add-opens java.desktop/sun.font=ALL-UNNAMED DefaultFontTest
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at DefaultFontTest.main(DefaultFontTest.java:47)
Caused by: java.lang.ClassCastException: class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap')
at java.desktop/sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1081)
... 5 more
Fixed test result on RHEL7.6 was as follows:
$ java -Dsun.awt.fontconfig=$HOME/fontconfig.properties --add-opens java.desktop/sun.font=ALL-UNNAMED DefaultFontTest
** Type1 Font: Family=Courier 10 Pitch Name=Courier 10 Pitch style=0 fileName=/usr/share/X11/fonts/Type1/c0419bt_.pfb
If Dialog font's slot 0 was missing
$ java -Dsun.awt.fontconfig=$HOME/fontconfig.properties.bad --add-opens java.desktop/sun.font=ALL-UNNAMED DefaultFontTest
** Type1 Font: Family=Bitstream Charter Name=Bitstream Charter style=0 fileName=/usr/share/X11/fonts/Type1/c0648bt_.pfb
Note:
Please change font file name if you are using non RHEL7.6.
JTreg test results for webrev.05 were as follows:
Without FIX
$ jtreg -v DefaultFontTest.java
runner starting test: java/awt/font/DefaultFontTest/DefaultFontTest.java
runner finished test: java/awt/font/DefaultFontTest/DefaultFontTest.java
Failed. Execution failed: `main' threw exception: java.lang.ClassCastException: class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap')
Test results: failed: 1
With FIX
$ jtreg -v DefaultFontTest.java
runner starting test: java/awt/font/DefaultFontTest/DefaultFontTest.java
runner finished test: java/awt/font/DefaultFontTest/DefaultFontTest.java
Passed. Execution successful
Test results: passed: 1
The fix was posted by:
https://mail.openjdk.java.net/pipermail/2d-dev/2019-October/010324.html
- backported by
-
JDK-8240354 ClassCastException can happen when fontconfig.properties is used
- Resolved
-
JDK-8240717 ClassCastException can happen when fontconfig.properties is used
- Resolved
-
JDK-8246564 ClassCastException can happen when fontconfig.properties is used
- Resolved
-
JDK-8281528 ClassCastException can happen when fontconfig.properties is used
- Resolved
-
JDK-8284464 ClassCastException can happen when fontconfig.properties is used
- Closed
- relates to
-
JDK-8230873 [AIX] GUI app does not work with UTF-8 locale on minimum software requirements
- Resolved
-
JDK-8304054 Linux: NullPointerException from FontConfiguration.getVersion in case no fonts are installed
- Resolved