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

Kotlin 1.4.0 Compatibility #830

Closed
AOrobator opened this issue Aug 14, 2020 · 21 comments · Fixed by #844
Closed

Kotlin 1.4.0 Compatibility #830

AOrobator opened this issue Aug 14, 2020 · 21 comments · Fixed by #844

Comments

@AOrobator
Copy link

I just upgraded to Kotlin 1.4.0 from 1.3.72 and I get the following error

* What went wrong:
Execution failed for task ':app:formatKotlinAndroidTest'.
> There was a failure while executing work items
   > A failure occurred while executing org.jmailen.gradle.kotlinter.tasks.format.FormatWorkerRunnable
      > Could not initialize class com.pinterest.ktlint.core.ast.ElementType

I changed nothing else besides the kotlin version in my project. I'm using Detekt v1.11.0

Your Environment

  • Version of ktlint used: Detekt 1.11.0, ktlint 0.37.2
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task):
  • Version of Gradle used (if applicable): 6.5.1
  • Operating System and version: Mac OS X 10.15.6
@kenyee
Copy link

kenyee commented Aug 14, 2020

Same...updated to latest detekt/ktlint and have same issue:


Exception in thread "main" java.lang.NoSuchFieldError: FUN_KEYWORD
--
  | at com.pinterest.ktlint.core.ast.ElementType.<clinit>(ElementType.kt:154)
  | at com.pinterest.ktlint.ruleset.standard.ChainWrappingRule.<init>(ChainWrappingRule.kt:36)
  | at com.pinterest.ktlint.ruleset.standard.StandardRuleSetProvider.get(StandardRuleSetProvider.kt:11)
  | at com.pinterest.ktlint.KtlintCommandLine.loadRulesets(Main.kt:546)
  | at com.pinterest.ktlint.KtlintCommandLine.run(Main.kt:222)
  | at com.pinterest.ktlint.Main.main(Main.kt:62)
  | Exception in thread "main" java.lang.NoSuchFieldError: FUN_KEYWORD
  | at com.pinterest.ktlint.core.ast.ElementType.<clinit>(ElementType.kt:154)
  |  
  | Exception in thread "main" java.lang.NoSuchFieldError: FUN_KEYWORDget(StandardRuleSetProvider.kt:11)
  | at com.pinterest.ktlint.core.ast.ElementType.<clinit>(ElementType.kt:154)
  | at com.pinterest.ktlint.ruleset.standard.ChainWrappingRule.<init>(ChainWrappingRule.kt:36)
  | at com.pinterest.ktlint.ruleset.standard.StandardRuleSetProvider.get(StandardRuleSetProvider.kt:11)
  | at com.pinterest.ktlint.KtlintCommandLine.loadRulesets(Main.kt:546)
  | at com.pinterest.ktlint.KtlintCommandLine.run(Main.kt:222)
  | at com.pinterest.ktlint.Main.main(Main.kt:62)

@romtsn
Copy link
Collaborator

romtsn commented Aug 15, 2020

Indeed, we need to release a new version compiled against 1.4. In the meantime, you can try kotlin-dev snapshot, that is built with 1.4-rc and the exception you get should already be gone.

@ZacSweers
Copy link

would you consider publishing a non-snapshot alpha/etc version that developers could use? Not sure what your time frame looks like

@romtsn
Copy link
Collaborator

romtsn commented Aug 16, 2020

yeah, we were even considering releasing a stable version as the changelog is looking pretty packed already for the next version, but I am relying on @shashachu here as she's the one who makes releases usually

@vRallev
Copy link

vRallev commented Aug 17, 2020

@romtsn You mentioned the latest snapshot build, but which one exactly? I tried 0.38.0-SNAPSHOT, but this build is 9 days old and fails with java.lang.NoClassDefFoundError: Could not initialize class com.pinterest.ktlint.core.ast.ElementType. Did you mean 0.38.0-kotlin-1.4-M2-SNAPSHOT? This build doesn't work either, because it's built with a preview build and Kotlin stable 1.4.0 doesn't allow using that.

@shashachu
Copy link
Contributor

Hi all, we're looking into this right now. It minimum we'll look to publish a snapshot build with the 1.4.0 release ASAP, but we'll aim to do a full release with 1.4.0 as soon as possible after.

@ZacSweers
Copy link

ZacSweers commented Aug 17, 2020

Thanks @shashachu. Would you consider making it a published -alpha01 or similar non-snapshot build? I think most teams would be happy to pick up an alpha but a snapshot build incurs a build reproducibility cost that most teams probably can't afford to check in

@vRallev
Copy link

vRallev commented Aug 17, 2020

I agree with Zac. Snapshot builds also use a different repository and it many codebases it's excluded. There's no downside for pushing an alpha version. Either way, it's very much appreciated.

@shashachu
Copy link
Contributor

Hi all, I've uploaded the Alpha01 executable jar here https://github.com/pinterest/ktlint/releases/tag/0.38.0-alpha01 but I'm having a fight with Sonatype so still working on getting the artifacts uploaded.

@ZacSweers
Copy link

Thank you!

@shashachu
Copy link
Contributor

Ok artifacts should be uploaded. Gotta put the kiddos to bed but let me know if this is enough to unblock you all.

@vRallev
Copy link

vRallev commented Aug 18, 2020

Thank you. This version definitely compiles, but comes with its own challenges. I filed a separate issue: #836

@romtsn
Copy link
Collaborator

romtsn commented Aug 18, 2020

Sorry for miscommunication @vRallev, I thought publishing snapshots with latest Kotlin version already works, but apparently it's not

@ZacSweers
Copy link

Worked for us. Thanks again for the quick turnaround on this!

@eduardompinto
Copy link

Wow. Amazing work. 👏

@jonasbark
Copy link

I tried updating https://github.com/jeremymailen/kotlinter-gradle/blob/master/buildSrc/src/main/kotlin/Versions.kt accordingly to the alpha release (and kotlin 1.4.0) but I keep getting the following exception in its unit tests (and one of my projects):

'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Object, java.lang.Class, java.lang.String, java.lang.String, int)'
java.lang.NoSuchMethodError: 'void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Object, java.lang.Class, java.lang.String, java.lang.String, int)'
	at com.pinterest.ktlint.core.KtLint$visitor$1.<init>(KtLint.kt)
	at com.pinterest.ktlint.core.KtLint.visitor$default(KtLint.kt:218)
	at com.pinterest.ktlint.core.KtLint.lint(KtLint.kt:164)
	at org.jmailen.gradle.kotlinter.support.RuleSetsTest.test compatibility(RuleSetsTest.kt:43)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:119)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
	at java.base/java.lang.Thread.run(Thread.java:834)

@ZacSweers
Copy link

@jonasbark I've seen that error come up only when running 1.4-compiled kotlin bytecode in a 1.3 environment

@kenyee
Copy link

kenyee commented Aug 18, 2020

Thanks for the alpha....'fraid it wasn't enough for us though...now we get this in a bunch of random places:


Exception in thread "main" java.lang.NoSuchFieldError: FUN_KEYWORD
--
  | at com.pinterest.ktlint.core.ast.ElementType.<clinit>(ElementType.kt:154)
  | at com.pinterest.ktlint.ruleset.standard.ChainWrappingRule.<init>(ChainWrappingRule.kt:36)
  | at com.pinterest.ktlint.ruleset.standard.StandardRuleSetProvider.get(StandardRuleSetProvider.kt:11)
  | at com.pinterest.ktlint.KtlintCommandLine.loadRulesets(Main.kt:546)
  | at com.pinterest.ktlint.KtlintCommandLine.run(Main.kt:222)
  | at com.pinterest.ktlint.Main.main(Main.kt:62)

Purely from a debugging perspective, it might help your debugging if you can dump out the line or region of our code that you get crashes in though I'm not sure it's possible.

@Vakhturov
Copy link

Hi guys, I am also waiting for ktlint to support Kotlin 1.4.0.
Was not sure, that the alpha version is ready and opened a pull request yesterday with updating dependencies. Please have a look, any feedback is appreciated.
The build is compiling, checks are passing, the application is running. Couldn't publish it to maven local, though.
#838

@vRallev
Copy link

vRallev commented Aug 20, 2020

Is there any chance to get another alpha build?

@Tapchicoma
Copy link
Collaborator

soon should be 0.38.0 release. Please create separate issues for any compatibility problems with Kotlin 1.4.

@pinterest pinterest locked as resolved and limited conversation to collaborators Aug 21, 2020
@shashachu shashachu unpinned this issue Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants