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

javac disallows annotation for local variables

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: viR10068 Date: 12/08/2003


      The spec 'A Program Annotation Facility for the Java Programming Language' says:
      "
      Annotations may be used as modifiers in any declaration, whether class,
      interface, field, method, parameter, constructor, enum, or local variable.
      "

      But the compiler jdk1.5-b30 rejects the valid java source with
      message: 'illegal start of expression'.

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

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

      @interface testID {
      }

      public class test1 {

          public int m() {
      @testID int i = 123;
      return i;
          }

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

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

      Execution log:
      % jdk1.5.0-b30/solaris-sparc/bin/javac -source 1.5 -target 1.5 -version test.java
      javac 1.5.0-beta
      test.java:9: illegal start of expression
              @testID int i = 123;
              ^
      1 error
      %

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              vivsunw Viv Viv (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: