Skip to content

Instantly share code, notes, and snippets.

@andredasilvapinto
Created December 31, 2017 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andredasilvapinto/a63468acd56498fd6f17bcad2905d41b to your computer and use it in GitHub Desktop.
Save andredasilvapinto/a63468acd56498fd6f17bcad2905d41b to your computer and use it in GitHub Desktop.
java.lang.VerifyError: Bad type on operand stack
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.experimental.runBlocking
import java.util.*
import kotlin.concurrent.schedule
class Test {
fun scheduleTimeout() {
Timer(true).schedule(300) {
launch {
runSuspended("hello")
}
}
}
suspend fun runSuspended(txt: String) = println(txt)
}
fun main(args: Array<String>) {
Test().scheduleTimeout()
runBlocking {
delay(10000)
}
}
@andredasilvapinto
Copy link
Author

Compiles successfully with Kotlin 1.2.10 but then fails with a RuntimeException:

Exception in thread "Timer-0" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    Test$scheduleTimeout$$inlined$schedule$1$lambda$1.create(Lkotlinx/coroutines/experimental/CoroutineScope;Lkotlin/coroutines/experimental/Continuation;)Lkotlin/coroutines/experimental/Continuation; @18: invokespecial
  Reason:
    Type 'Test$scheduleTimeout$$inlined$schedule$1$lambda$1' (current frame, stack[3]) is not assignable to 'Test$scheduleTimeout$$inlined$schedule$1'
  Current Frame:
    bci: @18
    flags: { }
    locals: { 'Test$scheduleTimeout$$inlined$schedule$1$lambda$1', 'kotlinx/coroutines/experimental/CoroutineScope', 'kotlin/coroutines/experimental/Continuation' }
    stack: { uninitialized 12, uninitialized 12, 'kotlin/coroutines/experimental/Continuation', 'Test$scheduleTimeout$$inlined$schedule$1$lambda$1' }
  Bytecode:
    0x0000000: 2b12 64b8 006a 2c12 6cb8 006a bb00 0259
    0x0000010: 2c2a b700 6e4e 2d2b b500 3d2d 3a04 1904
    0x0000020: b0                                     

	at Test$scheduleTimeout$$inlined$schedule$1.run(Timer.kt:145)
	at java.util.TimerThread.mainLoop(Timer.java:555)
	at java.util.TimerThread.run(Timer.java:505)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment