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

java.lang.annotation.IncompleteAnnotationException throws NPE when type is null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 6
    • core-libs
    • None
    • b01
    • x86
    • other
    • Verified

      The specification of the constructor does not indicate that
      the annotationType argument must not be null and does not
      specify the exception to be thrown if it is null.


      Here is the test code:

      ===================================================
      public void test() {
          IncompleteAnnotationException icae = null;
          try {
              icae = new IncompleteAnnotationException(null, "name");
          } catch (NullPointerException npe) {
              System.out.println("unexpected NullPointerException");
              return;
          }
          if (icae.annotationType() == null) {
              System.out.println("OK");
          } else {
              System.out.println("Expected null, got: "+icae.annotationType());
          }
      }
      --------------------------------------------------------

      When running the above test code on jdk6 and cdc 1.6, I got NullPointerException.

      The spec for the contructor IncompleteAnnotationException(Class<? extends Annotation> annotationType,String elementName) doesn't say anything about wether null is permitted or not. On the otherhand, if null is not permitted, then NullPointerException should
      be specified in the spec.

      I also checked package leave descrption for java.lang, java.lang.annotation,
      it doesn't says anything about NPE thrown if the paremter is null.

      So, based on the current spec, NPE should not be expected in the above code.

            darcy Joe Darcy
            rriggs Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: