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

javac allows incorrect type for complex annotations

XMLWordPrintable

    • generic
    • generic



      Name: viR10068 Date: 12/10/2003


      The spec 'A Program Annotation Facility for the Java Programming Language' says:
      "If the member type is an annotation type, the MemberValue must
      be an Annotation with the same type. "

      But the compiler jdk1.5-b30 does not rejects the invalid java source with
      incorrect annotation type.

      The following JCK tests are failed due to this bug:
      lang/ANNOT/annot039/annot03905/annot03905.html

      The source code:
      -------------------------- test.java ----------------------------
      import java.io.PrintStream;
       
      @interface Annot1 {
          float id();
      }
      @interface Annot2 {
          String id();
      }
      @interface testInter {
          Annot1 id();
      }

      public class test {

          @testInter(id = @Annot2) public void m(){
          }

          public static void main(String argv[]) {
              System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
          }

          public static int run(String argv[],PrintStream out) {
              return 0/*STATUS_PASSED*/;
          }
      }
      -----------------------------------------------------------------

      Execution log:
      % jdk1.5.0-b30/solaris-sparc/bin/javac -source 1.5 -target 1.5 -version test.java
      javac 1.5.0-beta
      %

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

            gafter Neal Gafter (Inactive)
            vivsunw Viv Viv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: