RFR: 8155701: The compiler fails with an AssertionError: typeSig ERROR
Srikanth Adayapalam
sadayapalam at openjdk.java.net
Wed Apr 27 06:20:37 UTC 2022
On Wed, 27 Apr 2022 05:51:49 GMT, Srikanth Adayapalam <sadayapalam at openjdk.org> wrote:
> Make sure javac issues suitable diagnostics for types not found in the class path
Notes for the reviewer(s):
Consider:
Class Foo from Foo.java refers to an annotation type @edu.umd.cs.findbugs.annotations.SuppressWarnings properly found on the class path. Foo.java is well formed and is compiled properly into Foo.class
Class Bar from Bar.java compiled separately refers to both class Foo and the annotation @edu.umd.cs.findbugs.annotations.SuppressWarnings BUT has only Foo.class on its class path.
While compiling Bar.java, the reference to Foo causes the class file Foo.class to be read in. The class Foo is found to refer to the annotation type @edu.umd.cs.findbugs.annotations.SuppressWarnings which is not on the current class path and so results in a CompletionFailure. This completion failure is not surfaced (see com.sun.tools.javac.jvm.ClassReader.AnnotationDeproxy#findAccessMethod) as an error - a lint diagnostics get issued if line mode includes class file sanity checks - instead we simply tag the type of the ClassSymbol corresponding to @edu.umd.cs.findbugs.annotations.SuppressWarnings as an ErrorType.
Subsequently when we look up the type @edu.umd.cs.findbugs.annotations.SuppressWarnings when Bar.java itself references it, we end up retrieving this stub symbol from the symbol table.
The fact that @edu.umd.cs.findbugs.annotations.SuppressWarnings is not on the class path while compiling Bar.java that references this missing type should result in a compilation error for the type not found. Instead we find the stub symbol, not recognize that as a place holder for a missing type and proceed further in the compilation pipeline.
This results in an assertion failure during code generation phase - which should never have been entered in the first place.
The fix is to recognize this scenario and return a typeNotFound error symbol rather than the stub symbol
-------------
PR: https://git.openjdk.java.net/jdk/pull/8414
More information about the compiler-dev
mailing list