Skip to content

Commit 1ee4e1c

Browse files
committed
Make JPMS stop blocking Java reflection
Always pass --add-opens=java.base/java.lang=ALL-UNNAMED when running Java code. In combination with the ReflectionUnlocker.unlockAll() method of org.scijava:app-launcher, this will hopefully reduce the number of illegal reflection failures seen downstream.
1 parent 419327d commit 1ee4e1c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pom.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.scijava</groupId>
66
<artifactId>pom-scijava-base</artifactId>
7-
<version>21.0.1-SNAPSHOT</version>
7+
<version>21.1.0-SNAPSHOT</version>
88
<packaging>pom</packaging>
99

1010
<name>SciJava Base POM</name>
@@ -184,7 +184,13 @@
184184
-->
185185
<maven.compiler.useIncrementalCompilation>false</maven.compiler.useIncrementalCompilation>
186186

187-
<!-- Extra maven-surefire-plugin args. -->
187+
<!-- Arguments to pass to all JVM launches for better behavior. -->
188+
<scijava.jvm.args />
189+
190+
<!-- Extra arguments affecting JPMS behavior. Only used with Java 9+. -->
191+
<scijava.jvm.jpms-args>--add-opens=java.base/java.lang=ALL-UNNAMED</scijava.jvm.jpms-args>
192+
193+
<!-- Extra arguments specific to maven-surefire-plugin. -->
188194
<scijava.surefire.args />
189195

190196
<!-- Minimum required Maven version to build the project. -->
@@ -533,7 +539,7 @@
533539
own property 'scijava.surefire.args' to specify those options.
534540
-->
535541
<configuration>
536-
<argLine>@{argLine} -Xms512m -Xmx512m -Dapple.awt.UIElement=true ${scijava.surefire.args}</argLine>
542+
<argLine>@{argLine} -Xms512m -Xmx512m -Dapple.awt.UIElement=true ${scijava.jvm.args} ${scijava.surefire.args}</argLine>
537543
</configuration>
538544
</plugin>
539545

@@ -1328,6 +1334,9 @@
13281334
-->
13291335
<profile>
13301336
<id>exec</id>
1337+
<properties>
1338+
<exec.args>${scijava.jvm.args}</exec.args>
1339+
</properties>
13311340
<build>
13321341
<plugins>
13331342
<plugin>
@@ -1940,7 +1949,8 @@
19401949

19411950
<!--
19421951
The java-9 profile includes adjustments for Java 9+; in particular, it
1943-
configures the release value, and fixes the path to the javadoc executable.
1952+
configures the release value, fixes the path to the javadoc executable,
1953+
and overrides JPMS restrictions to re-enable Java reflection.
19441954
-->
19451955
<profile>
19461956
<id>java-9</id>
@@ -1949,6 +1959,7 @@
19491959
</activation>
19501960
<properties>
19511961
<maven.compiler.release>${scijava.jvm.version}</maven.compiler.release>
1962+
<scijava.jvm.args>${scijava.jvm.jpms-args}</scijava.jvm.args>
19521963
</properties>
19531964
<build>
19541965
<plugins>

0 commit comments

Comments
 (0)