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

MirroredTypeException constructor does not throw NPE when type is null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 6
    • core-libs
    • None
    • b64
    • generic
    • generic
    • Not verified

      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

            darcy Joe Darcy
            ygaevsky Yuri Gaevsky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: