summaryrefslogtreecommitdiff
path: root/recipes/classpath/files/SimpleName.diff
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/classpath/files/SimpleName.diff')
-rw-r--r--recipes/classpath/files/SimpleName.diff66
1 files changed, 66 insertions, 0 deletions
diff --git a/recipes/classpath/files/SimpleName.diff b/recipes/classpath/files/SimpleName.diff
new file mode 100644
index 0000000000..ff2bec0f1c
--- /dev/null
+++ b/recipes/classpath/files/SimpleName.diff
@@ -0,0 +1,66 @@
+Index: vm/reference/java/lang/VMClass.java
+===================================================================
+RCS file: /sources/classpath/classpath/vm/reference/java/lang/VMClass.java,v
+retrieving revision 1.20
+diff -u -r1.20 VMClass.java
+--- vm/reference/java/lang/VMClass.java 18 Sep 2007 21:52:38 -0000 1.20
++++ vm/reference/java/lang/VMClass.java 19 Apr 2008 15:19:00 -0000
+@@ -296,27 +296,43 @@
+ */
+ static String getSimpleName(Class klass)
+ {
++ int arrayCount = 0;
++ while (klass.isArray())
++ {
++ klass = klass.getComponentType();
++ ++arrayCount;
++ }
++ // now klass is the component type
++
++ String simpleComponentName = null;
+ if (isAnonymousClass(klass))
+- return "";
+- if (isArray(klass))
+ {
+- return getComponentType(klass).getSimpleName() + "[]";
++ simpleComponentName = "";
+ }
+- String fullName = getName(klass);
+- int pos = fullName.lastIndexOf("$");
+- if (pos == -1)
+- pos = 0;
+ else
+ {
+- ++pos;
+- while (Character.isDigit(fullName.charAt(pos)))
+- ++pos;
++ String fullName = getName(klass);
++ int pos = fullName.lastIndexOf("$");
++ if (pos != -1)
++ { //inner class or local class
++ // skip digits of local classes
++ while (Character.isDigit(fullName.charAt(pos+1)))
++ pos++;
++ }
++ else
++ {
++ pos = fullName.lastIndexOf(".");
++ }
++ simpleComponentName = fullName.substring(pos+1);
+ }
+- int packagePos = fullName.lastIndexOf(".", pos);
+- if (packagePos == -1)
+- return fullName.substring(pos);
+- else
+- return fullName.substring(packagePos + 1);
++
++ if (arrayCount == 0)
++ return simpleComponentName;
++
++ StringBuffer sb = new StringBuffer(simpleComponentName);
++ while (arrayCount-- > 0)
++ sb.append("[]");
++ return sb.toString();
+ }
+
+ /**