Skip to content

Commit 10a6da3

Browse files
committed
kotlinx-coroutines-debug: Fix split-package with the -core module
- `kotlinx.coroutines.debug.internal` owned by coroutines-core - `kotlinx.coroutines.debug` owned by coroutines-debug (Which also reflects the nature of the debug module, which exposes _some_ public API from the .debug.internal package) This requires moving: - AgentPremain -> .debug.internal - ByteBuddyDynamicAttach -> .debug - NoOpProbes.kt -> .debug
1 parent 6c6df2b commit 10a6da3

File tree

11 files changed

+17
-15
lines changed

11 files changed

+17
-15
lines changed

kotlinx-coroutines-core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ val allMetadataJar by tasks.getting(Jar::class) { setupManifest(this) }
188188
fun setupManifest(jar: Jar) {
189189
jar.manifest {
190190
attributes(mapOf(
191-
"Premain-Class" to "kotlinx.coroutines.debug.AgentPremain",
191+
"Premain-Class" to "kotlinx.coroutines.debug.internal.AgentPremain",
192192
"Can-Retransform-Classes" to "true",
193193
))
194194
}

kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/proguard/coroutines.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
volatile <fields>;
1717
}
1818

19-
# These classes are only required by kotlinx.coroutines.debug.AgentPremain, which is only loaded when
19+
# These classes are only required by kotlinx.coroutines.debug.internal.AgentPremain, which is only loaded when
2020
# kotlinx-coroutines-core is used as a Java agent, so these are not needed in contexts where ProGuard is used.
2121
-dontwarn java.lang.instrument.ClassFileTransformer
2222
-dontwarn sun.misc.SignalHandler

kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/r8/coroutines.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
volatile <fields>;
1313
}
1414

15-
# These classes are only required by kotlinx.coroutines.debug.AgentPremain, which is only loaded when
15+
# These classes are only required by kotlinx.coroutines.debug.internal.AgentPremain, which is only loaded when
1616
# kotlinx-coroutines-core is used as a Java agent, so these are not needed in contexts where ProGuard is used.
1717
-dontwarn java.lang.instrument.ClassFileTransformer
1818
-dontwarn sun.misc.SignalHandler

kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
volatile <fields>;
1717
}
1818

19-
# These classes are only required by kotlinx.coroutines.debug.AgentPremain, which is only loaded when
19+
# These classes are only required by kotlinx.coroutines.debug.internal.AgentPremain, which is only loaded when
2020
# kotlinx-coroutines-core is used as a Java agent, so these are not needed in contexts where ProGuard is used.
2121
-dontwarn java.lang.instrument.ClassFileTransformer
2222
-dontwarn sun.misc.SignalHandler

kotlinx-coroutines-core/jvm/src/debug/internal/AgentInstallationType.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ package kotlinx.coroutines.debug.internal
33
/**
44
* Object used to differentiate between agent installed statically or dynamically.
55
* This is done in a separate object so [DebugProbesImpl] can check for static installation
6-
* without having to depend on [kotlinx.coroutines.debug.AgentPremain], which is not compatible with Android.
6+
* without having to depend on [AgentPremain], which is not compatible with Android.
77
* Otherwise, access to `AgentPremain.isInstalledStatically` triggers the load of its internal `ClassFileTransformer`
88
* that is not available on Android.
9+
*
10+
* Usage Note: Fleet (Reflection): FleetDebugProbes
11+
* Usage Note: Android (Hard Coded, ignored for Leak Detection)
12+
* Usage Note: IntelliJ (Suppress KotlinInternalInJava): CoroutineDumpState
913
*/
1014
internal object AgentInstallationType {
1115
internal var isInstalledStatically = false

kotlinx-coroutines-core/jvm/src/debug/AgentPremain.kt renamed to kotlinx-coroutines-core/jvm/src/debug/internal/AgentPremain.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
package kotlinx.coroutines.debug
1+
package kotlinx.coroutines.debug.internal
22

33
import android.annotation.*
4-
import kotlinx.coroutines.debug.internal.*
54
import org.codehaus.mojo.animal_sniffer.*
65
import sun.misc.*
76
import java.lang.instrument.*

kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal object DebugProbesImpl {
5151

5252
@Suppress("UNCHECKED_CAST")
5353
private fun getDynamicAttach(): Function1<Boolean, Unit>? = runCatching {
54-
val clz = Class.forName("kotlinx.coroutines.debug.internal.ByteBuddyDynamicAttach")
54+
val clz = Class.forName("kotlinx.coroutines.debug.ByteBuddyDynamicAttach")
5555
val ctor = clz.constructors[0]
5656
ctor.newInstance() as Function1<Boolean, Unit>
5757
}.getOrNull()

kotlinx-coroutines-core/jvm/src/module-info.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
requires transitive kotlin.stdlib;
66
requires kotlinx.atomicfu;
77

8-
// these are used by kotlinx.coroutines.debug.AgentPremain
8+
// these are used by kotlinx.coroutines.debug.internal.AgentPremain
99
requires static java.instrument; // contains java.lang.instrument.*
1010
requires static jdk.unsupported; // contains sun.misc.Signal
1111

1212
exports kotlinx.coroutines;
1313
exports kotlinx.coroutines.channels;
14-
exports kotlinx.coroutines.debug;
1514
exports kotlinx.coroutines.debug.internal;
1615
exports kotlinx.coroutines.flow;
1716
exports kotlinx.coroutines.flow.internal;

kotlinx-coroutines-debug/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ val shadowJar by tasks.existing(ShadowJar::class) {
6868
manifest {
6969
attributes(
7070
mapOf(
71-
"Premain-Class" to "kotlinx.coroutines.debug.AgentPremain",
71+
"Premain-Class" to "kotlinx.coroutines.debug.internal.AgentPremain",
7272
"Can-Redefine-Classes" to "true",
7373
"Multi-Release" to "true"
7474
)
@@ -104,7 +104,7 @@ kover {
104104
filters {
105105
excludes {
106106
// Never used, safety mechanism
107-
classes("kotlinx.coroutines.debug.internal.NoOpProbesKt")
107+
classes("kotlinx.coroutines.debug.NoOpProbesKt")
108108
}
109109
}
110110
}

kotlinx-coroutines-debug/src/internal/Attach.kt renamed to kotlinx-coroutines-debug/src/Attach.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@file:Suppress("unused")
2-
package kotlinx.coroutines.debug.internal
2+
package kotlinx.coroutines.debug
33

44
import net.bytebuddy.*
55
import net.bytebuddy.agent.*
@@ -28,7 +28,7 @@ internal class ByteBuddyDynamicAttach : Function1<Boolean, Unit> {
2828

2929
private fun detach() {
3030
val cl = Class.forName("kotlin.coroutines.jvm.internal.DebugProbesKt")
31-
val cl2 = Class.forName("kotlinx.coroutines.debug.internal.NoOpProbesKt")
31+
val cl2 = Class.forName("kotlinx.coroutines.debug.NoOpProbesKt")
3232
ByteBuddy()
3333
.redefine(cl2)
3434
.name(cl.name)

0 commit comments

Comments
 (0)