Fix StringIndexOutOfBoundsException in isRClassDescriptor

This fixes a bug where isRClassDescriptor would throw a
StringIndexOutOfBoundsException when called with a class descriptor
where the class name ends with $, which causes type.charAt(0) to fail
due to type being the empty string.

Fixes: b/447076894
Change-Id: I22dd20f4a3eeb9a757448af9f7ebfa284c192585
diff --git a/src/main/java/com/android/tools/r8/utils/DescriptorUtils.java b/src/main/java/com/android/tools/r8/utils/DescriptorUtils.java
index 39624d2..b9da81c 100644
--- a/src/main/java/com/android/tools/r8/utils/DescriptorUtils.java
+++ b/src/main/java/com/android/tools/r8/utils/DescriptorUtils.java
@@ -818,8 +818,11 @@
 
   public static boolean isRClassDescriptor(String descriptor) {
     String simpleClassName = DescriptorUtils.getSimpleClassNameFromDescriptor(descriptor);
-    List<String> split = StringUtils.split(simpleClassName, '$');
-
+    int innerClassSeparatorIndex = simpleClassName.lastIndexOf(INNER_CLASS_SEPARATOR);
+    if (innerClassSeparatorIndex < 0 || innerClassSeparatorIndex == simpleClassName.length() - 1) {
+      return false;
+    }
+    List<String> split = StringUtils.split(simpleClassName, INNER_CLASS_SEPARATOR);
     if (split.size() < 2) {
       return false;
     }
@@ -828,8 +831,7 @@
     // We match on R if:
     // - The name of the Class is R$type - we allow R to be an inner class.
     //   - The inner type should be with lower case
-    boolean isRClass = Character.isLowerCase(type.charAt(0)) && rClass.equals("R");
-    return isRClass;
+    return Character.isLowerCase(type.charAt(0)) && rClass.equals("R");
   }
 
   public static String getPathFromDescriptor(String descriptor) {