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

Compilation failure if sources contain annotations from javax.annotation package.

XMLWordPrintable

    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+110-2016-03-17-022235.javare.4664.nc)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+110-2016-03-17-022235.javare.4664.nc, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]


      A DESCRIPTION OF THE PROBLEM :
      When compiling project that contains annotations from the javax.annotation package, compiler error is reported that corresponding classes can not be found.

      Problem occurs both when compiling entire project with Maven, or when trying to compile separate class with plain javac,

      Attempts to compile with -addmods key (as suggested at https://bugs.openjdk.java.net/browse/JDK-8152842) failed as well.
      Unfortunately there is little information on jdk9 javac options available, so probably I misused 'addmods' option.

      REGRESSION. Last worked in version 8u72

      ADDITIONAL REGRESSION INFORMATION:
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a class annotated with the annotation from javax.annotation package.
      For example add a class-level annotation @Provider(1)

      2. Compile the class with command:
      javac -cp javax.annotation-api-1.2.jar Sample.java

      where javax.annotation-api-1.2.jar is "Common Annotations for the JavaTM Platform API". Available at http://central.maven.org/maven2/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar

      3. JDK9 javac reports an error, compilation fails.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Class / project compiles successfully.
      ACTUAL -
      Compiler reports error, class / project won't compile.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      D:\programs\jdk-9\bin>javac.exe -cp javax.jar Sample.java
      Sample.java:1: error: cannot find symbol
      import javax.annotation.Priority;
                             ^
        symbol: class Priority
        location: package javax.annotation
      Sample.java:3: error: cannot find symbol
      @Priority(1)
       ^
        symbol: class Priority
      2 errors

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.annotation.Priority;

      @Priority(1)
      public class Sample {
      }

      ---------- END SOURCE ----------

            sadayapalam Srikanth Adayapalam (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: