JDK-8294579 : NPE in ConcurrentHashMap in PhysicalStrike when measuring a specific string with
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2022-09-28
  • Updated: 2022-09-30
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 8
8-poolUnresolved
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Java SE 8 (not OpenJDK) on Windows, Mac or Linux

A DESCRIPTION OF THE PROBLEM :
When measuring or painting the string "\u1798\u17C9\u17C4" with the following font in Java 8 a NullPointerException happens at ConcurrentHashMap.putVal/ConcurrentHashMap.put/PhysicalStrike.getGlyphPoint/SunLayoutEngine.nativeLayout
https://github.com/notofonts/noto-fonts/raw/main/unhinted/otf/NotoSansKhmer/NotoSansKhmer-Regular.otf
(A previous version of that font did not cause this issue, as might newer versions. So if the issue does not reproduce, make sure to use the version of the font from 2022-02-15)
This is possibly related to https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8204590 but consistently reproducible on all OSes.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
java.awt.geom.Rectangle2D$Float[x=0.0,y=-1.0689225,w=1.0,h=1.3619013]
ACTUAL -
Exception in thread "main" java.lang.NullPointerException
	at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
	at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006)
	at sun.font.PhysicalStrike.getGlyphPoint(PhysicalStrike.java:140)
	at sun.font.SunLayoutEngine.nativeLayout(Native Method)
	at sun.font.SunLayoutEngine.layout(SunLayoutEngine.java:187)
	at sun.font.GlyphLayout$EngineRecord.layout(GlyphLayout.java:685)
	at sun.font.GlyphLayout.layout(GlyphLayout.java:466)
	at sun.font.ExtendedTextSourceLabel.createGV(ExtendedTextSourceLabel.java:329)
	at sun.font.ExtendedTextSourceLabel.getGV(ExtendedTextSourceLabel.java:315)
	at sun.font.ExtendedTextSourceLabel.createLogicalBounds(ExtendedTextSourceLabel.java:225)
	at sun.font.ExtendedTextSourceLabel.getAdvance(ExtendedTextSourceLabel.java:134)
	at java.awt.font.TextLine.init(TextLine.java:281)
	at java.awt.font.TextLine.<init>(TextLine.java:129)
	at java.awt.font.TextLine.fastCreateTextLine(TextLine.java:983)
	at java.awt.font.TextLayout.fastInit(TextLayout.java:612)
	at java.awt.font.TextLayout.<init>(TextLayout.java:393)
	at java.awt.Font.getStringBounds(Font.java:2431)
	at java.awt.Font.getStringBounds(Font.java:2335)
	at FontNpeTest.main(FontNpeTest.java:10)

---------- BEGIN SOURCE ----------
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.net.URL;
public class FontNpeTest {
    public static void main(String[] args) throws Throwable {
        System.out.println(Font.createFont(Font.TRUETYPE_FONT, new URL(
                "https://github.com/notofonts/noto-fonts/raw/main" +
                "/unhinted/otf/NotoSansKhmer/NotoSansKhmer-Regular.otf"
                ).openStream()).getStringBounds("\u1798\u17C9\u17C4",
                        new FontRenderContext(null, false, false)));
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Using an older version of the font or a newer version of Java.

FREQUENCY : always



Comments
Checked with attached testcase in Windows10, issue is reproducible only in JDK8 pool Test Result ======= 8: Fail 8u341: Fail 11.0.16: Pass 17.0.4: Pass 18.0.2: Pass 19: Pass 20ea17: Pass
29-09-2022