[OpenJDK 2D-Dev] RFR: 8221741 ClassCastException happen when fontconfig.properties was used

Langer, Christoph christoph.langer at sap.com
Wed Oct 30 15:00:51 UTC 2019


Hi Ichiroh,

I'm currently observing a test issue on one of our AIX boxes with that patch in place. Please give me some time to have a closer look...

Best regards
Christoph

> -----Original Message-----
> From: 2d-dev <2d-dev-bounces at openjdk.java.net> On Behalf Of Ichiroh
> Takiguchi
> Sent: Montag, 28. Oktober 2019 17:59
> To: Philip Race <philip.race at oracle.com>
> Cc: 2d-dev at openjdk.java.net; Zeller, Arno <arno.zeller at sap.com>
> Subject: Re: [OpenJDK 2D-Dev] RFR: 8221741 ClassCastException happen
> when fontconfig.properties was used
> 
> Hello Phil and other reviewers.
> 
> I appreciate if you give me your comment and suggestion.
> 
> Thanks,
> Ichiroh Takiguchi
> 
> On 2019-10-15 20:33, Ichiroh Takiguchi wrote:
> > Hello Phil.
> >
> > Sorry for bad response.
> >
> > AIX is following case, but physical font is not defined by default.
> >> If you have fonts installed and have a custom fontconfig.properties
> >> file for AIX
> >> which references those, then you should be able to get a default font
> >> from that
> >> set of known existent physical fonts.
> >
> > Please try following steps to emulate same kind this on linux (RHEL7).
> > 1. Download DefaultFontTestA.java and fontconfig.properties files
> >    Please modify fontconfig.properties if c0419bt_.pfb is not in
> > /usr/share/X11/fonts/Type1 directory.
> >
> > 2. Compile and run with following options and environment variable.
> >     $ javac --add-exports java.desktop/sun.font=ALL-UNNAMED
> > DefaultFontTestA.java
> >     $ USE_J2D_FONTCONFIG=no java --add-opens
> > java.desktop/sun.font=ALL-UNNAMED
> > -Dsun.awt.fontconfigfontconfig.properties DefaultFontTestA
> >     defaultFontName=Dialog
> >     defaultFontFileName=/dialog.ttf
> >     Exception in thread "main" 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(SunFontMa
> nager.java:1081)
> >             at DefaultFontTestA.main(DefaultFontTestA.java:48)
> >
> >        Font2D font2d =
> >             findFont2D(getDefaultFontFaceName(), Font.PLAIN,
> > NO_FALLBACK);
> >   Note:
> >     USE_J2D_FONTCONFIG is defined into
> > src/java.desktop/unix/native/common/awt/fontpath.c
> >     Dialog and /dialog.ttf are defined into
> > src/java.desktop/unix/classes/sun/awt/FcFontManager.java
> >
> > getDefaultFontFaceName returns defaultFontName, it's "Dialog".
> > findFont2D() returns Dialog CompositeFont instead of physical font.
> > I think we cannot control return value for
> > physicalFonts.values().iterator();
> > "defaultPhysicalFont = ((CompositeFont) font2d).getSlotFont(0);" is
> > useful.
> >
> > Please give me your comment.
> >
> > Thanks,
> > Ichiroh Takiguchi
> >
> > On 2019-10-09 01:06, Philip Race wrote:
> >> I think this needs a little bit more explanation first.
> >> Systems without fontconfig ... meaning without libfontconfig.
> >> So does that mean you just can't find fonts or have none installed ?
> >> If you have fonts installed and have a custom fontconfig.properties
> >> file for AIX
> >> which references those, then you should be able to get a default font
> >> from that
> >> set of known existent physical fonts.
> >>
> >> If you have neither .. then you have a system configuration problem
> >> and without
> >> a physical font installed avoiding an exception here isn't really
> >> going to help you
> >> get much further. Perhaps we should throw InternalError a bit earlier.
> >> I see no point in trying to survive ..
> >>
> >> -phil
> >>
> >>
> >> On 10/8/19, 12:35 AM, Langer, Christoph wrote:
> >>> Hi Ichiroh,
> >>>
> >>> thanks for the update. It looks good to me. I'll run it through test
> >>> system tonight and let you know if we see issues by tomorrow. Should
> >>> you not hear back from me, consider it as reviewed and tested ��
> >>>
> >>> Thanks
> >>> Christoph
> >>>
> >>>> -----Original Message-----
> >>>> From: Ichiroh Takiguchi<takiguc at linux.vnet.ibm.com>
> >>>> Sent: Montag, 7. Oktober 2019 19:16
> >>>> To: Langer, Christoph<christoph.langer at sap.com>
> >>>> Cc: 2d-dev at openjdk.java.net; Zeller, Arno<arno.zeller at sap.com>
> >>>> Subject: RE: [OpenJDK 2D-Dev] RFR: 8221741 ClassCastException
> happen
> >>>> when fontconfig.properties was used
> >>>>
> >>>> Hello Christoph.
> >>>>
> >>>> I appreciate your suggestion.
> >>>> JTreg testcase could throw ClassCastException instead of
> >>>> InvocationTargetException.
> >>>> JTreg results were in JDK-8221741
> >>>>
> >>>> Bug:    https://bugs.openjdk.java.net/browse/JDK-8221741
> >>>> Change: https://cr.openjdk.java.net/~itakiguchi/8221741/webrev.05/
> >>>>
> >>>> Could you review the fix ?
> >>>>
> >>>> Thanks,
> >>>> Ichiroh Takiguchi
> >>>> IBM Japan, Ltd.
> >>>>
> >>>> On 2019-10-07 22:53, Langer, Christoph wrote:
> >>>>> Hi Ichiroh,
> >>>>>
> >>>>> this is great, thanks for doing this. We regularly see this and
> >>>>> just
> >>>>> stumbled over it the other day where the fontconfig of our test
> >>>>> user
> >>>>> was corrupted somehow.
> >>>>>
> >>>>> As for the test, I would reduce the amount of reflection a little
> >>>>> bit.
> >>>>> It should not be necessary to access SunFontManager via
> >>>>> Class.forName,
> >>>>> you already exported it to the test via the @modules statement. You
> >>>>> can probably use this coding (please try as I didn't test it��):
> >>>>>
> >>>>>          SunFontManager sfm = SunFontManager.getInstance();
> >>>>>          Field defaultFontName_fid =
> >>>>> SunFontManager.class.getDeclaredField("defaultFontName");
> >>>>>          defaultFontName_fid.setAccessible(true);
> >>>>>          defaultFontName_fid.set(sfm, "Dialog");
> >>>>>          Method loadFonts_mid =
> >>>>> SunFontManager.class.getDeclaredMethod("loadFonts");
> >>>>>          loadFonts_mid.setAccessible(true);
> >>>>>          loadFonts_mid.invoke(sfm);
> >>>>>          PhysicalFont physicalFont = sfm.getDefaultPhysicalFont();
> >>>>>          System.out.println(physicalFont);
> >>>>>
> >>>>> If you want, I can run your (updated) patch through our test
> >>>>> system.
> >>>>>
> >>>>> Thanks
> >>>>> Christoph
> >>>>>
> >>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: 2d-dev<2d-dev-bounces at openjdk.java.net>  On Behalf Of
> >>>>>> Ichiroh
> >>>>>> Takiguchi
> >>>>>> Sent: Montag, 7. Oktober 2019 09:33
> >>>>>> To: 2d-dev at openjdk.java.net
> >>>>>> Subject: [OpenJDK 2D-Dev] RFR: 8221741 ClassCastException happen
> >>>> when
> >>>>>> fontconfig.properties was used
> >>>>>>
> >>>>>> Hello.
> >>>>>>
> >>>>>> Could you review the fix ?
> >>>>>>
> >>>>>> Bug:    https://bugs.openjdk.java.net/browse/JDK-8221741
> >>>>>> Change:
> https://cr.openjdk.java.net/~itakiguchi/8221741/webrev.04/
> >>>>>>
> >>>>>> JTreg testcase and results are including JDK-8221741 [1].
> >>>>>>
> >>>>>> [1] https://bugs.openjdk.java.net/browse/JDK-8221741
> >>>>>>
> >>>>>> Thanks,
> >>>>>> Ichiroh Takiguchi
> >>>>>> IBM Japan, Ltd.


More information about the 2d-dev mailing list