RFR: 8337998: CompletionFailure in getEnclosingType attaching type annotations

Liam Miller-Cushon cushon at openjdk.org
Fri Aug 9 17:51:37 UTC 2024


On Fri, 9 Aug 2024 17:44:23 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> This change fixes a `CompletionFailure` crash in javac when a missing class is discovered while attaching type annotations read from a class file.
>> 
>> Type annotations on classes are located with a type path starting on the 'outermost part of the type for which a type annotation is admissible', so annotating a type requires knowing its outer classes, and the call to `ClassType#getEnclosingType` can cause additional symbols to be completed.
>> 
>> This change handles the completion failures, and reports an error diagnostic instead of the current crash.
>
> test/langtools/tools/javac/annotations/typeAnnotations/CompletionErrorOnEnclosingType.java line 78:
> 
>> 76: 
>> 77:         // now if we remove A.class there will be an error but javac should not crash
>> 78:         tb.deleteFiles(out.resolve("A.class"));
> 
> here the problem doesn't seem to be with the annotation not being found but with the annotated type not being found right?

Yes if the annotation is missing that should get handled earlier, the issue here is if visiting the annotated type causes completion failures, e.g. when calling `getEnclosingType`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20495#discussion_r1711884642


More information about the compiler-dev mailing list