Skip to content

8378740: Suppressed warnings reported when implicit compilation is combined with annotation processing#30110

Closed
lahodaj wants to merge 5 commits intoopenjdk:masterfrom
lahodaj:JDK-8378740
Closed

8378740: Suppressed warnings reported when implicit compilation is combined with annotation processing#30110
lahodaj wants to merge 5 commits intoopenjdk:masterfrom
lahodaj:JDK-8378740

Conversation

@lahodaj
Copy link
Copy Markdown
Contributor

@lahodaj lahodaj commented Mar 6, 2026

As part of @david-beaumont's work on openjdk/valhalla#2180, it turned out warnings are sometimes reported to a wrong file when annotation processors are present, and, as a consequence, these warnings are not properly suppressed by @SuppressWarnings.

The reason is simple: the log.useSource is misplaced, and the source in the Log may not be correctly reset. The source is correctly reset if tree == null, which is the normal case without annotation processing. But with annotation processing combined with implicit compilation, tree != null, and the source is never reset to the original value. And subsequent diagnostic then may be assigned to a wrong file.

This PR is moving setting the source to the correct place.

Note that for testCorrectSource, there are multiple warnings printed. This is an pre-existing problem that is sadly harder to fix albeit hopefully with a smaller severity. I think it would be better tackled separately. I've filled https://bugs.openjdk.org/browse/JDK-8378950 for it.


Progress

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

Issue

  • JDK-8378740: Suppressed warnings reported when implicit compilation is combined with annotation processing (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30110

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link
Copy Markdown

bridgekeeper bot commented Mar 6, 2026

👋 Welcome back jlahoda! 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 Mar 6, 2026

@lahodaj 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:

8378740: Suppressed warnings reported when implicit compilation is combined with annotation processing

Reviewed-by: liach, vromero, dbeaumont

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 199 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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

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

openjdk bot commented Mar 6, 2026

@lahodaj 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 Mar 6, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge bot commented Mar 6, 2026

Webrevs

Copy link
Copy Markdown
Contributor

@david-beaumont david-beaumont left a comment

Choose a reason for hiding this comment

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

Looks good. A few optional suggestions.

/*
* @test
* @bug 8378740
* @summary Verify warnings are properly suppress in the combination of
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: "suppress in" --> "suppressed for" ?


public class APImplicitClassesWarnings {

ToolBox tb = new ToolBox();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: final (and maybe private)

I know it's not super important but as a reader of code, it's nice to not have lingering questions about "why or when could this change". A final field can just be read once and completely understood.

public void testCorrectSuppress() throws Exception {
Path src = base.resolve("src");
Path classes = base.resolve("classes");
tb.writeJavaFiles(src,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe a comment saying that the only difference here is the one suppression line.
It saves me having to do a line-by-line scan to know what changed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file can get a year bump.

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

openjdk bot commented Mar 10, 2026

⚠️ @lahodaj This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

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

@lahodaj
Copy link
Copy Markdown
Contributor Author

lahodaj commented Mar 12, 2026

/integrate

@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 12, 2026

Going to push as commit 39a2566.
Since your change was applied there have been 226 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 12, 2026
@openjdk openjdk bot closed this Mar 12, 2026
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 12, 2026
@openjdk
Copy link
Copy Markdown

openjdk bot commented Mar 12, 2026

@lahodaj Pushed as commit 39a2566.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants