JDK-6593082 : MirroredTypeException constructor does not throw NPE when type is null
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.lang.model
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-08-15
  • Updated: 2011-07-15
  • Resolved: 2011-07-15
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 7
7 b64Fixed
Related Reports
Relates :  
Description
Problem description:
====================
The javadoc specification for the javax.lang.model.type.MirroredTypeException(TypeMirror type) constructor 
at http://java.sun.com/javase/6/docs/api/javax/lang/model/type/MirroredTypeException.html
states as follows:
  ---Excerpt-from-spec---
  Constructs a new MirroredTypeException for the specified type.

  Parameters:
      type - the type being accessed
  ---End-of-excerpt-from-spec---

Note that the javax.lang.model.type package contains this statement:
  ---Excerpt-from-spec---
  Unless otherwise specified, methods in this package will throw a NullPointerException if given a null argument.
  ---End-of-excerpt-from-spec---

However, the constructor does not throw NullPointerException when 'type' is null, and does not document that 'type' may be null.

Minimized test:
===============
-- Test.java --
import javax.lang.model.type.*;

public class Test {
    public static void main(String[] args) {
        MirroredTypeException obj = null;
        try {
            obj = new MirroredTypeException((TypeMirror) null);
            System.out.println(
                    "FAILED. NullPointerException is not thrown");
        } catch (NullPointerException npe) {
            System.out.println("OKAY");
        }
    }
}
-- End of Test.java --

Minimized test output:
======================
$java -showversion Test
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)

FAILED. NullPointerException is not thrown

Comments
EVALUATION Will investigate; most likely resolution will be changing the spec to match the implementation.
18-08-2007