You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you follow the instruction on how to directly format some code using the artifact ktlint-code, you are forced to use JDK 11 because on JDK 17, the latest LTS, you get a java.lang.ExceptionInInitializerError.
Observed Behavior
When executing ktLintRuleEngine.format() the following exception is thrown when using JDK 17 (works fine with JDK 11):
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.jetbrains.kotlin.com.intellij.util.exception.FrequentErrorLogger.report(FrequentErrorLogger.java:47)
at org.jetbrains.kotlin.com.intellij.util.exception.FrequentErrorLogger.info(FrequentErrorLogger.java:43)
at org.jetbrains.kotlin.com.intellij.psi.impl.DebugUtil.handleUnspecifiedTrace(DebugUtil.java:628)
at org.jetbrains.kotlin.com.intellij.psi.impl.DebugUtil.currentInvalidationTrace(DebugUtil.java:620)
at org.jetbrains.kotlin.com.intellij.psi.impl.DebugUtil.calcInvalidationTrace(DebugUtil.java:614)
at org.jetbrains.kotlin.com.intellij.psi.impl.DebugUtil.onInvalidated(DebugUtil.java:585)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.TreeElement.onInvalidated(TreeElement.java:226)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.TreeElement.rawRemoveUpToWithoutNotifications(TreeElement.java:388)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.TreeElement.rawRemoveUpTo(TreeElement.java:342)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement.remove(CompositeElement.java:775)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement.lambda$removeChildrenInner$4(CompositeElement.java:797)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.ChangeUtil$1.runInner(ChangeUtil.java:147)
at org.jetbrains.kotlin.com.intellij.pom.impl.PomTransactionBase.run(PomTransactionBase.java:28)
at com.pinterest.ktlint.core.internal.FormatPomModel.runTransaction(KotlinPsiFileFactory.kt:127)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.ChangeUtil.prepareAndRunChangeAction(ChangeUtil.java:142)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement.removeChildrenInner(CompositeElement.java:796)
at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement.removeRange(CompositeElement.java:611)
at com.pinterest.ktlint.ruleset.standard.ImportOrderingRule.beforeVisitChildNodes(ImportOrderingRule.kt:116)
at com.pinterest.ktlint.core.internal.RuleExecutionContext$executeRuleOnNodeRecursively$1.invoke(RuleExecutionContext.kt:66)
at com.pinterest.ktlint.core.internal.RuleExecutionContext$executeRuleOnNodeRecursively$1.invoke(RuleExecutionContext.kt:65)
at com.pinterest.ktlint.core.internal.SuppressHandler.handle(SuppressHandler.kt:25)
at com.pinterest.ktlint.core.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:65)
at com.pinterest.ktlint.core.internal.RuleExecutionContext.access$executeRuleOnNodeRecursively(RuleExecutionContext.kt:23)
at com.pinterest.ktlint.core.internal.RuleExecutionContext$executeRuleOnNodeRecursively$2$1.invoke(RuleExecutionContext.kt:73)
at com.pinterest.ktlint.core.internal.RuleExecutionContext$executeRuleOnNodeRecursively$2$1.invoke(RuleExecutionContext.kt:72)
at com.pinterest.ktlint.core.internal.SuppressHandler.handle(SuppressHandler.kt:25)
at com.pinterest.ktlint.core.internal.RuleExecutionContext.executeRuleOnNodeRecursively(RuleExecutionContext.kt:72)
at com.pinterest.ktlint.core.internal.RuleExecutionContext.executeRule(RuleExecutionContext.kt:47)
at com.pinterest.ktlint.core.KtLintRuleEngine$format$4.invoke(KtLint.kt:517)
at com.pinterest.ktlint.core.KtLintRuleEngine$format$4.invoke(KtLint.kt:516)
at com.pinterest.ktlint.core.internal.VisitorProvider$visitor$6.invoke(VisitorProvider.kt:90)
at com.pinterest.ktlint.core.internal.VisitorProvider$visitor$6.invoke(VisitorProvider.kt:88)
at com.pinterest.ktlint.core.KtLintRuleEngine.format(KtLint.kt:516)
at com.pinterest.ktlint.core.KtLintRuleEngine.format$default(KtLint.kt:497)
at org.gtkkn.gir.generator.KtLintFormatter.formatAndWriteKotlinFile(KtLintFormatter.kt:61)
at org.gtkkn.gir.generator.BindingsGenerator.writeType(BindingsGenerator.kt:155)
at org.gtkkn.gir.generator.BindingsGenerator.writeType$default(BindingsGenerator.kt:131)
at org.gtkkn.gir.generator.BindingsGenerator.generate(BindingsGenerator.kt:56)
at org.gtkkn.gir.MainKt.main(Main.kt:56)
Caused by: 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 @11614aef
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at org.jetbrains.kotlin.com.intellij.util.ReflectionUtil.findFieldInHierarchy(ReflectionUtil.java:154)
at org.jetbrains.kotlin.com.intellij.util.ReflectionUtil.getDeclaredField(ReflectionUtil.java:279)
at org.jetbrains.kotlin.com.intellij.openapi.util.objectTree.ThrowableInterner.<clinit>(ThrowableInterner.java:88)
... 39 more
Steps to Reproduce
Make sure to have JDK 17 and necessary dependencies installed: apt-get --quiet install --yes openjdk-17-jdk gcc-multilib libgirepository1.0-dev libadwaita-1-dev
Clone this repository: git clone https://gitlab.com/gtk-kn/gtk-kn.git
Checkout the branch feature/67-jdk17: git checkout feature/67-jdk17
Execute the Gradle task :gir:run: ./gradlew :gir:run
Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): Maven Central artifact com.pinterest.ktlint:ktlint-core:0.48.2
Version of Gradle used (if applicable): 7.6
Operating System and version: Ubuntu 22.04
The text was updated successfully, but these errors were encountered:
I saw that a similar ticket was open and closed: #1391
The ticket provides a workaround but, after more than one year, there is still no proper fix. It seems to be an issues with some dependencies of KtLint. I would still keep the ticket open until a proper fix is available.
leinardi
added a commit
to gtk-kn/gtk-kn
that referenced
this issue
Apr 14, 2023
Expected Behavior
If you follow the instruction on how to directly format some code using the artifact
ktlint-code
, you are forced to use JDK 11 because on JDK 17, the latest LTS, you get ajava.lang.ExceptionInInitializerError
.Observed Behavior
When executing
ktLintRuleEngine.format()
the following exception is thrown when using JDK 17 (works fine with JDK 11):Steps to Reproduce
apt-get --quiet install --yes openjdk-17-jdk gcc-multilib libgirepository1.0-dev libadwaita-1-dev
git clone https://gitlab.com/gtk-kn/gtk-kn.git
feature/67-jdk17
:git checkout feature/67-jdk17
:gir:run
:./gradlew :gir:run
Your Environment
0.48.2
.editorconfig
settings: https://gitlab.com/gtk-kn/gtk-kn/-/blob/feature/67-jdk17/.editorconfigcom.pinterest.ktlint:ktlint-core:0.48.2
7.6
Ubuntu 22.04
The text was updated successfully, but these errors were encountered: