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 11, 2021
1 parent 984e893 commit a0821d0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
20 changes: 20 additions & 0 deletions factory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<guava.version>30.1-jre</guava.version>
<test.jvm.flag/>
<truth.version>1.1.2</truth.version>
</properties>

Expand Down Expand Up @@ -168,6 +169,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 +209,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>
21 changes: 21 additions & 0 deletions value/processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<tag>HEAD</tag>
</scm>

<properties>
<test.jvm.flags/>
</properties>

<dependencies>
<dependency>
<groupId>com.google.auto</groupId>
Expand Down Expand Up @@ -167,6 +171,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 +244,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>
18 changes: 18 additions & 0 deletions value/src/it/functional/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<name>Auto-Value Functional Integration Test</name>
<properties>
<exclude.tests>this-matches-nothing</exclude.tests>
<test.jvm.flags/>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -149,6 +150,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 +204,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 a0821d0

Please sign in to comment.