RFR: 8284283: javac crashes when several transitive supertypes are missing
Vicente Romero
vromero at openjdk.java.net
Tue Apr 26 18:13:55 UTC 2022
On Mon, 4 Apr 2022 20:24:44 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> Consider this testcase:
>
> ---Lib.java
> package lib;
> public class Lib implements A, B {}
> interface A {}
> interface B {}
> ---Test.java
> public class Test<E> extends lib.Lib {}
> ---
>
> $ javac -d out Lib.java
> $ rm out/lib/A.class out/lib/B.class
> $ javac -classpath out -XDdev Test.java
> Test.java:1: error: cannot access A
> public class Test<E> extends lib.Lib {}
> ^
> class file for lib.A not found
> 1 error
> An exception has occurred in the compiler (17-internal). 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, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
> java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.hasTag(com.sun.tools.javac.code.TypeTag)" because the return value of "com.sun.tools.javac.code.Type$TypeVar.getUpperBound()" is null
> at jdk.compiler/com.sun.tools.javac.code.Types.getBounds(Types.java:2732)
> ....
>
>
> The reason for the cache is insufficient error recovery - when the missing class `A` and `B` are encountered, the processing in `TypeEnter` (`TypeEnter.HierarchyPhase` for `A` and `TypeEnter.HeaderPhase` for `B`) is interrupted, and the rest of the processing is skipped to the end of the phase, leaving unprocessed tree, which ultimately leads to the exception.
>
> The proposed patch is to enhance the error recovery, catch the `CompletionFailure` for the missing classes sooner, and let the rest of the `TypeEnter` processing finish normally.
looks sensible
-------------
Marked as reviewed by vromero (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/8095
More information about the compiler-dev
mailing list