re PR libgcj/35020 (Class.getSimpleName() differs from Sun Java)

2008-05-22  Andrew Haley  <aph@redhat.com>

        PR libgcj/35020
        * java/lang/Class.java (getSimpleName): Import from GNU Classpath.

From-SVN: r135771
This commit is contained in:
Andrew Haley 2008-05-22 16:20:55 +00:00 committed by Andrew Haley
parent 4799e6aa58
commit 9f8e4e845b
4 changed files with 22 additions and 12 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -1075,22 +1075,27 @@ public final class Class<T>
*/
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);
}
/**