Skip to content
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

Illegal reflective access operation with Kotlin 1.5.0 #1143

Closed
obsantos opened this issue May 7, 2021 · 8 comments
Closed

Illegal reflective access operation with Kotlin 1.5.0 #1143

obsantos opened this issue May 7, 2021 · 8 comments
Labels

Comments

@obsantos
Copy link

obsantos commented May 7, 2021

Expected Behavior

ktlint should run without illegal reflective access warnings.

Observed Behavior

When running ktlint while using Kotlin 1.5.0 it outputs the following warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.com.intellij.util.ReflectionUtil (file:/Users/obustosantos/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable/1.4.31/6451ea797cef544e81f507b0d9959cd97ae09c0/kotlin-compiler-embeddable-1.4.31.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
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

Other than the warning, ktlint works and detects issues in the code

Steps to Reproduce

  • Run a clean to avoid incremental analysis: ./gradlew clean
  • Run ./gradlew ktlint and observe warning

Your Environment

  • Version of ktlint used: 0.41.0
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task):

Default implementation from the README

task ktlint(type: JavaExec, group: "verification") {
    inputs.files(inputFiles)
    outputs.dir(outputDir)
    description = "Check Kotlin code style."
    classpath = configurations.ktlint
    main = "com.pinterest.ktlint.Main"
    args "src/**/*.kt", "--reporter=plain", "--reporter=checkstyle,output=${outputFile}"
}
  • Version of Gradle used (if applicable): 7.0 (Android Gradle Plugin 4.2.0)
  • Operating System and version: macOS Mojave
  • Link to your project (if it's a public repository): Private repo

Seems to be related to this https://youtrack.jetbrains.com/issue/KT-43704 that states:

Affected versions 1.4.20, 1.4.21
Fix in builds 1.5.20-dev-27, 1.5.0-M1-10, 1.5.20-M1-30

Could be similar solution as suggested in #1142 but since output is different and in my case it's just a warning (ktlint still works) decided to create new issue

@itsandreramon
Copy link

itsandreramon commented May 20, 2021

I have the same issue on 1.4.32 with an M1 Mac and ktlint 0.41.0 (it reports 1.4.31 even though I am using 1.4.32).

Task :common-ui-compose:ktlintFormat FAILED
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.com.intellij.util.ReflectionUtil (file:/Users/andrethiele/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable/1.4.31/6451ea797cef544e81f507b0d9959cd97ae09c0/kotlin-compiler-embeddable-1.4.31.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)

Edit: No error on ktlint 0.40.0

@obsantos
Copy link
Author

@itsandreramon yea because they are using 1.4.31
https://github.com/pinterest/ktlint/blob/master/build.gradle#L7

I guess we need a new version of ktlint using the latest

@obsantos
Copy link
Author

Looks like the fix has been merged #1175 but no new version has been published yet

@magneticflux-
Copy link

I frequently use Java 16 on the command line and have to explicitly switch to Java 8 so ktlint works because of KT-45566. A new release using Kotlin 1.5.20 would be fantastic!

@ipat500
Copy link

ipat500 commented Aug 24, 2021

As far as I can tell this seems to be fixed as of ktlint 0.42.1

@obsantos
Copy link
Author

As far as I can tell this seems to be fixed as of ktlint 0.42.1

You are right, seems that the have fixed it

'kotlin': gradle.ext.isKotlinDev ? "1.5.30-RC" : "1.5.20",

Closing

@fzyzcjy
Copy link

fzyzcjy commented Jan 27, 2022

I still observe the error...

java -jar /Users/tom/opt/ktlint-0.44.0-20220123.092956-49-all.jar  --format xxxxxx
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.com.intellij.util.ReflectionUtil (file:/Users/tom/opt/ktlint-0.44.0-20220123.092956-49-all.jar) 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
ktlint --version
0.43.2

@carmen-gh
Copy link

and in version 0.45.1 too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants