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

crash in Annotate with duplicate declaration and annotation processing enabled

    XMLWordPrintable

Details

    • b24

    Description

      In the following example javac crashes on a compilation unit that contains a duplicate annotation declaration, with annotation processing enabled, and if one of the classes being compiled is already present on the classpath.

      === p/Y.java
      package p;
      class Y {
        @interface A {}
        @interface A {} // error: class A is already defined in class Y
        T t;
      }
      === p/T.java
      package p;
      @Deprecated class T {}
      === P.java
      import java.util.Set;
      import javax.annotation.processing.AbstractProcessor;
      import javax.annotation.processing.RoundEnvironment;
      import javax.annotation.processing.SupportedAnnotationTypes;
      import javax.lang.model.SourceVersion;
      import javax.lang.model.element.TypeElement;

      @SupportedAnnotationTypes("*")
      public class P extends AbstractProcessor {

        @Override
        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
          return false;
        }

        @Override
        public SourceVersion getSupportedSourceVersion() {
          return SourceVersion.latestSupported();
        }
      }
      ===

      javac P.java p/T.java
      javac -processor P p/Y.java p/T.java
      ...
      An exception has occurred in the compiler (9.0.1). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.AssertionError
              at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
              at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.lambda$annotateLater$0(Annotate.java:245)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.flush(Annotate.java:184)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.unblockAnnotations(Annotate.java:137)
              at jdk.compiler/com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:150)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterDone(JavaCompiler.java:1726)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1054)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:923)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:302)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:162)
              at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
              at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

      The crash reproduces with:
      9.0.1+11
      1.8.0_162-ea-b03
      1.7.0_80-b15

      Attachments

        Issue Links

          Activity

            People

              vromero Vicente Arturo Romero Zaldivar
              cushon Liam Miller-Cushon
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: