Skip to content

8348611: Eliminate DeferredLintHandler and emit warnings after attribution #24584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 69 commits into
base: master
Choose a base branch
from

Conversation

archiecobbs
Copy link
Contributor

@archiecobbs archiecobbs commented Apr 10, 2025

This is a fairly large cleanup/refactoring of how lint warnings are handled.

A central challenge with lint warnings is that warnings can be generated at any point during compilation, but whether a particular lint warning is suppressed via @SuppressWarnings can't be known until after attribution. For example, the parser doesn't have enough information to interpret and apply @SuppressWarnings("text-blocks") to the text blocks that it encounters.

In addition, several other factors complicate things:

  • Some warnings are "suppressibly mandatory" (i.e., they are emitted if not suppressed instead of emitted if enabled)
  • Some warnings are "unsuppressibly mandatory" (e.g., the "internal proprietary API" warning)
  • Some mandatory warnings are aggregated into notes that are emitted at the end of compilation when not enabled
  • Some warnings are lint warnings, with a corresponding lint category, while others are just "plain" warnings
  • Some lint warning categories support @SuppressWarnings, while others only support the -Xlint flags
  • Speculative compilation requires holding log messages in purgatory until the speculation resolves, after which they are then either discarded or emitted (but even then, we may not know yet whether the warning should be suppressed)

Previously the logic to get all of this right was non-obviously woven around the code base. In particular, you needed to know somehow whether or not to use DeferredLintHandler, and in what "mode".

Besides general refactoring & cleanup, a primary goal of this PR is to simplify the usage so that no matter where you are in the compiler, you can just invoke log.warning() to log a warning and forget about (most of) the details listed above.


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

Issues

  • JDK-8348611: Eliminate DeferredLintHandler and emit warnings after attribution (Enhancement - P5)
  • JDK-8224228: No way to locally suppress lint warnings in parser/tokenizer or preview features (Task - P4)
  • JDK-8353758: Missing calls to Log.useSource() in JavacTrees (Bug - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24584

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 10, 2025

👋 Welcome back acobbs! 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

openjdk bot commented Apr 10, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Apr 10, 2025

@archiecobbs this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8348611
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk
Copy link

openjdk bot commented Apr 10, 2025

⚠️ @archiecobbs 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).

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Apr 10, 2025
@archiecobbs
Copy link
Contributor Author

/solves JDK-8353758

@openjdk
Copy link

openjdk bot commented May 28, 2025

@archiecobbs
Adding additional issue to solves list: 8353758: Missing calls to Log.useSource() in JavacTrees.

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label May 28, 2025
@openjdk openjdk bot added merge-conflict Pull request has merge conflict with target branch and removed merge-conflict Pull request has merge conflict with target branch labels May 31, 2025
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Jun 5, 2025
@archiecobbs
Copy link
Contributor Author

/issue remove JDK-8350514

@openjdk
Copy link

openjdk bot commented Jun 13, 2025

@archiecobbs
Removing additional issue from issue list: 8350514.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org kulla kulla-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

1 participant