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

REGRESSION: NPE when calling font.deriveFont(...)

XMLWordPrintable

    • 2d
    • beta
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0-ea"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b34)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b34, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Professional SP2

      A DESCRIPTION OF THE PROBLEM :
      When calling the method deriveFont(Map<? extends Attribute, ?> attributes), in some cases a NullPointerException gets thrown.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached code



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Code runs through without problems
      ACTUAL -
      NPE in method merge() of class sun.font.AttributeValues

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      C:\Dokumente und Einstellungen\Jan\Desktop>java -cp "C:\Dokumente und Einstellun
      gen\Jan\Eigene Dateien\development\java\projekte\Mahou\classes" com.incors.swing
      .text.editor.JTextEditor
      java.lang.NullPointerException
              at sun.font.AttributeValues.merge(Unknown Source)
              at sun.font.AttributeValues.merge(Unknown Source)
              at java.awt.Font.deriveFont(Unknown Source)
              at com.BugTest.main(BugTest.java:16)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.font.TextAttribute;
      import java.util.Map;

      public class BugTest {

        public static void main(String[] args) {
          Font font = new Font("Name", Font.PLAIN, 12);
          Font font2 = new Font("Name", Font.PLAIN, 11);
          Map map = font2.getAttributes();
          map.remove(TextAttribute.WEIGHT);
          font.deriveFont(map);
        }

      }
      ---------- END SOURCE ----------

      Release Regression From : 5.0
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 2005-05-03 16:57:53 GMT

            igor Igor Nekrestyanov (Inactive)
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: