From bcc4a62182956a048330498fc623f9bea8c0ca70 Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 21 Oct 2023 11:17:18 +0200 Subject: [PATCH] Fix JDK 21 compatibility --- .../errorprone/documentation/Compilation.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/documentation-support/src/test/java/tech/picnic/errorprone/documentation/Compilation.java b/documentation-support/src/test/java/tech/picnic/errorprone/documentation/Compilation.java index 082714f624..452b5d2df5 100644 --- a/documentation-support/src/test/java/tech/picnic/errorprone/documentation/Compilation.java +++ b/documentation-support/src/test/java/tech/picnic/errorprone/documentation/Compilation.java @@ -29,12 +29,26 @@ public static void compileWithDocumentationGenerator( public static void compileWithDocumentationGenerator( String outputDirectory, String path, String... lines) { + /* + * The compiler options specified here largely match those used by Error Prone's + * `CompilationTestHelper`. A key difference is the stricter linting configuration. When + * compiling using JDK 21+, these lint options also require that certain JDK modules are + * explicitly exported. + */ compile( ImmutableList.of( + "--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", + "--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + "-encoding", + "UTF-8", + "-parameters", "-proc:none", "-Werror", - "-Xlint:all,-processing,-serial", - "-Xplugin:DocumentationGenerator -XoutputDirectory=" + outputDirectory), + "-Xlint:all,-serial", + "-Xplugin:DocumentationGenerator -XoutputDirectory=" + outputDirectory, + "-XDdev", + "-XDcompilePolicy=simple"), FileObjects.forSourceLines(path, lines)); }