-
Notifications
You must be signed in to change notification settings - Fork 512
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
java.lang.reflect.InaccessibleObjectException: Unable to make field private transient java.lang.Object java.lang.Throwable.backtrace accessible: module java.base does not "opens java.lang" to unnamed module @76628072 #1391
Comments
I can not reproduce your problem when running with CLI on java 17.0.2:
I do have problems when trying to run
Can you please try to run CLI in same way as I did and report back? Also try to narrow down the problem to a specific file. |
@paul-dingemans Looks like you might be running it on the main branch. Can you try the |
So the above error is what I get on my above m1 laptop. I started getting other issues on JDK 17 on circleci: I was able to resolve this by moving to JDK 11: |
Indeed I was running on main instead of
Can you repeat steps above on your CLI? |
@paul-dingemans You aren't getting any errors because I fixed all the style issues on the branch (It's an active PR). Try going back to this specific commit and trying again - https://app.circleci.com/pipelines/github/ScottPierce/kotlin-html/509/workflows/bce512b5-1d86-4440-a939-0146e87ac5f4/jobs/1538 |
I hope that you understand that it is hard to investigate problems against a "living" branch. If you want me to dig in this problem, please provide a reproducable example in this issue. Until then, closing it without further investigation. |
@paul-dingemans Sorry, I thought I was providing everything you needed with the above link. It gives you the git commit hash, with a fully reproducible log from a docker run on CircleCI. I'll make you a branch from that commit hash for convenience. Link to CI Run If you can't reproduce the log locally for some reason, you should be able to definitely reproduce it in docker. My CI is being built using the following docker image: Please let me know if you need anything else. |
I'm using ktlint's Running the code with Java 11 prints:
so maybe this is a Kotlin issue? EDIT: Filed https://youtrack.jetbrains.com/issue/KT-51619 |
@ScottPierce Sorry that I was not clear. The problem that I have regaing this issue, is that you expect me to check out a entire repo in which I have to get digging for a problem. Normally that is not always a problem. But this was with a living branch. I have looked multiple times at this issue and failed for various reasons (including own mistakes). This all was not needed if a "code sample" that reproduces the problem was added to the issue. So I am happy to assist, but I do ask more preparations from your side to narrow the problem down to a specific file or preferably just a code section. |
Ktlint just provides access to org.jetbrains.kotlin.com.intellij.psi.PsiFileFactory. This just looks like a java 11+ issue to me. Please try to reproduce with Java 11 and/or provide a code sample (in a new issue!) which reproduces the problem. |
@paul-dingemans my point was that I'm experiencing the same issue that @ScottPierce is experiencing, but I'm not actually using ktlint (I just copied the When running with Java 17 I get the same crash that Scott posted, and when running with Java 11, I get the same warning Scott gets when running with Java 11 (https://app.circleci.com/pipelines/github/ScottPierce/kotlin-html/511/workflows/07169170-bd22-40e3-b9a0-d2ac462f2db0/jobs/1545). |
So as things stand, any time there is a ktlint error, I reproduce the issue. If the style for the project .
Sure - I'll do my best! Sorry, I think this is a case of I knew something that I didn't communicate very well, which is that this seems to be reproducible with my ktlint configuration (a single file for my whole project that I pasted in the root issue, located in i.e. I did the following:
Here is my java version:
If you can't reproduce it from this here are my thoughts:
Attached is my project |
@ScottPierce Tnx for detailed description. I will have a look at it again. |
This is a configuration cache bug where gradle tries to serialize an exception during caching. Disable it and rerun to show the original issue, gradle should just not try to serialize exceptions thrown like this |
Would you tell us, which option you mean, and how we disable it? |
Hello, here's another data point on this: I got the same error when trying to run ktlint 0.45.2 from Java 17 in gradle. I eventually got around it by setting these jvmArgs in my JavaExec task.
Fwiw, I also did not run into the issue originally unless I passed the |
try this, this work well for me. I alse encounter this problem in jdk 17.
|
Same issues here. Any updates? |
for what its worth we've worked around this by using the antrun maven plugin instead of the ktlint maven plugin: https://github.com/trib3/leakycauldron/blob/cabaf522652be90550e4d0f8d7ccde50335116d6/parent-pom/pom.xml#L1472-L1498 -- that way the rest of the build still runs without any --add-opens, but ktlint runs with the --add-opens workaround. We also appear to see this on 0.46.1, but things appear to work without any workarounds on 0.45.2, at least in our codebase (even with changing source code to force ktlint to reformat on execution)? |
@paul-dingemans I have created a sample repository with the same issue here. I am facing this issue with
ktlintFormat works when using with java 11 (though gives a warning as mentioned here: #1618), but if there is some code formatting issue, then ktlintFormat fails with the above version, and may be other java versions as well.
Gradle 7.4Build time: 2022-02-08 09:58:38 UTC Kotlin: 1.5.31
|
@ashish12 Tnx for the example repo. I can not reproduce the problem with the example repo with the Java Corretto 17.0.4.1 version. I have tried with ktlint version 0.45.2, 0.46.1 and 0.47.1. I am running on MacOs. What is your OS? |
Now with updated OS All I am doing is running, |
Sorry, I was just running the ktlint CLI version which worked fine. Tnx for pointing once more to
|
Thanks @paul-dingemans, @cwilper
|
I am not sure whether OP's original problem is solved, but I am loosing track on the status of this issue. The problem is caused by newer Java version restricting access to certain libraries. We have to wait until libraries we use, do solve this problem so that it does not propagate via KtLint. Providing the |
Upstream dependencies of ktlint need to be updated, in the meantime this is a workaround. See pinterest/ktlint#1391
The recommendation from the corresponding ktlint issue: pinterest/ktlint#1391 (comment) Bug: 273619707 Test: echo >> appactions/interaction/interaction-service/src/main/java/androidx/appactions/interaction/service/AppInteractionServiceFactory.kt \ && ./gradlew :appactions:interaction:interaction-service:ktlintFormat Change-Id: Ie4d8d95ce873d8c068ebc200191a1fc8c7ea8d1f
Hello @paul-dingemans, would it be possible to re-open this issue until a proper fix is available? |
See #1618 |
For maven users it is possible to get around this by adding a file $ mkdir -p .mvn
$ echo "--add-opens java.base/java.lang=ALL-UNNAMED" > .mvn/jvm.config |
pre-commit should already auto-find the right files and pass them to these hooks, and not passing them should I *think* mean it's harder for new implementers to forget adding explicitly to this list. Manually testing seems to confirm this is the case (by breaking a file and seeing ktlint complain). Though we're running into pinterest/ktlint#1618 (AKA pinterest/ktlint#1391) and I can't seem to figure out how to pass through JVM args...
Expected Behavior
The task should tell me if there is a problem with the code style or not.
Observed Behavior
Crash:
Steps to Reproduce
ktlint.gradle:
Your Environment
The text was updated successfully, but these errors were encountered: