question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoClassDefFoundError: Could not initialize class kotlinx.coroutines.CoroutineExceptionHandlerImplKt

See original GitHub issue

I am using Android Studio with Kotlin 1.3.40 and kotlinx-coroutines-core:1.3.0-M1. If you are interested, the source code of the whole project is here: https://gitlab.com/SuperFreezZ/SuperFreezZ/tree/coroutines-crash

Unfortunately, I could not reproduce it with try.kotlinlang.org.

*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at JPLISAgent.c line: 844

java.lang.NoClassDefFoundError: Could not initialize class kotlinx.coroutines.CoroutineExceptionHandlerImplKt

	at kotlinx.coroutines.CoroutineExceptionHandlerKt.handleCoroutineException(CoroutineExceptionHandler.kt:33)
	at kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx_coroutines_core(Dispatched.kt:280)
	at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:249)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.kt:116)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:79)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:54)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at superfreeze.tool.android.AsyncDelegatedTest.getValue4(AsyncDelegatedTest.kt:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

The failed test:

	@Test
	fun getValue4() = runBlocking {
		(0..1000).map {
			launch {
				val b by AsyncDelegated {
					delay(10)
					"hi"
				}
				repeat(1000) {
					Assert.assertEquals("hi", b)
				}
			}
		}.joinAll()
	}

The tested class:

class AsyncDelegated<T>(val f: suspend () -> T) {
	private val deferred = GlobalScope.async {
		f()
	}

	operator fun getValue(thisRef: Any?, property: KProperty<*>): T = runBlocking {
		deferred.await() // TODO await() takes a lot of time (?)
	}
}

Invalidate caches and restart did not help.

Might be related to https://github.com/Kotlin/kotlinx.coroutines/issues/680.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
CuriousNikhilcommented, Aug 29, 2021

Yes, I got the same error as above ^ after upgrading kotlin to 1.5+

5reactions
davidljuba15031979commented, Aug 31, 2019

This ticket comment resolved my problem: https://youtrack.jetbrains.com/issue/KT-27994#focus=streamItem-27-3148043.0-0

Fixed adding bomProperty("kotlin.version", "1.3.50") in Spring Boot Gradle Kotlin Application:

plugins {
    kotlin("jvm") version "1.3.50"
    id("io.spring.dependency-management") version "1.0.8.RELEASE"
}

dependencyManagement {
    imports { mavenBom("org.springframework.boot:spring-boot-dependencies:2.1.6.RELEASE") {
        bomProperty("kotlin.version", "1.3.50") // https://youtrack.jetbrains.com/issue/KT-27994#focus=streamItem-27-3148043.0-0
    } }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not initialize class kotlinx.coroutines ...
My plugin is crashing occasionally with java.lang.NoClassDefFoundError: Could not initialize class kotlinx.coroutines.CoroutineExceptionHandlerImplKt .
Read more >
java.lang.NoClassDefFoundError: kotlinx.coroutines ...
Any help would be appreciated. Fatal Exception: java.lang.NoClassDefFoundError: kotlinx.coroutines.CoroutineExceptionHandlerImplKt at kotlinx.
Read more >
1.2.0-alpha06 completely breaks previews on library modules
Observe preview will not render. Stack trace (if applicable): java.lang.ClassNotFoundException: androidx.customview.poolingcontainer.R$id
Read more >
kotlinx-coroutines-test
This is helpful when one wants to execute a test in situations where the platform Main dispatcher is not available, or to replace...
Read more >
Diff - platform/external/kotlinx.coroutines - Google Git
+ * Fixed StackOverflow when waiting for a lot of completed children that did not remove their handlers from the parent. +* Use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found