Integrated: 8284283: javac crashes when several transitive supertypes are missing

Jan Lahoda jlahoda at openjdk.java.net
Thu May 12 13:44:01 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.

This pull request has now been integrated.

Changeset: e4439ca3
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/e4439ca32abd779d7525f3a545e3635a8b02bc1c
Stats:     109 lines in 4 files changed: 103 ins; 3 del; 3 mod

8284283: javac crashes when several transitive supertypes are missing

Reviewed-by: vromero

-------------

PR: https://git.openjdk.java.net/jdk/pull/8095


More information about the compiler-dev mailing list