Fix race in NestReducer
Bug: 140781644
Change-Id: I718a3743063d1864bfd6a7604b5a5a450d111e67
diff --git a/src/main/java/com/android/tools/r8/ir/optimize/NestReducer.java b/src/main/java/com/android/tools/r8/ir/optimize/NestReducer.java
index 97c9eb7..715c936 100644
--- a/src/main/java/com/android/tools/r8/ir/optimize/NestReducer.java
+++ b/src/main/java/com/android/tools/r8/ir/optimize/NestReducer.java
@@ -47,17 +47,15 @@
// Nests are therefore computed the first time a nest member is met, host or not.
// The computedNestHosts list is there to avoid processing multiple times the same nest.
for (DexProgramClass clazz : appView.appInfo().classes()) {
- if (clazz.isInANest()) {
- DexType hostType = clazz.getNestHost();
- if (!nestHosts.contains(hostType)) {
- nestHosts.add(hostType);
- futures.add(
- executorService.submit(
- () -> {
- processNestFrom(clazz);
- return null; // we want a Callable not a Runnable to be able to throw
- }));
- }
+ DexType hostType = clazz.getNestHost();
+ if (hostType != null && !nestHosts.contains(hostType)) {
+ nestHosts.add(hostType);
+ futures.add(
+ executorService.submit(
+ () -> {
+ processNestFrom(clazz);
+ return null; // we want a Callable not a Runnable to be able to throw
+ }));
}
}
ThreadUtils.awaitFutures(futures);