Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
R8 specific rules to allow for service loader optimizations (#2880)
Fixes the R8 ServiceLoader optimization that broke in the R8 bundled in the new AGP. For details, see https://issuetracker.google.com/issues/196302685
- Loading branch information
1 parent
463f9a0
commit dfc4821
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/proguard/coroutines.pro
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# When editing this file, update the following files as well: | ||
# - META-INF/proguard/coroutines.pro | ||
# - META-INF/com.android.tools/r8/coroutines.pro | ||
|
||
# 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 <fields>; | ||
} | ||
|
||
# Same story for the standard library's SafeContinuation that also uses AtomicReferenceFieldUpdater | ||
-keepclassmembers class kotlin.coroutines.SafeContinuation { | ||
volatile <fields>; | ||
} | ||
|
||
# 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 |
20 changes: 20 additions & 0 deletions
20
kotlinx-coroutines-core/jvm/resources/META-INF/com.android.tools/r8/coroutines.pro
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# When editing this file, update the following files as well: | ||
# - META-INF/proguard/coroutines.pro | ||
# - META-INF/com.android.tools/proguard/coroutines.pro | ||
|
||
# Most of volatile fields are updated with AFU and should not be mangled | ||
-keepclassmembers class kotlinx.coroutines.** { | ||
volatile <fields>; | ||
} | ||
|
||
# Same story for the standard library's SafeContinuation that also uses AtomicReferenceFieldUpdater | ||
-keepclassmembers class kotlin.coroutines.SafeContinuation { | ||
volatile <fields>; | ||
} | ||
|
||
# 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 |
4 changes: 4 additions & 0 deletions
4
kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro
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