.kotlinx.kotlinx-coroutines-debug.1.10.1.source-code.Attach.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlinx-coroutines-debug Show documentation
Show all versions of kotlinx-coroutines-debug Show documentation
Coroutines support libraries for Kotlin
The newest version!
@file:Suppress("unused")
package kotlinx.coroutines.debug
import net.bytebuddy.*
import net.bytebuddy.agent.*
import net.bytebuddy.dynamic.loading.*
/*
* This class is used reflectively from kotlinx-coroutines-core when this module is present in the classpath.
* It is a substitute for service loading.
*/
internal class ByteBuddyDynamicAttach : Function1 {
override fun invoke(value: Boolean) {
if (value) attach() else detach()
}
private fun attach() {
ByteBuddyAgent.install(ByteBuddyAgent.AttachmentProvider.ForEmulatedAttachment.INSTANCE)
val cl = Class.forName("kotlin.coroutines.jvm.internal.DebugProbesKt")
val cl2 = Class.forName("kotlinx.coroutines.debug.internal.DebugProbesKt")
ByteBuddy()
.redefine(cl2)
.name(cl.name)
.make()
.load(cl.classLoader, ClassReloadingStrategy.fromInstalledAgent())
}
private fun detach() {
val cl = Class.forName("kotlin.coroutines.jvm.internal.DebugProbesKt")
val cl2 = Class.forName("kotlinx.coroutines.debug.NoOpProbesKt")
ByteBuddy()
.redefine(cl2)
.name(cl.name)
.make()
.load(cl.classLoader, ClassReloadingStrategy.fromInstalledAgent())
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy