Description
openedon Oct 24, 2022
Describe the bug
When using tools such as ErrorProne with JDK16+ you need to define various export flags for the JVM as documented in the error prone installation such as
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
These would be defined within .mvn/jvm.config so that the same settings apply to everyone who checking out the code and running it, making builds reproducible easier.
These however aren't been picked up by the plugin, resulting in
An exception has occurred in the compiler (17.0.3). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com/) after checking the Bug Database (http://bugs.java.com/) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you. 12:21:55 java.lang.IllegalAccessError: class com.google.errorprone.ErrorProneAnalyzer (in unnamed module @0x293b7a99) cannot access class com.sun.tools.javac.main.JavaCompiler (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.main to unnamed module @0x293b7a99
To Reproduce
A maven project which requires the modules to be exported (for example Using ErrorProne) combined with JDK16+.
Expected behavior
The plugin should detect the JVM config file and make use of it for defining the various options.
Work around
If you define all of the exports again in your Jenkins file, but this leads to duplication and people will forget to update both.
def rtMaven = Artifactory.newMavenBuild()
rtMaven.opts = "--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED"
Versions
- Jenkins Artifactory plugin version: 3.13.0
- Jenkins operating system: Linux