On Thu, 26 Mar 2026 13:49:32 GMT, Jan Lahoda <[email protected]> wrote:

> Consider code like:
> 
> import unknown.Unknown;
> class T {
>     Unknown u;
> }
> 
> 
> compiling this leads to:
> 
> $ javac /tmp/T.java 
> /tmp/T.java:1: error: package unknown does not exist
> import unknown.Unknown;
>               ^
> /tmp/T.java:3: error: cannot find symbol
>     Unknown u;
>     ^
>   symbol:   class Unknown
>   location: class T
> 2 errors
> 
> 
> And in the AST the error type for `Unknown` in `Unknown u` does not refer to 
> `unknown.Unknown` at all.
> 
> This PR is trying to improve this, by keeping track unresolvable types that 
> are (single-name) imported, and using their symbols when attributing 
> references.
> 
> With this patch, the error reported is:
> 
> $ javac /tmp/T.java 
> /tmp/T.java:1: error: package unknown does not exist
> import unknown.Unknown;
>               ^
> 1 error
> 
> 
> And the reference to `Unknown` is attributed as `unknown.Unknown`.
> 
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).
> - [ ]

This pull request has now been integrated.

Changeset: bb9a0943
Author:    Jan Lahoda <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/bb9a09437cc03551f81f49c3922d38ad4f0355a7
Stats:     339 lines in 8 files changed: 223 ins; 63 del; 53 mod

8378102: Validly imported symbols of unresolved types do not have their FQN 
reflected in the Element/TypeMirror instances passed to annotation processors

Reviewed-by: vromero

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

PR: https://git.openjdk.org/jdk/pull/30452

Reply via email to