Last active
February 21, 2018 08:41
-
-
Save ov7a/18d568dab9c3d79796c26a886a64ad62 to your computer and use it in GitHub Desktop.
Kotlin and quasar MWE for Unable to instrument class kotlin/SynchronizedLazyImpl https://github.com/puniverse/quasar/issues/288
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'idea' | |
apply plugin: 'kotlin' | |
apply plugin: 'application' | |
buildscript { | |
ext.kotlin_version = '1.1.51' | |
ext.quasar_version = '0.7.9' | |
repositories { | |
mavenCentral() | |
maven { | |
url "https://plugins.gradle.org/m2/" | |
} | |
} | |
dependencies { | |
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") | |
classpath("org.jetbrains.kotlin:kotlin-noarg:$kotlin_version") | |
classpath("org.jetbrains.kotlin:kotlin-allopen:$kotlin_version") | |
} | |
} | |
configurations { | |
quasar | |
} | |
repositories { | |
mavenCentral() | |
maven { url "https://oss.sonatype.org/content/repositories/snapshots" } | |
} | |
dependencies { | |
compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version") | |
compile("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version") | |
compile("co.paralleluniverse:quasar-core:$quasar_version:jdk8") | |
compile("co.paralleluniverse:quasar-actors:$quasar_version") | |
compile("co.paralleluniverse:quasar-kotlin:$quasar_version") | |
quasar "co.paralleluniverse:quasar-core:$quasar_version:jdk8" | |
} | |
tasks.withType(JavaForkOptions) { | |
systemProperty 'co.paralleluniverse.fibers.detectRunawayFibers', 'false' | |
//uncomment if there are problems with fibers | |
systemProperty 'co.paralleluniverse.fibers.verifyInstrumentation', 'true' | |
jvmArgs "-javaagent:${(++configurations.quasar.iterator())}" | |
} | |
mainClassName = "mwe.Main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mwe | |
import co.paralleluniverse.fibers.Suspendable | |
import co.paralleluniverse.kotlin.Actor | |
import co.paralleluniverse.kotlin.register | |
import co.paralleluniverse.kotlin.spawn | |
import co.paralleluniverse.strands.Strand | |
class LazyActor : Actor() { | |
val x: String by lazy { | |
"some string" | |
} | |
@Suspendable | |
override fun doRun() { | |
while (true) { | |
println(x) | |
Strand.sleep(1000) | |
} | |
} | |
} | |
object Main { | |
@JvmStatic | |
fun main(args: Array<String>) { | |
spawn(register("actorId", LazyActor())) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:compileKotlin | |
Using Kotlin incremental compilation | |
Could not perform incremental compilation: Could not connect to Kotlin compile daemon | |
Could not connect to kotlin daemon. Using fallback strategy. | |
warning: the '-d' option with a directory destination is ignored because '-Xbuild-file' is specified | |
:compileJava NO-SOURCE | |
:copyMainKotlinClasses UP-TO-DATE | |
:processResources NO-SOURCE | |
:classes UP-TO-DATE | |
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". | |
SLF4J: Defaulting to no-operation (NOP) logger implementation | |
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. | |
[quasar] WARNING: UnableToInstrumentException encountered when instrumenting kotlin/SynchronizedLazyImpl#getValue()Ljava/lang/Object;: Unable to instrument kotlin/SynchronizedLazyImpl#getValue()Ljava/lang/Object; because of synchronization | |
[quasar] ERROR: Unable to instrument class kotlin/SynchronizedLazyImpl | |
java.lang.NullPointerException | |
at co.paralleluniverse.asm.MethodWriter.visitMaxs(Unknown Source) | |
at co.paralleluniverse.asm.tree.MethodNode.accept(Unknown Source) | |
at co.paralleluniverse.fibers.instrument.InstrumentClass.visitEnd(InstrumentClass.java:260) | |
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) | |
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) | |
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:134) | |
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:94) | |
at co.paralleluniverse.fibers.instrument.JavaAgent$Transformer.transform(JavaAgent.java:209) | |
at sun.instrument.TransformerManager.transform(TransformerManager.java:188) | |
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428) | |
at java.lang.ClassLoader.defineClass1(Native Method) | |
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) | |
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) | |
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) | |
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) | |
at java.security.AccessController.doPrivileged(Native Method) | |
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) | |
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) | |
at kotlin.LazyKt.lazy(Lazy.kt:40) | |
at mwe.LazyActor.<init>(Main.kt:11) | |
at mwe.Main.main(Main.kt:29) | |
[quasar] ERROR: while transforming kotlin/SynchronizedLazyImpl: null | |
java.lang.NullPointerException | |
at co.paralleluniverse.asm.MethodWriter.visitMaxs(Unknown Source) | |
at co.paralleluniverse.asm.tree.MethodNode.accept(Unknown Source) | |
at co.paralleluniverse.fibers.instrument.InstrumentClass.visitEnd(InstrumentClass.java:260) | |
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) | |
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source) | |
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:134) | |
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:94) | |
at co.paralleluniverse.fibers.instrument.JavaAgent$Transformer.transform(JavaAgent.java:209) | |
at sun.instrument.TransformerManager.transform(TransformerManager.java:188) | |
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428) | |
at java.lang.ClassLoader.defineClass1(Native Method) | |
at java.lang.ClassLoader.defineClass(ClassLoader.java:763) | |
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) | |
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) | |
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:368) | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:362) | |
at java.security.AccessController.doPrivileged(Native Method) | |
at java.net.URLClassLoader.findClass(URLClassLoader.java:361) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) | |
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) | |
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) | |
at kotlin.LazyKt.lazy(Lazy.kt:40) | |
at mwe.LazyActor.<init>(Main.kt:11) | |
at mwe.Main.main(Main.kt:29) | |
:run | |
some string | |
some string | |
BUILD SUCCESSFUL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment