Account for java.lang.Object being in program when compiling libcore

Fixes: b/373385230
Change-Id: Idffb0a9e9948505077990a30827bf02f061a7130
diff --git a/src/main/java/com/android/tools/r8/classmerging/ClassMergerTreeFixer.java b/src/main/java/com/android/tools/r8/classmerging/ClassMergerTreeFixer.java
index 167d305..73c2f14 100644
--- a/src/main/java/com/android/tools/r8/classmerging/ClassMergerTreeFixer.java
+++ b/src/main/java/com/android/tools/r8/classmerging/ClassMergerTreeFixer.java
@@ -113,9 +113,12 @@
     if (clazz.isInterface()) {
       return false;
     }
-    DexProgramClass superClass =
-        asProgramClassOrNull(appView.definitionFor(clazz.getSuperType(), clazz));
-    return superClass == null;
+    if (clazz.hasSuperType()) {
+      DexProgramClass superClass =
+          asProgramClassOrNull(appView.definitionFor(clazz.getSuperType(), clazz));
+      return superClass == null;
+    }
+    return true;
   }
 
   protected abstract void traverseProgramClassesDepthFirst(
@@ -148,10 +151,12 @@
   }
 
   private void fixupProgramClassSuperTypes(DexProgramClass clazz) {
-    DexType rewrittenSuperType = fixupType(clazz.getSuperType());
-    if (rewrittenSuperType.isNotIdenticalTo(clazz.getSuperType())) {
-      originalSuperTypes.put(clazz, clazz.getSuperType());
-      clazz.superType = rewrittenSuperType;
+    if (clazz.hasSuperType()) {
+      DexType rewrittenSuperType = fixupType(clazz.getSuperType());
+      if (rewrittenSuperType.isNotIdenticalTo(clazz.getSuperType())) {
+        originalSuperTypes.put(clazz, clazz.getSuperType());
+        clazz.setSuperType(rewrittenSuperType);
+      }
     }
     clazz.setInterfaces(fixupInterfaces(clazz, clazz.getInterfaces()));
   }
diff --git a/src/main/java/com/android/tools/r8/horizontalclassmerging/policies/deadlock/SingleCallerInformation.java b/src/main/java/com/android/tools/r8/horizontalclassmerging/policies/deadlock/SingleCallerInformation.java
index 112da4a..a1589b1 100644
--- a/src/main/java/com/android/tools/r8/horizontalclassmerging/policies/deadlock/SingleCallerInformation.java
+++ b/src/main/java/com/android/tools/r8/horizontalclassmerging/policies/deadlock/SingleCallerInformation.java
@@ -191,7 +191,9 @@
             });
 
         // Repeat for the parent classes.
-        triggerClassInitializer(clazz.getSuperType());
+        if (clazz.hasSuperType()) {
+          triggerClassInitializer(clazz.getSuperType());
+        }
       }
 
       @Override
diff --git a/src/main/java/com/android/tools/r8/optimize/bridgehoisting/BridgeHoisting.java b/src/main/java/com/android/tools/r8/optimize/bridgehoisting/BridgeHoisting.java
index b91bff4..d298f95 100644
--- a/src/main/java/com/android/tools/r8/optimize/bridgehoisting/BridgeHoisting.java
+++ b/src/main/java/com/android/tools/r8/optimize/bridgehoisting/BridgeHoisting.java
@@ -136,14 +136,16 @@
 
     // Bail out if the bridge is also declared in the parent class. In that case, hoisting would
     // change the behavior of calling the bridge on an instance of the parent class.
-    MethodResolutionResult res =
-        appView.appInfo().resolveMethodOnClass(clazz.getSuperType(), methodReference);
-    if (res.isSingleResolution()) {
-      if (!res.getResolvedMethod().isAbstract()) {
+    if (clazz.hasSuperType()) {
+      MethodResolutionResult res =
+          appView.appInfo().resolveMethodOnClass(clazz.getSuperType(), methodReference);
+      if (res.isSingleResolution()) {
+        if (!res.getResolvedMethod().isAbstract()) {
+          return;
+        }
+      } else if (res.isMultiMethodResolutionResult()) {
         return;
       }
-    } else if (res.isMultiMethodResolutionResult()) {
-      return;
     }
 
     // Go through each of the subclasses and find the bridges that can be hoisted. The bridge holder