-
Notifications
You must be signed in to change notification settings - Fork 751
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
'An illegal reflective access operation has occurred' warnings #1157
Comments
Related: #1158 |
The warning can be suppressed with |
I have the same problem, not sure how to get rid of the warning, the
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration combine.self="append">
<release>11</release>
<compilerArgs combine.self="override">
<arg>-Werror</arg>
<arg>-Xlint:all,-fallthrough,-processing,-serial,-classfile</arg>
<arg>-parameters</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>-J--illegal-access=debug</arg>
<arg>-J--add-opens=java.base/java.lang=ALL-UNNAMED</arg>
<arg>-J--add-opens=java.base/java.lang.reflect=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-Xplugin:ErrorProne
-XepOpt:Immutable:KnownImmutable=javax.money.CurrencyUnit
-XepDisableWarningsInGeneratedCode
-Xep:ConstantField:WARN
-Xep:ClassName:WARN
-Xep:DivZero:WARN
-Xep:EmptyIf:WARN
-Xep:IterablePathParameter:WARN
-Xep:LongLiteralLowerCaseSuffix:WARN
-Xep:AnnotationPosition:WARN
-Xep:EmptyTopLevelDeclaration:WARN
-Xep:EqualsBrokenForNull:WARN
-Xep:FunctionalInterfaceClash:WARN
-Xep:InvalidInlineTag:WARN
-Xep:InvalidParam:WARN
-Xep:MissingDefault:WARN
-Xep:NonCanonicalStaticMemberImport:WARN
-Xep:PrimitiveArrayPassedToVarargsMethod:WARN
-Xep:RedundantOverride:WARN
-Xep:RedundantThrows:WARN
-Xep:StaticQualifiedUsingExpression:WARN
-Xep:StringEquality:WARN
-Xep:UnusedException:WARN
-Xep:ConstantField:WARN
-Xep:MultiVariableDeclaration:WARN
-Xep:MultipleTopLevelClasses:WARN
-Xep:MultipleUnaryOperatorsInMethodCall:WARN
-Xep:PrivateConstructorForUtilityClass:WARN
-Xep:UngroupedOverloads:WARN
</arg>
</compilerArgs>
<annotationProcessorPaths combine.self="append">
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.3.3</version>
</dependency>
</annotationProcessorPaths>
<showWarnings>true</showWarnings>
</configuration>
</plugin> the stacktrace appeared only after adding the |
I think |
Looks like the illegal access is already blocked in OpenJDK 13, so either that means abandoning Error Prone to upgrade Java, or being blocked from upgrading until this is resolved. |
If |
This is quite annoying as it results in the Jenkins Warnings Next Generation plugin failing to match the first error reported since they switched to explicitly handling errorprone warnings (https://issues.jenkins-ci.org/browse/JENKINS-60622) |
@grahamtriggs can you provide more detail about the change you're observing in 13? AFAIK it doesn't change the default I can repro this with the example in #1158 (comment), but I'm not consistently seeing these warnings with smaller 'hello world' type examples, which is weird. The underlying issue here is that by default Java > 9 warns on reflective access to internal APIs (see It would be nice to avoid accessing javac internals from Error Prone, however I also not aware of public APIs that provide alternatives to some of the implementation details that are currently being accessed, so there isn't an obvious way to avoid these accesses. |
I see this in Bazel@HEAD with RBE, on this gerrit change: [1].
[1] https://gerrit-review.googlesource.com/c/gerrit/+/291864 |
In JDK 16 EA (which I'm not sure is being used in #1157 (comment), 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
Example of updating a maven build with this flags: google/turbine@622b591 |
@cushon Do you think the gradle plugin should add them by default when compiling with JDK 16+ ? This also necessarily means forking the process like with JDK 8, right? (would be a daemon process reused between compilation tasks and subsequent builds with Gradle though, so amortized over time) |
@tbroyer if the plugin can add them by default, that SGTM. I was planning to update the release instructions in time for JDK 16 to mention this also. |
Is there an updated maven example? I've tried using the google/turbine@622b591 example, but no luck. This is my current maven profile that I use with JDK15. The error I get with 16 with 2.5.1 is
|
@codylerum google/turbine is still successfully using JDK 16 EA. Are you using |
@cushon I was able to distill it down a bit and got things working. Here is a working example (runs on 15 and 16) for anyone else who finds this.
|
Adding <arg>
-Xplugin:ErrorProne
-Xep:DeadException:WARN
-Xep:GuardedBy:OFF
</arg> That's the behavior I'm seeing. I use a large number of flags with XML comments interspersed, so this is really unfortunate. |
When using |
@cushon is this the long-term plan or is there any investigation being done as to what would be needed from OpenJDK so that error prone could run without requiring these compiler options? |
@cushon I think there was an "opens" argument missing. I had to add Failed GitHub workflow run: https://github.com/dropwizard/dropwizard/runs/2130657086#step:8:1666 Full error message with stacktrace
|
* 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 google/error-prone#1157 Refs google/error-prone@038d3dc * Add "opens com.sun.tools.javac.code" for jdk.compiler * Fix HttpsConnectorFactoryTest.testExcludedProtocols TLSv1.3 support in OpenJDK 16. * Disable tests using MySQL via Docker on Java 16
* 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 google/error-prone#1157 Refs google/error-prone@038d3dc * Add "opens com.sun.tools.javac.code" for jdk.compiler * Fix HttpsConnectorFactoryTest.testExcludedProtocols TLSv1.3 support in OpenJDK 16. * Disable tests using MySQL via Docker on Java 16 (cherry picked from commit 01b1c34)
I've come to the conclusion, that it's easier to just specify the flags through maven I've created a
and then specify it in CI config as a part of environment:
MAVEN_OPTS: "-Xmx800m -Xms512m @jvm-build.options" The options file can be also easily used in IDE The full <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration combine.self="append">
<release>${java.version}</release>
<showWarnings>true</showWarnings>
<compilerArgs combine.self="override">
<arg>-Werror</arg>
<arg>-Xlint:all,-fallthrough,-processing,-serial,-classfile,-path</arg>
<arg>-parameters</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne
-XepDisableWarningsInGeneratedCode
-XepAllDisabledChecksAsWarnings
-Xep:AndroidJdkLibsChecker:OFF
-Xep:BooleanParameter:OFF
-Xep:CatchingUnchecked:OFF
-Xep:DeduplicateConstants:OFF
-Xep:FieldCanBeFinal:OFF
-Xep:HashCodeToString:OFF
-Xep:InconsistentOverloads:OFF
-Xep:InvalidBlockTag:OFF
-Xep:Java7ApiChecker:OFF
-Xep:MethodCanBeStatic:OFF
-Xep:MissingSummary:OFF
-Xep:NoFunctionalReturnType:OFF
-Xep:StaticOrDefaultInterfaceMethod:OFF
-Xep:StaticQualifiedUsingExpression:OFF
-Xep:StringSplitter:OFF
-Xep:SuppressWarningsWithoutExplanation:OFF
-Xep:TryFailRefactoring:OFF
-Xep:TypeParameterNaming:OFF
-Xep:UseTimeInScope:OFF
-Xep:Var:OFF
-Xep:WildcardImport:OFF
-Xep:NullAway:WARN
-XepOpt:NullAway:AnnotatedPackages=com.cogvio
-XepOpt:NullAway:TreatGeneratedAsUnannotated=true
-XepOpt:NullAway:AcknowledgeRestrictiveAnnotations=true
-XepOpt:NullAway:KnownInitializers=org.springframework.beans.factory.InitializingBean.afterPropertiesSet
-XepOpt:NullAway:ExcludedFieldAnnotations=org.springframework.beans.factory.annotation.Autowired
</arg>
</compilerArgs>
<annotationProcessorPaths combine.self="append">
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.5.1</version>
</path>
<path>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1-jre</version>
</path>
<path>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>0.8.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin> |
I'm going to close this. If you encounter any more flags that need to be added please report those, and I'll keep iterating on the list in the installation instructions. |
I just released v2.0.0 of the |
The warning:
Java code that (rightfully) triggers the warning:
I'm using the maven plugin as such:
The text was updated successfully, but these errors were encountered: