error-prone: 'An illegal reflective access operation has occurred' warnings
The warning:
Changes detected - recompiling the module!
Compiling 8 source files to /home/my_stuff/target/classes
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.errorprone.bugpatterns.FutureReturnValueIgnored (file:/my_home/.m2/repository/com/google/errorprone/error_prone_core/2.3.2/error_prone_core-2.3.2.jar) to field com.sun.tools.javac.code.Type$StructuralTypeMapping$4.this$0
WARNING: Please consider reporting this to the maintainers of com.google.errorprone.bugpatterns.FutureReturnValueIgnored
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
$ java --version
openjdk 11.0.1 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)
Java code that (rightfully) triggers the warning:
@SuppressWarnings("FutureReturnValueIgnored")
private void schedule(Runnable runnable, long delayMs) {
try {
scheduledExecutorService.schedule(runnable, delayMs, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException ex) {
// shutting down, no more checks
}
}
I’m using the maven plugin as such:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
<debug>true</debug>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArgument>-parameters</compilerArgument>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Xlint:-processing</arg>
<arg>-Werror</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.3.2</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 24 (10 by maintainers)
Commits related to this issue
- Update instructions for JDK 16 https://github.com/google/error-prone/issues/1157 — committed to google/error-prone by cushon 3 years ago
- Add jdk16 profile for making Error Prone work Refs https://github.com/google/error-prone/issues/1157 Refs https://github.com/google/error-prone/commit/038d3dc2829b950226eff3c84b2da94986f0b285 — committed to dropwizard/dropwizard by joschi 3 years ago
- Build Dropwizard with Java 16 (#3788) * Build Dropwizard with Java 16 https://mail.openjdk.java.net/pipermail/announce/2021-March/000295.html * Add jdk16 profile for making Error Prone work ... — committed to dropwizard/dropwizard by joschi 3 years ago
- Build Dropwizard with Java 16 (#3788) * Build Dropwizard with Java 16 https://mail.openjdk.java.net/pipermail/announce/2021-March/000295.html * Add jdk16 profile for making Error Prone work Refs h... — committed to dropwizard/dropwizard by joschi 3 years ago
- Add another --add-opens= flag to installation instructions https://github.com/google/error-prone/issues/1157#issuecomment-801075269 — committed to google/error-prone by cushon 3 years ago
I just released v2.0.0 of the
net.ltgt.errorproneplugin that does just that.In JDK 16 EA (which I’m not sure is being used in https://github.com/google/error-prone/issues/1157#issuecomment-769260477, but noting here for posterity), the module access checks have been upgraded by JEP 396: Strongly Encapsulate JDK Internals by Default.
I don’t currently know a better way to use Error Prone on JDK 16 than passing
--illegal-access=permit, or else:Example of updating a maven build with this flags: https://github.com/google/turbine/commit/622b59136c480a9aeca3fd6b4cc433c87777f8bd
Related: #1158
If
--add-opensdoesn’t work anymore on JDK 13, one could still disable that one check of error-prone using-Xep:FutureReturnValueIgnored:OFF.@joschi thanks, I added that flag too in the instructions: https://github.com/google/error-prone/commit/9014ef59b45247894fc1dcdcae59d137059e1902
@cushon I think there was an “opens” argument missing. I had to add
-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMEDin order to make it work for our project: https://github.com/dropwizard/dropwizard/pull/3788/commits/28a92835b6538f39d83dee81979cac5f64acf6afFailed GitHub workflow run: https://github.com/dropwizard/dropwizard/runs/2130657086#step:8:1666
Full error message with stacktrace
Thanks @tbroyer, using line continuations works for me with
<fork>true</fork>.I pushed a change to update the installation docs for JDK 16, and to also mention line continuations in the flag docs: https://github.com/google/error-prone/commit/038d3dc2829b950226eff3c84b2da94986f0b285
When using
<fork>true</fork>, Maven (plexus-compiler actually) will use an argument file, so it’s using Javac’s own parsing rules, where you need to use line-continuations for multiline arguments; i.e. end your lines with a\. (Disclaimer: I haven’t actually tested it, only read the JDK’s code)