This patch replaces VMClass#getSimpleName() implementation with JamVM's version
that supposedly comes from GCJ. This fixes a compatibility problem found by
Malva.

Signed-off-by: Pekka Enberg <penb...@kernel.org>
---
 vm/reference/java/lang/VMClass.java |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/vm/reference/java/lang/VMClass.java 
b/vm/reference/java/lang/VMClass.java
index a0091c0..76f9039 100644
--- a/vm/reference/java/lang/VMClass.java
+++ b/vm/reference/java/lang/VMClass.java
@@ -299,24 +299,24 @@ final class VMClass
     if (isAnonymousClass(klass))
       return "";
     if (isArray(klass))
-      {
-        return getComponentType(klass).getSimpleName() + "[]";
-      }
+      return getComponentType(klass).getSimpleName() + "[]";
+
     String fullName = getName(klass);
-    int pos = fullName.lastIndexOf("$");
-    if (pos == -1)
-      pos = 0;
-    else
-      {
-        ++pos;
-        while (Character.isDigit(fullName.charAt(pos)))
-          ++pos;
-      }
-    int packagePos = fullName.lastIndexOf(".", pos);
-    if (packagePos == -1)
-      return fullName.substring(pos);
-    else
-      return fullName.substring(packagePos + 1);
+    Class enclosingClass = getEnclosingClass(klass);
+    if (enclosingClass == null)
+      // It's a top level class.
+      return fullName.substring(fullName.lastIndexOf(".") + 1);
+
+    fullName = fullName.substring(enclosingClass.getName().length());
+
+    // We've carved off the enclosing class name; now we must have '$'
+    // followed optionally by digits, followed by the class name.
+    int pos = 1;
+    while (Character.isDigit(fullName.charAt(pos)))
+      ++pos;
+    fullName = fullName.substring(pos);
+
+    return fullName;
   }
 
   /**
-- 
1.7.0.4


Reply via email to