Skip to content

8179187: Misleading compilation error on annotated fully-qualified classname#30672

Open
dbalek wants to merge 1 commit intoopenjdk:masterfrom
dbalek:dbalek/8179187
Open

8179187: Misleading compilation error on annotated fully-qualified classname#30672
dbalek wants to merge 1 commit intoopenjdk:masterfrom
dbalek:dbalek/8179187

Conversation

@dbalek
Copy link
Copy Markdown
Contributor

@dbalek dbalek commented Apr 10, 2026

Consider the following code snippet:

import java.lang.annotation.*;
import java.util.List;

class Test {
    @TA java.lang.Object f1;
    List<@TA java.lang.Object> f2;
}

@Target(ElementType.TYPE_USE)
@interface TA { }

While the error reported for the line with the f1 declaration correctly mentions the root case of the problem which is an incorrectly placed type annotation

Test.java:5: error: type annotation @TA is not expected here
    @TA java.lang.Object of1;
                 ^
  (to annotate a qualified type, write java.lang.@TA Object)

the error reported for the similar problem on the line with the f2 declaration is different and quite misleading

Test.java:6: error: cannot find symbol
    List<@TA java.lang.Object> f2;
             ^
  symbol:   class java
  location: class Test

Closer observation shows that the correct error message would be reported also for the later line but its printing is suppressed due to existing error already printed on the same position.

The proposal here is:
Prevent reporting of the ResolveError while attributing the JCAnnotatedType.underlayingType (by not strictly requiring the attribution result to be a type) and allow for a better error message to be displayed later when validating annotations.



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8179187: Misleading compilation error on annotated fully-qualified classname (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30672/head:pull/30672
$ git checkout pull/30672

Update a local copy of the PR:
$ git checkout pull/30672
$ git pull https://git.openjdk.org/jdk.git pull/30672/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30672

View PR using the GUI difftool:
$ git pr show -t 30672

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30672.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Apr 10, 2026

👋 Welcome back dbalek! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 10, 2026

@dbalek This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8179187: Misleading compilation error on annotated fully-qualified classname

Reviewed-by: jlahoda, vromero

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 17 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@lahodaj, @vicente-romero-oracle) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Apr 10, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 10, 2026

@dbalek The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 10, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Apr 10, 2026

Webrevs

Copy link
Copy Markdown
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me. I think it would be good to get another review for this.
/reviewers 2

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 10, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Apr 10, 2026

@lahodaj
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Apr 10, 2026
Copy link
Copy Markdown
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler compiler-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants