From d1c3d52d4dc64b80d2398376ab64548e14ed96eb Mon Sep 17 00:00:00 2001 From: Morten Krogh-Jespersen Date: Fri, 13 Aug 2021 13:37:32 +0200 Subject: [PATCH 1/2] Create R8 specific to allow for service loader optimizations --- .../jvm/resources/META-INF/r8/coroutines.pro | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 kotlinx-coroutines-core/jvm/resources/META-INF/r8/coroutines.pro diff --git a/kotlinx-coroutines-core/jvm/resources/META-INF/r8/coroutines.pro b/kotlinx-coroutines-core/jvm/resources/META-INF/r8/coroutines.pro new file mode 100644 index 0000000000..c8abd9e723 --- /dev/null +++ b/kotlinx-coroutines-core/jvm/resources/META-INF/r8/coroutines.pro @@ -0,0 +1,16 @@ +# Most of volatile fields are updated with AFU and should not be mangled +-keepclassmembers class kotlinx.coroutines.** { + volatile ; +} + +# Same story for the standard library's SafeContinuation that also uses AtomicReferenceFieldUpdater +-keepclassmembers class kotlin.coroutines.SafeContinuation { + volatile ; +} + +# These classes are only required by kotlinx.coroutines.debug.AgentPremain, which is only loaded when +# kotlinx-coroutines-core is used as a Java agent, so these are not needed in contexts where ProGuard is used. +-dontwarn java.lang.instrument.ClassFileTransformer +-dontwarn sun.misc.SignalHandler +-dontwarn java.lang.instrument.Instrumentation +-dontwarn sun.misc.Signal From f967d630d24b11cfc05e818550211d59dce868df Mon Sep 17 00:00:00 2001 From: Morten Krogh-Jespersen Date: Fri, 1 Oct 2021 00:36:34 +0200 Subject: [PATCH 2/2] Move R8 specific files into com.android.tools folder --- .../com.android.tools/proguard/coroutines.pro | 20 +++++++++++++++++++ .../{ => com.android.tools}/r8/coroutines.pro | 0 2 files changed, 20 insertions(+) create mode 100644 kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/proguard/coroutines.pro rename kotlinx-coroutines-core/jvm/resources/META-INF/{ => com.android.tools}/r8/coroutines.pro (100%) diff --git a/kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/proguard/coroutines.pro b/kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/proguard/coroutines.pro new file mode 100644 index 0000000000..1a9ae1c7ff --- /dev/null +++ b/kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/proguard/coroutines.pro @@ -0,0 +1,20 @@ +# ServiceLoader support +-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {} +-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {} + +# Most of volatile fields are updated with AFU and should not be mangled +-keepclassmembers class kotlinx.coroutines.** { + volatile ; +} + +# Same story for the standard library's SafeContinuation that also uses AtomicReferenceFieldUpdater +-keepclassmembers class kotlin.coroutines.SafeContinuation { + volatile ; +} + +# These classes are only required by kotlinx.coroutines.debug.AgentPremain, which is only loaded when +# kotlinx-coroutines-core is used as a Java agent, so these are not needed in contexts where ProGuard is used. +-dontwarn java.lang.instrument.ClassFileTransformer +-dontwarn sun.misc.SignalHandler +-dontwarn java.lang.instrument.Instrumentation +-dontwarn sun.misc.Signal diff --git a/kotlinx-coroutines-core/jvm/resources/META-INF/r8/coroutines.pro b/kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/r8/coroutines.pro similarity index 100% rename from kotlinx-coroutines-core/jvm/resources/META-INF/r8/coroutines.pro rename to kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/r8/coroutines.pro