Version 2.0.36
Cherry-pick: Use AtomicInteger for increment synthesized
service-loader methods
CL: https://r8-review.googlesource.com/48420
Bug: 148929520
Change-Id: I5806a2a02995b2d982cee9775d6692df3d77194d
diff --git a/src/main/java/com/android/tools/r8/Version.java b/src/main/java/com/android/tools/r8/Version.java
index 26d82b5..72b9c00 100644
--- a/src/main/java/com/android/tools/r8/Version.java
+++ b/src/main/java/com/android/tools/r8/Version.java
@@ -11,7 +11,7 @@
// This field is accessed from release scripts using simple pattern matching.
// Therefore, changing this field could break our release scripts.
- public static final String LABEL = "2.0.35";
+ public static final String LABEL = "2.0.36";
private Version() {
}
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java b/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
index 856baa9..e8799da 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/ServiceLoaderRewriter.java
@@ -35,6 +35,7 @@
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* ServiceLoaderRewriter will attempt to rewrite calls on the form of: ServiceLoader.load(X.class,
@@ -72,6 +73,8 @@
private ConcurrentHashMap<DexType, DexEncodedMethod> synthesizedServiceLoaders =
new ConcurrentHashMap<>();
+ private AtomicInteger atomicInteger = new AtomicInteger(0);
+
private final AppView<? extends AppInfoWithLiveness> appView;
public ServiceLoaderRewriter(AppView<? extends AppInfoWithLiveness> appView) {
@@ -216,7 +219,7 @@
.createMethod(
serviceLoaderType,
proto,
- SERVICE_LOADER_METHOD_PREFIX_NAME + synthesizedServiceLoaders.size());
+ SERVICE_LOADER_METHOD_PREFIX_NAME + atomicInteger.incrementAndGet());
MethodAccessFlags methodAccess =
MethodAccessFlags.fromSharedAccessFlags(Constants.ACC_PUBLIC | Constants.ACC_STATIC, false);
DexEncodedMethod encodedMethod =