Avoid using HashMap.computeIfAbsent with recursive creation function.

HashMap.computeIfAbsent holds on to an index into the backing across
the call to the creation function. Therefore, if the creation function
changes the hash map things can go wrong.

R=herhut@google.com, jsjeong@google.com

Bug: 67889172
Change-Id: I7eb642e13938688e1d69e327b46543361aa0c6e3
diff --git a/src/main/java/com/android/tools/r8/naming/ClassNameMinifier.java b/src/main/java/com/android/tools/r8/naming/ClassNameMinifier.java
index 410a47c..c5e62e2 100644
--- a/src/main/java/com/android/tools/r8/naming/ClassNameMinifier.java
+++ b/src/main/java/com/android/tools/r8/naming/ClassNameMinifier.java
@@ -282,7 +282,8 @@
   }
 
   private Namespace getStateForPackagePrefix(String prefix) {
-    return states.computeIfAbsent(prefix, k -> {
+    Namespace state = states.get(prefix);
+    if (state == null) {
       // Calculate the parent package prefix, e.g., La/b/c -> La/b
       String parentPackage = getParentPackagePrefix(prefix);
       // Create a state for parent package prefix, if necessary, in a recursive manner.
@@ -291,13 +292,16 @@
       // From the super state, get a renamed package prefix for the current level.
       String renamedPackagePrefix = superState.nextPackagePrefix();
       // Create a new state, which corresponds to a new name space, for the current level.
-      return new Namespace(renamedPackagePrefix);
-    });
+      state = new Namespace(renamedPackagePrefix);
+      states.put(prefix, state);
+    }
+    return state;
   }
 
   private Namespace getStateForOuterClass(DexType outer) {
     String prefix = getClassBinaryNameFromDescriptor(outer.toDescriptorString());
-    return states.computeIfAbsent(prefix, k -> {
+    Namespace state = states.get(prefix);
+    if (state == null) {
       // Create a naming state with this classes renaming as prefix.
       DexString renamed = renaming.get(outer);
       if (renamed == null) {
@@ -311,8 +315,10 @@
         }
       }
       String binaryName = getClassBinaryNameFromDescriptor(renamed.toString());
-      return new Namespace(binaryName, "$");
-    });
+      state = new Namespace(binaryName, "$");
+      states.put(prefix, state);
+    }
+    return state;
   }
 
   private void renameArrayTypeIfNeeded(DexType type) {