-
Notifications
You must be signed in to change notification settings - Fork 742
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
Update "Command-line flags" page with -Xplugin
instructions
#1115
Update "Command-line flags" page with -Xplugin
instructions
#1115
Conversation
If run in the old style, it uses javac9, which can't handle the Java 11 class files in the JDK11 bootclasspath. This follows the instructions at https://errorprone.info/docs/installation#maven Note also the need to include -Xep:BetaApi:OFF in the same arg as -Xplugin:ErrorProne: google/error-prone#1136 (comment) google/error-prone#1115 (Also, incidentally update Error Prone itself. I forget whether I had a Java-11-related reason for that, but it seems like a good idea.) RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=272934125
If run in the old style, it uses javac9, which can't handle the Java 11 class files in the JDK11 bootclasspath. This follows the instructions at https://errorprone.info/docs/installation#maven Note also the need to include -Xep:BetaApi:OFF in the same arg as -Xplugin:ErrorProne: google/error-prone#1136 (comment) google/error-prone#1115 (Also, incidentally update Error Prone itself. I forget whether I had a Java-11-related reason for that, but it seems like a good idea.) RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=272934125
docs/flags.md
Outdated
</compilerArgs> | ||
</configuration> | ||
</build> | ||
</plugins> | ||
</plugin> | ||
</project> | ||
``` | ||
|
||
Be aware that when running on JDK 8 the flags cannot be wrapped across multiple | ||
lines. JDK 9 and above do allow the flags to be separated by newlines. |
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 not sure what this means, was this a JDK change or a maven change? Is it saying that e.g.
<arg>-Xplugin:ErrorProne
-Xep:DeadException:WARN
-Xep:GuardedBy:OFF</arg>
is supported?
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 understood correctly. It's a JDK change, and indeed such formatting is supported on JDK 9 and up. I'll add an example.
(See #1226 for an example where a JDK 8 user hit this issue, and removing the newlines fixed it. With JDK 9+ newlines do work, as shown in e.g. #1136 (comment). Unfortunately I wasn't able to find the OpenJDK commit that fixed this.)
f009ba8
to
788327e
Compare
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.
Tnx for the review @cushon. I rebased and added a commit; PTAL.
docs/flags.md
Outdated
</compilerArgs> | ||
</configuration> | ||
</build> | ||
</plugins> | ||
</plugin> | ||
</project> | ||
``` | ||
|
||
Be aware that when running on JDK 8 the flags cannot be wrapped across multiple | ||
lines. JDK 9 and above do allow the flags to be separated by newlines. |
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 understood correctly. It's a JDK change, and indeed such formatting is supported on JDK 9 and up. I'll add an example.
(See #1226 for an example where a JDK 8 user hit this issue, and removing the newlines fixed it. With JDK 9+ newlines do work, as shown in e.g. #1136 (comment). Unfortunately I wasn't able to find the OpenJDK commit that fixed this.)
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.
LGTM, thanks!
I migrated a Maven configuration from
javac-with-errorprone
to-Xplugin:ErrorProne
, as documented in 74726c3. Not being familiar with javac plugins, it took me quite a while before I realized why I was consistently greeted with errors about Error Prone flags not being recognized:It turns out the following doesn't work anymore (like it did with
javac-with-errorprone
):Then based on the Ant and command line documentation I tried the following, but this only worked on Java 9+, still failing on Java 8:
The lesson is that for compatibility with Java 8 the flags must either all be on the same line, or in case one wishes to intersperse comments, wrapped like this:
This PR updates the documentation so that others may find a smoother upgrade path :).