+2008-05-22 Andrew Haley <aph@redhat.com>
+
+ PR libgcj/35020
+ * java/lang/Class.java (getSimpleName): Import from GNU Classpath.
+
2008-05-20 David Daney <ddaney@avtrex.com>
PR libgcj/36252
*/
public String getSimpleName()
{
- StringBuffer sb = new StringBuffer();
- Class klass = this;
- int arrayCount = 0;
- while (klass.isArray())
+ if (isAnonymousClass())
+ return "";
+ if (isArray())
{
- klass = klass.getComponentType();
- ++arrayCount;
+ return getComponentType().getSimpleName() + "[]";
}
- if (! klass.isAnonymousClass())
+ String fullName = getName();
+ int pos = fullName.lastIndexOf("$");
+ if (pos == -1)
+ pos = 0;
+ else
{
- String fullName = klass.getName();
- sb.append(fullName, fullName.lastIndexOf(".") + 1, fullName.length());
+ ++pos;
+ while (Character.isDigit(fullName.charAt(pos)))
+ ++pos;
}
- while (arrayCount-- > 0)
- sb.append("[]");
- return sb.toString();
+ int packagePos = fullName.lastIndexOf(".", pos);
+ if (packagePos == -1)
+ return fullName.substring(pos);
+ else
+ return fullName.substring(packagePos + 1);
}
/**