Skip to content

Commit 62f1ad5

Browse files
committed
add examples of Java 11+ module exceptions
1 parent cc3bc17 commit 62f1ad5

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

README.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,38 @@ this article:
4949

5050
https://sormuras.github.io/blog/2018-09-11-testing-in-the-modular-world.html#white-box-modular-testing-with-extra-java-command-line-options
5151

52-
TODO: examples of adding exceptions (copy from R5 or OTP2)
52+
In Gradle this might look like:
53+
```Groovy
54+
test {
55+
useJUnitPlatform()
56+
jvmArgs = ['--add-opens=java.base/java.io=ALL-UNNAMED',
57+
'--add-opens=java.base/java.time=ALL-UNNAMED',
58+
'--add-opens=java.base/java.time.zone=ALL-UNNAMED',
59+
'--add-opens=java.base/java.lang=ALL-UNNAMED']
60+
}
61+
```
62+
63+
In Maven:
64+
```xml
65+
<plugin>
66+
<groupId>org.apache.maven.plugins</groupId>
67+
<artifactId>maven-surefire-plugin</artifactId>
68+
<version>3.0.0-M7</version>
69+
<configuration>
70+
<!-- we have to fork the JVM during tests so that the argLine is passed along -->
71+
<forkCount>3</forkCount>
72+
<!-- enable the restricted reflection under Java 11 so that the ObjectDiffer works
73+
the @{argLine} part is there to allow jacoco to insert its arguments as well
74+
-->
75+
<argLine>
76+
@{argLine}
77+
-Xmx2G
78+
-Dfile.encoding=UTF-8
79+
--add-opens java.base/java.io=ALL-UNNAMED
80+
--add-opens java.base/java.lang=ALL-UNNAMED
81+
--add-opens java.base/java.math=ALL-UNNAMED
82+
--add-opens java.base/java.net=ALL-UNNAMED
83+
</argLine>
84+
</configuration>
85+
</plugin>
86+
```

0 commit comments

Comments
 (0)