[OpenJDK 2D-Dev] [9] Review request for 8144703: ClassCastException: sun.font.CompositeFont cannot be cast to PhysicalFont

dmitry markov dmitry.markov at oracle.com
Fri Jun 10 12:07:06 UTC 2016


Hello,

Could you review a fix for jdk9, please?

     bug: https://bugs.openjdk.java.net/browse/JDK-8144703
     webrev: http://cr.openjdk.java.net/~dmarkov/8144703/webrev.00/

Problem description:
If an incorrect font file is used, we unable to initialize the font 
during CompositeFont.doDeferredInitialisation() invocation and assign 
default physical font to the corresponding components entry. Later at 
the same method, (i.e. doDeferredInitialisation()) we try to update this 
entry one more time, since the name retrieved from the entry and the 
name provide by componentNames array are different. The method 
SunFontManager.findFont2D() may return a composite font for such case. 
As a result we get ClassCastException trying to assign CompositeFont 
object to the instance of PhysicalFont.

Fix:
Surround invocation of SunFontManager.findFont2D() inside 
CompositeFont.doDeferredInitialisation() with 'try-catch' to avoid 
propagation of ClassCastException.

Thanks,
Dmitry



More information about the 2d-dev mailing list