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

(ann) unexpected NullPointerException for Constructor.getParameterAnnotations()

    • b44
    • generic
    • generic
    • Verified



      Name: viR10068 Date: 03/04/2004


      The spec JSR-175 Preliminary Proposed Final Draft Specification 2
      says for the method Constructor.getParameterAnnotations()
      "Returns an array of length zero if the underlying method is parameterless."

      But the jdk1.5.0-b41 throws the unexpected NullPointerException.
      Please see execution log below.

      The affected new JCK 1.5 test is:
      api/java_lang/reflect/Constructor/index.html#getParamAnnot[getParamAnnot0001]

      The source:
      -------------------------- test.java --------------------------
      import java.io.PrintStream;
      import java.lang.annotation.*;

      class annotElem {
          public annotElem() {
          }
      }

      public class test {

          public static void main(String argv[]) {
              annotElem annotObj = new annotElem();
              try {
                  System.out.println("Constructor is " + annotObj.getClass().getConstructor());
                  System.out.println("ParameterAnnotations is " +
      annotObj.getClass().getConstructor().getParameterAnnotations());
              } catch (Exception ex) {
                  System.out.println("Unexpected exception: " + ex);
                  return;
              }
          }
      }
      ---------------------------------------------------------------

      Execution log:
      % jdk1.5.0-b41/solaris-sparc/bin/javac -source 1.5 -version test.java &&
      jdk1.5.0-b41/solaris-sparc/bin/java -showversion test
      javac 1.5.0-beta2
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b41)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b41, mixed mode)

      Constructor is public annotElem()
      Unexpected exception: java.lang.NullPointerException
      %

      ======================================================================

            jjb Josh Bloch
            vivsunw Viv Viv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: