JDK-8273321 : java/awt/font/GlyphVector/NLGlyphTest.java fails on Linux
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 17,18,repo-phoenix
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2021-09-03
  • Updated: 2025-05-21
  • Resolved: 2025-05-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25Resolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
This test reliably fails on my Xubuntu 20.04:

$ CONF=linux-x86_64-server-fastdebug make run-test TEST=java/awt/font/GlyphVector/NLGlyphTest.java

...

STDERR:
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at java.desktop/sun.font.StandardGlyphVector.getGlyphCode(StandardGlyphVector.java:310)
	at NLGlyphTest.main(NLGlyphTest.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:833)

JavaTest Message: Test threw exception: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
JavaTest Message: shutting down test

Seems to fail here:

   public static void main(String[] args) {
      char[] chs = { '\n' };
      FontRenderContext frc = new FontRenderContext(null, true, true);
      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      Font[] fonts = ge.getAllFonts();
      for (Font font : fonts) {
          GlyphVector cgv = font.createGlyphVector(frc, "\n");
          GlyphVector lgv = font.layoutGlyphVector(frc, chs, 0, 1, 0);
          int c_code = cgv.getGlyphCode(0);
          int l_code = lgv.getGlyphCode(0); <--- AIIOB

Seems that "\n" produced no glyphs? I assume this is a test bug. [~prr], please advise how to fix this test?
Comments
This bug came in with a harfbuzz update and it is resolved by a harfbuzz update. I installed Asana Math (Asana-Math.otf) on Ubuntu 24.04 and was quickly able to reproduce this with JDK 24. The problem was still present in JDK 25 b21 but went away with JDK 25 b22 which has the fix for https://bugs.openjdk.org/browse/JDK-8355528 : Update HarfBuzz to 11.2.0 This isn't an accident since we had this test start to fail on macOS when testing the fix for https://bugs.openjdk.org/browse/JDK-8350203 And it was determined to be harfbuzz's handling of 0xFFFF as deleted glyph not invisible glyphs - and they fixed that (for us !) But that should only affect AAT fonts. Hmm. Dumping table info for the font I see 0. 'CFF ' - chksm = 0x786D1DAD, off = 0x0000444C, len = 353864 1. 'FFTM' - chksm = 0x485E5E31, off = 0x0005AFA4, len = 28 2. 'GDEF' - chksm = 0x00270BB8, off = 0x0005AA94, len = 30 3. 'GPOS' - chksm = 0x8B249647, off = 0x0005AF54, len = 80 4. 'GSUB' - chksm = 0x31202112, off = 0x0005AAB4, len = 1182 5. 'MATH' - chksm = 0xA18A21EC, off = 0x0005AFC0, len = 12174 6. 'OS/2' - chksm = 0x3FF4E6E2, off = 0x00000180, len = 96 7. 'cmap' - chksm = 0x0F2349BE, off = 0x00003B40, len = 2282 8. 'feat' - chksm = 0xC0190454, off = 0x000610B8, len = 44 9. 'head' - chksm = 0xF34C37EA, off = 0x0000011C, len = 54 10. 'hhea' - chksm = 0x10C91972, off = 0x00000154, len = 36 11. 'hmtx' - chksm = 0xCAD0E820, off = 0x0005DF50, len = 11976 12. 'maxp' - chksm = 0x0BB25000, off = 0x00000178, len = 6 13. 'morx' - chksm = 0x349D3519, off = 0x00060E18, len = 128 14. 'name' - chksm = 0x15C3324B, off = 0x000001E0, len = 14686 15. 'post' - chksm = 0xFE89003B, off = 0x0000442C, len = 32 16. 'prop' - chksm = 0x4CFB9FDA, off = 0x00060E98, len = 542 So we have OpenType AND AAT tables .. if we (or harfbuzz) check first for morx and find it we'll use it as an AAT font which would explain things. So I'm closing this as a dup of the harfbuzz upgrade.
21-05-2025

The failure is also reproducible on Windows-aarch64 with the same stack trace - it was checked on JDK17 and 21.
01-03-2023

I can also reproduce this on jdk11.0.18. using some fonts from the “fonts-chinese” package on linux
08-02-2023

> I think the test could be updated to skip the validation if no glyphs are produced .. Well, yes, I wrote the same almost 18 months ago :- > [~shade] not sure. I mean I could just skip if there are no gluphs returned by layout because it is effectively the same as a single invisible glyph but I wasn't sure I wanted to do it.
07-02-2023

I think the test could be updated to skip the validation if no glyphs are produced by the layoutGlyphVector, it will allow to verify the old bug, and will work on various fonts. The current bug still be open for investigation.
07-02-2023

I reproduced using Asana-Math. I can see we pass in the code point to HB, it makes the call to map char to glyph and we return the same 0xffff ID as we do for other fonts. Interestingly this specific behaviour started with JDK 16, in which release we upgraded from harfbuzz 2.3.1 to 2.7.2. I haven't yet regressed it to the specific build which that upgrade but it seems very likely. Since a lot changed in hb between those two releases it may not be easy to figure out the cause
17-09-2021

The first failing font seems to be Asana Math (probably from one of the TeX packages I have installed): java.awt.Font[family=Asana Math,name=Asana Math,style=plain,size=1] Comes from here: $ apt search asana-math fonts-oflb-asana-math/focal,focal,now 000.907-6 all [installed,automatic] extended smart Unicode Math font texlive-fonts-extra/focal,focal,now 2019.202000218-1 all [installed] TeX Live: Additional fonts If I remove the package containing the font, the test starts to fail with: java.awt.Font[family=Meslo LG L,name=Meslo LG L Bold,style=plain,size=1] That one I cannot remove easily, it was installed as my default font. :) I emailed you the Asana-Math.otf.
14-09-2021

[~shade] not sure. I mean I could just skip if there are no gluphs returned by layout because it is effectively the same as a single invisible glyph But I'd like to know what is actually happening so I need to know the font. If you add "System.out.println(font);" we can find out .. and if it is a hard-to-find font you can locate it on your system and email it to me.
13-09-2021