summaryrefslogtreecommitdiffstats
path: root/recipes-core/classpath/classpath-0.98/SimpleName.diff
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-core/classpath/classpath-0.98/SimpleName.diff')
-rw-r--r--recipes-core/classpath/classpath-0.98/SimpleName.diff66
1 files changed, 66 insertions, 0 deletions
diff --git a/recipes-core/classpath/classpath-0.98/SimpleName.diff b/recipes-core/classpath/classpath-0.98/SimpleName.diff
new file mode 100644
index 0000000..ff2bec0
--- /dev/null
+++ b/recipes-core/classpath/classpath-0.98/SimpleName.diff
@@ -0,0 +1,66 @@
1Index: vm/reference/java/lang/VMClass.java
2===================================================================
3RCS file: /sources/classpath/classpath/vm/reference/java/lang/VMClass.java,v
4retrieving revision 1.20
5diff -u -r1.20 VMClass.java
6--- vm/reference/java/lang/VMClass.java 18 Sep 2007 21:52:38 -0000 1.20
7+++ vm/reference/java/lang/VMClass.java 19 Apr 2008 15:19:00 -0000
8@@ -296,27 +296,43 @@
9 */
10 static String getSimpleName(Class klass)
11 {
12+ int arrayCount = 0;
13+ while (klass.isArray())
14+ {
15+ klass = klass.getComponentType();
16+ ++arrayCount;
17+ }
18+ // now klass is the component type
19+
20+ String simpleComponentName = null;
21 if (isAnonymousClass(klass))
22- return "";
23- if (isArray(klass))
24 {
25- return getComponentType(klass).getSimpleName() + "[]";
26+ simpleComponentName = "";
27 }
28- String fullName = getName(klass);
29- int pos = fullName.lastIndexOf("$");
30- if (pos == -1)
31- pos = 0;
32 else
33 {
34- ++pos;
35- while (Character.isDigit(fullName.charAt(pos)))
36- ++pos;
37+ String fullName = getName(klass);
38+ int pos = fullName.lastIndexOf("$");
39+ if (pos != -1)
40+ { //inner class or local class
41+ // skip digits of local classes
42+ while (Character.isDigit(fullName.charAt(pos+1)))
43+ pos++;
44+ }
45+ else
46+ {
47+ pos = fullName.lastIndexOf(".");
48+ }
49+ simpleComponentName = fullName.substring(pos+1);
50 }
51- int packagePos = fullName.lastIndexOf(".", pos);
52- if (packagePos == -1)
53- return fullName.substring(pos);
54- else
55- return fullName.substring(packagePos + 1);
56+
57+ if (arrayCount == 0)
58+ return simpleComponentName;
59+
60+ StringBuffer sb = new StringBuffer(simpleComponentName);
61+ while (arrayCount-- > 0)
62+ sb.append("[]");
63+ return sb.toString();
64 }
65
66 /**