JDK-6185120 : Font(Map)/getFont(Map) do not allow null values of TextAttributes
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-10-27
  • Updated: 2011-03-29
  • Resolved: 2005-04-26
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 6
6 b33Fixed
Related Reports
Relates :  
Description
The spec of TextAttribute states: "the default effect if the attribute is absent (or has a null value)/If the value is null or not of the proper type then it has the default effect/ BACKGROUND...Default null" However, if any of attributes have null value, constructor Font(Map) as well as method getFont(Map) throws NullPointerException. Please see sample java code attached. The result of this code run:
==================================================
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
-------------------------------------------------
java -cp ./   Test60     
Key: java.awt.font.TextAttribute(background); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(bidi_embedding); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(char_replacement); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(family); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(font); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(foreground); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(input method highlight); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(input method underline); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(justification); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(numeric_shaping); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(posture); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(run_direction); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(size); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(strikethrough); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(superscript); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(swap_colors); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(transform); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(underline); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(weight); value: null
  Error: java.lang.NullPointerException
Key: java.awt.font.TextAttribute(width); value: null
  Error: java.lang.NullPointerException
###@###.### 10/27/04 12:05 GMT

Comments
EVALUATION This should be fixed with the putback for 4296952. ###@###.### 2005-04-14 17:29:54 GMT
14-04-2005