Exception running hook on Java 17
javydreamercsw opened this issue · comments
I upgraded to version 3.3 as part of my project migrating to JDK 11 but now running the hook gives an error:
Failed to execute goal com.cosium.code:git-code-format-maven-plugin:3.3:on-pre-commit (default-cli) on project automation-interface: Execution default-cli of goal com.cosium.code:git-code-format-maven-plugin:3.3:on-pre-commit failed: An API incompatibility was encountered while executing com.cosium.code:git-code-format-maven-plugin:3.3:on-pre-commit: java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module @0x61f39bb) 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 @0x61f39bb
Most likely it needs a JVM argument like --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
I was unable to make it work but had to do similar changes to my project pom to make it work on Java 11 from Java 8.
Already documented at https://github.com/Cosium/git-code-format-maven-plugin#jdk-16-peculiarities