Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8294579

NPE in ConcurrentHashMap in PhysicalStrike when measuring a specific string with

XMLWordPrintable

    • 2d
    • generic
    • generic

      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


            bvaidya Balchandra Vaidya
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: