Open rikintanna opened 7 months ago
@cushon , can you consider to remove label "Intelij" ?
this problem is for maven projects when formatter is used as library , so it is problem for all users of jdk17.
java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module @0x459e9125) cannot access class com.sun.tools.javac.parser.Tokens$TokenKind (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.parser to unnamed module @0x459e9125
we have problems with it at https://github.com/checkstyle/checkstyle/pull/15222#discussion_r1672444320 , failure is on MacOS container with JDK17.
some workaround for maven users is at https://github.com/Cosium/git-code-format-maven-plugin?tab=readme-ov-file#jdk-16-peculiarities
@romani there's some documentation about this here: https://github.com/google/google-java-format?tab=readme-ov-file#as-a-library, the --add-exports=
flags are required when using google-java-format as a library
Similar to https://github.com/google/google-java-format/issues/787#issuecomment-1971447073_
Caused by: java.lang.IllegalAccessError: class com.google.googlejavaformat.java.RemoveUnusedImports (in unnamed module @0x2b099be2) cannot access class com.sun.tools.javac.util.Context (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.util to unnamed module @0x2b099be2 at com.google.googlejavaformat.java.RemoveUnusedImports.removeUnusedImports(RemoveUnusedImports.java:218) ... 142 more
This issue occurs when building at command line and in Intellij.
I tried adding the below workaround to my
gradle.properties
filejava version
Originally posted by @rikintanna in https://github.com/google/google-java-format/issues/787#issuecomment-1971447073