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:
parent
4799e6aa58
commit
9f8e4e845b
@ -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
|
||||
|
Binary file not shown.
Binary file not shown.
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user