pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.2k stars 508 forks source link

Illegal reflective access by org.jetbrains.kotlin.com.intellij.util.ReflectionUtil in 0.47.0 #1618

Open kkocel opened 2 years ago

kkocel commented 2 years ago

I noticed that Illegal reflective access reappeared:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.com.intellij.util.ReflectionUtil (file:/opt/homebrew/Cellar/ktlint/0.47.0/libexec/ktlint) to field java.lang.Throwable.backtrace
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.com.intellij.util.ReflectionUtil
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
paul-dingemans commented 2 years ago

I expect this to be a problem caused by a transitive dependency. At least that seemed the solution in https://github.com/pinterest/ktlint/issues/1143. Please add a clear reproduction path (with exact java version) and sample project.

kkocel commented 2 years ago
$ java --version
openjdk 17.0.3 2022-04-19 LTS
OpenJDK Runtime Environment (build 17.0.3+7-LTS)
OpenJDK 64-Bit Server VM (build 17.0.3+7-LTS, mixed mode, sharing)

Reproduction:

  1. checkout sample project: https://github.com/kkocel/ktlint-reproduction
  2. run ktlint -F
  3. Observed behavior:
    $ ktlint -F
    13:28:16.135 [main] INFO com.pinterest.ktlint.internal.KtlintCommandLine - Enable default patterns [**/*.kt, **/*.kts]
    WARNING: An illegal reflective access operation has occurred
    WARNING: Illegal reflective access by org.jetbrains.kotlin.com.intellij.util.ReflectionUtil (file:/opt/homebrew/Cellar/ktlint/0.47.0/libexec/ktlint) to field java.lang.Throwable.backtrace
    WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.com.intellij.util.ReflectionUtil
    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
paul-dingemans commented 2 years ago

I just found that @Goooler already reported this to jetbrains as a comment on https://youtrack.jetbrains.com/issue/KT-43704. I am doubting whether it gets any priority from the kotlin team. So until then, you have to ignore it, or try one of the workarounds mentioned in the issue.

Goooler commented 2 years ago

Also