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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 6
    • Fix Version/s: 8
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      x86
    • OS:
      other
    • Verification:
      Verified

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: