Skip to content

Commit

Permalink
Ensure compilation tests will run on JDK 16+.
Browse files Browse the repository at this point in the history
As noted [here](google/compile-testing#222), the change of the default `--illegal-access` from `permit` to `deny` will cause compile-testing tests to fail by default, with messages like this:

```
class com.google.testing.compile.Parser (in unnamed module @0x4114d843) cannot
access class com.sun.tools.javac.api.JavacTool (in module jdk.compiler) because
module jdk.compiler does not export com.sun.tools.javac.api to unnamed module
@0x4114d843
```

We can work around that by supplying the necessary `--add-opens` flag to the JVM that runs the tests.

RELNOTES=n/a
PiperOrigin-RevId: 362396186
  • Loading branch information
eamonnmcmanus authored and Google Java Core Libraries committed Mar 12, 2021
1 parent 984e893 commit 14ec090
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
19 changes: 19 additions & 0 deletions factory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>${test.jvm.flags}</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
Expand Down Expand Up @@ -200,4 +208,15 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>open-modules</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<test.jvm.flags>--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</test.jvm.flags>
</properties>
</profile>
</profiles>
</project>
17 changes: 17 additions & 0 deletions value/processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>${test.jvm.flags}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down Expand Up @@ -232,5 +240,14 @@
<additionalparam>-Xdoclint:none</additionalparam>
</properties>
</profile>
<profile>
<id>open-modules</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<test.jvm.flags>--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</test.jvm.flags>
</properties>
</profile>
</profiles>
</project>
17 changes: 17 additions & 0 deletions value/src/it/functional/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>${test.jvm.flags}</argLine>
</configuration>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -195,5 +203,14 @@
<exclude.tests>**/AutoValueJava8Test.java</exclude.tests>
</properties>
</profile>
<profile>
<id>open-modules</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<test.jvm.flags>--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</test.jvm.flags>
</properties>
</profile>
</profiles>
</project>

0 comments on commit 14ec090

Please sign in to comment.