JDK-8273321 : java/awt/font/GlyphVector/NLGlyphTest.java fails on Linux
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 17,18
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2021-09-03
  • Updated: 2024-05-22
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 24
24Unresolved
Related Reports
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
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