-
Bug
-
Resolution: Fixed
-
P3
-
None
-
b09
If a compilation references a repeatable annotation on the classpath, and the container for the repeatable annotation is not found, javac catches an exception at the top level and reports a javac.msg.bug diagnostic.
This should be an error, but it should be handled and reported as a more helpful diagnostic, instead of a crash.
=== A.java ===
import java.lang.annotation.Repeatable;
@Repeatable(As.class)
@interface A {}
@interface As {
A[] value();
}
=== T.java ===
@A @A class T {}
```
$ javac T.java
$ rm As.class
$ javac -sourcepath : T.java
An exception has occurred in the compiler (22.0.1). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for As not found
```
The stack trace is:
```
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for As not found
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.newCompletionFailure(ClassFinder.java:420)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.classFileNotFound(ClassFinder.java:407)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:402)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:302)
at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:686)
at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1421)
at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.members(Symbol.java:1342)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.validateContainer(Annotate.java:948)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.processRepeatedAnnotations(Annotate.java:799)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.makeContainerAnnotation(Annotate.java:1001)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.annotateNow(Annotate.java:395)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.lambda$annotateLater$0(Annotate.java:267)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.flush(Annotate.java:191)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.unblockAnnotations(Annotate.java:144)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:157)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterDone(JavaCompiler.java:1827)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1081)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:947)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
```
This should be an error, but it should be handled and reported as a more helpful diagnostic, instead of a crash.
=== A.java ===
import java.lang.annotation.Repeatable;
@Repeatable(As.class)
@interface A {}
@interface As {
A[] value();
}
=== T.java ===
@A @A class T {}
```
$ javac T.java
$ rm As.class
$ javac -sourcepath : T.java
An exception has occurred in the compiler (22.0.1). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for As not found
```
The stack trace is:
```
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for As not found
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.newCompletionFailure(ClassFinder.java:420)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.classFileNotFound(ClassFinder.java:407)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:402)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:302)
at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:686)
at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1421)
at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.members(Symbol.java:1342)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.validateContainer(Annotate.java:948)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.processRepeatedAnnotations(Annotate.java:799)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.makeContainerAnnotation(Annotate.java:1001)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.annotateNow(Annotate.java:395)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.lambda$annotateLater$0(Annotate.java:267)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.flush(Annotate.java:191)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.unblockAnnotations(Annotate.java:144)
at jdk.compiler/com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:157)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterDone(JavaCompiler.java:1827)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1081)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:947)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
```
- links to
-
Commit(master) openjdk/jdk/34ee06f5
-
Review(master) openjdk/jdk/20260