-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KtLint 0.43.0 is missing requisite --add-opens
to work in JDK 16+
#1274
Comments
The way we handle this with google-java-format is to add it to the exec prefix like so private val EXEC_PREFIX =
"""#!/bin/sh
exec java \
-Xmx512m \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
--add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-opens jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED \
--add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
--add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \
--add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
-jar "${'$'}0" "${'$'}@"
""".trimIndent() You could update this line to do the same with the requisite args Line 57 in 94f42e0
One down side is it makes the CLI jar unusable on JDK versions <9. Another solution would be to publish two CLI jars - one with the exec prefix and one without (where folks that need to add extra commands can use the latter and repackage it themselves, like we do with GJF) |
Thx for sharing the solution above. I would not be surprised if this relates to #1271 in which it is reported that ktlint no longer works on jdk8. |
You don't need to add all those opens. You just need to add one. I altered the build.gradle like so :
And it works fine on Java 17. I'd put in a PR, but I see in this thread that this would break Java 8? The @paul-dingemans I do not think it is related to #1271 |
For maven I've added |
Let's track this in #1195 |
|
See ktlint documentation. |
Expected Behavior
I expect KtLint's fat jar on CLI to add requisite opens to run
Observed Behavior
It crashes when using JDK 16 or later
You can see this warning on older JDKs as well
Steps to Reproduce
Run the KtLint CLI binary with JDK 16
Your Environment
The text was updated successfully, but these errors were encountered: