ktlint exception when using java 9

Created on 5 Feb 2018  路  5Comments  路  Source: pinterest/ktlint

Using ktlint from brew, version 0.15.0. Works fine on Java 8, switched to Java 9 using jenv and get the following error.

Exception in thread "Thread-0" java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class com.github.shyiko.ktlint.core.KtLint
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at com.github.shyiko.ktlint.Main$parallel$consumer$1.run(Main.kt:614)
    at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.github.shyiko.ktlint.core.KtLint
    at com.github.shyiko.ktlint.Main.lint(Main.kt:585)

Command is simply: ktlint

Most helpful comment

@ifrins as soon as Kotlin 1.2.30 is out

All 5 comments

153 merged in but there are still couple of things that need to be fixed before this ticket can be closed:

$ ktlint --version
null

and

$ ktlint
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.com.intellij.util.text.StringFactory (file:/tmp/ktlint/ktlint/target/ktlint) to constructor java.lang.String(char[],boolean)
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.com.intellij.util.text.StringFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

+ verify together with maven/gradle.

The exception and the version showing have been fixed. What鈥檚 remaining is the illegal reflective access. This is a Kotlin compiler that has already been resolved upstream KT-19051 and will land when Kotlin 1.2.30 is released.

@shyiko do you have any plans for a release that is compatible with java 9?

@ifrins as soon as Kotlin 1.2.30 is out

UPDATE:

0.16.0 released with @ifrins fixes included (thank you once again, Francesc!).

[email protected] hasn't been released yet so "An illegal reflective access operation has occurred" warning is still printed (to stderr) but other than that it appears to be working.

[email protected] with [email protected] is out. Java 9 support is now official. Thanks everyone :bowing_man:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zsavely picture zsavely  路  5Comments

pkubowicz picture pkubowicz  路  4Comments

ZakTaccardi picture ZakTaccardi  路  3Comments

Tapchicoma picture Tapchicoma  路  3Comments

DanteAndroid picture DanteAndroid  路  3Comments