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

(anno) Class.isAnnotationPresent(null) does not throw NullPointerException

XMLWordPrintable

    • b40
    • generic
    • generic
    • Verified



      Name: viR10068 Date: 01/22/2004


      The metadata-public-draft.html for the methods Class.isAnnotationPresent() says:
      "Throws: NullPointerException if annotationType is null"

      But jdk1.5.0-b35 does not throw the NullPointerException for null
      parameter.

      The affected tests are:
      api/java_lang/Class/index.html#isAnnotPresent[isAnnotPresent0003]

      The test source:
      --------------------------- B2.java -----------------------------------
      import java.io.PrintStream;

      class B2 {
          public static void main(String args[]) {
              try {
                  System.out.println("result for non annotated class '" +
      B2.class.isAnnotationPresent(null) + "'");
              } catch (NullPointerException npe) {
                  System.out.println("OKEY: " + npe);
                  return;
              }
              System.out.println("FAILED");
          }
      }
      -------------------------------------------------------------------------

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

      result for non annotated class 'false'
      FAILED
      %

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: