-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
JDK-8310061: Note if implicit annotation processing is being used #14499
Conversation
👋 Welcome back darcy! A progress list of the required criteria for merging this PR into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New diagnostic messages look reasonable
Webrevs
|
The goal of the change in this PR is to emit a message to users who may be unknowingly relying on default implicit annotation processing that the long-standing default may be changing in a future release. The message is a Note rather than a Warning to avoid running afoul of build setups using configurations like "-Xlint:all -Werror". Semantically, the note about implicit processors is treated as on by default. The note is not emitted if there are explicit configuration options related to annotation processing, including the new-in-JDK-21 "-proc:full". and not emitted if the "options" lint check is explicitly disabled, either through "-Xlint:-options" or "-Xlint:none". A targeted regression test for the change to follow. |
PS To be clear, the goal is to get this change into JDK 22 and then backport it into JDK 21. |
Mailing list message from Alex Buckley on compiler-dev: On 6/16/2023 11:48 AM, Joe Darcy wrote:
I looked at the man page -- (`-proc:full` isn't mentioned, but maybe it's coming soon?) The title of this mail is about "implicit annotation processing", that One or more annotation processors found under the default policy of as saying: Let's try to be more specific about where javac should search for (The man page doesn't mention searching the module path for processors. Consider this text, which sidesteps "implicit" in favor of Annotation processing is enabled, and one or more annotation They will be called [the word from the man page] in this compilation, Use -Xlint:-options to suppress this message. Alex |
Mailing list message from Joseph D. Darcy on compiler-dev: On 6/16/2023 12:20 PM, Alex Buckley wrote:
Getting -proc:full in the man page is being addressed under JDK-8308456.
My mistake; I verified the implementation does not look for annotation
To give more context around the situations where the note appears and ??? $ javac --class-path JarFileWithAnnotationProcessor.java Foo.java will look for and find the annotation processor inside In contrast, none of these other command lines would generate a note: ??? $ javac --processor-path JarFileWithAnnotationProcessor.java Foo.java ??? $ javac --class-path JarFileWithAnnotationProcessor.java The first three have explicit annotation processor related configuration Thanks, -Joe
|
Mailing list message from Alex Buckley on compiler-dev: On 6/16/2023 6:49 PM, Joseph D. Darcy wrote:
A new suggestion: Annotation processing is enabled because one or more processors Alex |
@jddarcy 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:
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 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks sensible
@@ -232,6 +236,10 @@ else if (option.equals("class")) | |||
*/ | |||
public Log log; | |||
|
|||
/** Whether or not the options lint category was initially disabled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've copied my pattern of misuse. "Whether or not" is not recommended use, whether or not you like it.
The consensus is to use just whether
; whether or not
means regardless
FWIW, I still like the whether or not
form!
optionsCheckingInitiallyDisabled = | ||
options.isSet(Option.XLINT_CUSTOM, "-options") || | ||
options.isSet(Option.XLINT_CUSTOM, "none"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a context
, so you can use get a Lint
object with Lint.instance(context)
and then use isEnabled(LintCategory)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly abusing the existing lint options category here. I want to have the effect that a new options-related link check is on by default. There are lint categories that are enabled by default, but options isn't one of them.
I'm implementing that policy by treating the implicit annotation processing check as enabled unless options checking has been explicitly disabled, which is what the code above does and is different than the standard is-options-lint-category enabled check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS Will add a clarifying comment that the idiom in question is intentional.
unless at least one processor is specified by name (-processor), or a search\n\ | ||
path is specified (--processor-path, --processor-module-path), or annotation\n\ | ||
processing is enabled explicitly (-proc:only, -proc:full).\n\ | ||
Use -Xlint:-options to suppress this message. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You ought to be able to suppress the message by addressing the underlying cause, not just by disabling the check.
For example, I would expect -proc:none
to disable the message as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That observation is true and I'll add -proc:none to the test case.
I'll add a sentence that -proc:none will disable processing.
compiler.err.annotation.unrecognized.attribute.name No newline at end of file | ||
compiler.err.annotation.unrecognized.attribute.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it just me? I cannot see any difference in these lines... Is there a difference in trailing whitespace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, it was an end-of-file difference, but it isn't being reflected in the webrev either.
processorName); | ||
|
||
// write out processor source file | ||
tb.writeFile(processorName + ".java", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use writeJavaFiles
, it will infer the filename from the source code.
|
||
// Compile the processor | ||
new JavacTask(tb) | ||
.files(processorName + ".java") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's a utility method ToolBox.findJavaFiles
which is generally useful in this sort of context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, with some optional suggestions for stylistic improvement
/integrate |
Going to push as commit 3df36c4.
Your commit was automatically rebased without conflicts. |
/backport jdk21 |
@jddarcy the backport was successfully created on the branch jddarcy-backport-3df36c4f in my personal fork of openjdk/jdk21. To create a pull request with this backport targeting openjdk/jdk21:master, just click the following link: The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21:
|
Emit a note warning of the possibility of changing the implicit running of annotation processors in a future release.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14499/head:pull/14499
$ git checkout pull/14499
Update a local copy of the PR:
$ git checkout pull/14499
$ git pull https://git.openjdk.org/jdk.git pull/14499/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14499
View PR using the GUI difftool:
$ git pr show -t 14499
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14499.diff
Webrev
Link to Webrev Comment