Skip to content
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

Conversation

Stephan202
Copy link
Contributor

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:

javac: invalid flag: -Xep:FieldMissingNullable:OFF

It turns out the following doesn't work anymore (like it did with javac-with-errorprone):

<arg>-Xplugin:ErrorProne</arg>
<arg>-Xep:FieldMissingNullable:OFF</arg>

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:

<arg>-Xplugin:ErrorProne
     -Xep:FieldMissingNullable:OFF</arg>

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:

<arg>-Xplugin:ErrorProne <!--
      See //github.com/google/error-prone/issues/708.
  -->-Xep:FieldMissingNullable:OFF</arg>

This PR updates the documentation so that others may find a smoother upgrade path :).

docs/installation.md Outdated Show resolved Hide resolved
cpovirk added a commit to google/jimfs that referenced this pull request Oct 4, 2019
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
@cpovirk cpovirk mentioned this pull request Oct 4, 2019
cpovirk added a commit to google/jimfs that referenced this pull request Oct 4, 2019
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
regisd pushed a commit to regisd/jflex that referenced this pull request Nov 4, 2019
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.
Copy link
Collaborator

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?

Copy link
Contributor Author

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

docs/installation.md Outdated Show resolved Hide resolved
@Stephan202 Stephan202 force-pushed the improvement/update-flags-documentation branch from f009ba8 to 788327e Compare May 16, 2020 11:07
Copy link
Contributor Author

@Stephan202 Stephan202 left a 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.
Copy link
Contributor Author

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

docs/installation.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@cushon cushon left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@cushon
Copy link
Collaborator

cushon commented May 16, 2020

c8f2c17

@cushon cushon closed this May 16, 2020
@Stephan202 Stephan202 deleted the improvement/update-flags-documentation branch May 16, 2020 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants