Skip to content

Commit

Permalink
Update Error Prone version
Browse files Browse the repository at this point in the history
and get tests passing with latest JDK 16 EA.

#538

PiperOrigin-RevId: 357875378
  • Loading branch information
cushon authored and google-java-format Team committed Feb 17, 2021
1 parent b9fd8d2 commit 506875d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 24 deletions.
58 changes: 37 additions & 21 deletions core/src/test/java/com/google/googlejavaformat/java/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ public class MainTest {
// PrintWriter instances used below are hard-coded to use system-default line separator.
private final Joiner joiner = Joiner.on(System.lineSeparator());

private static final ImmutableList<String> ADD_EXPORTS =
ImmutableList.of(
"--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.parser=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-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED");

@Test
public void testUsageOutput() {
StringWriter out = new StringWriter();
Expand Down Expand Up @@ -109,11 +119,13 @@ public void preserveOriginalFile() throws Exception {
public void testMain() throws Exception {
Process process =
new ProcessBuilder(
ImmutableList.of(
Paths.get(JAVA_HOME.value()).resolve("bin/java").toString(),
"-cp",
JAVA_CLASS_PATH.value(),
Main.class.getName()))
ImmutableList.<String>builder()
.add(Paths.get(JAVA_HOME.value()).resolve("bin/java").toString())
.addAll(ADD_EXPORTS)
.add("-cp")
.add(JAVA_CLASS_PATH.value())
.add(Main.class.getName())
.build())
.redirectError(Redirect.PIPE)
.redirectOutput(Redirect.PIPE)
.start();
Expand Down Expand Up @@ -435,14 +447,16 @@ public void exitIfChangedStdin() throws Exception {
Files.write(path, "class Test {\n}\n".getBytes(UTF_8));
Process process =
new ProcessBuilder(
ImmutableList.of(
Paths.get(JAVA_HOME.value()).resolve("bin/java").toString(),
"-cp",
JAVA_CLASS_PATH.value(),
Main.class.getName(),
"-n",
"--set-exit-if-changed",
"-"))
ImmutableList.<String>builder()
.add(Paths.get(JAVA_HOME.value()).resolve("bin/java").toString())
.addAll(ADD_EXPORTS)
.add("-cp")
.add(JAVA_CLASS_PATH.value())
.add(Main.class.getName())
.add("-n")
.add("--set-exit-if-changed")
.add("-")
.build())
.redirectInput(path.toFile())
.redirectError(Redirect.PIPE)
.redirectOutput(Redirect.PIPE)
Expand All @@ -461,14 +475,16 @@ public void exitIfChangedFiles() throws Exception {
Files.write(path, "class Test {\n}\n".getBytes(UTF_8));
Process process =
new ProcessBuilder(
ImmutableList.of(
Paths.get(JAVA_HOME.value()).resolve("bin/java").toString(),
"-cp",
JAVA_CLASS_PATH.value(),
Main.class.getName(),
"-n",
"--set-exit-if-changed",
path.toAbsolutePath().toString()))
ImmutableList.<String>builder()
.add(Paths.get(JAVA_HOME.value()).resolve("bin/java").toString())
.addAll(ADD_EXPORTS)
.add("-cp")
.add(JAVA_CLASS_PATH.value())
.add(Main.class.getName())
.add("-n")
.add("--set-exit-if-changed")
.add(path.toAbsolutePath().toString())
.build())
.redirectError(Redirect.PIPE)
.redirectOutput(Redirect.PIPE)
.start();
Expand Down
20 changes: 17 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
<version>2.0.8</version>
<version>2.5.1</version>
</dependency>

<!-- Test dependencies -->
Expand Down Expand Up @@ -180,7 +180,21 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<fork>true</fork>
<compilerArgs>
<!-- runtime arguments for Error Prone -->
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<!-- compile-time arguments for google-java-format -->
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
Expand All @@ -195,7 +209,7 @@
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.3.2</version>
<version>2.5.1</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down Expand Up @@ -245,7 +259,7 @@
<version>2.18</version>
<configuration>
<!-- set heap size to work around http://github.com/travis-ci/travis-ci/issues/3396 -->
<argLine>-Xmx1024m</argLine>
<argLine>-Xmx1024m --illegal-access=permit</argLine>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit 506875d

Please sign in to comment.