re PR libgcj/35020 (Class.getSimpleName() differs from Sun Java)
2008-05-28 Andrew Haley <aph@redhat.com> * java/lang/Class.java (getSimpleName): Use getEnclosingClass(). * testsuite/libjava.lang/PR35020.java: New cases. * testsuite/libjava.lang/PR35020.out: New cases. From-SVN: r136103
This commit is contained in:
parent
38154e4f0f
commit
71292a0540
6 changed files with 53 additions and 37 deletions
|
@ -1078,26 +1078,24 @@ public final class Class<T>
|
|||
if (isAnonymousClass())
|
||||
return "";
|
||||
if (isArray())
|
||||
{
|
||||
return getComponentType().getSimpleName() + "[]";
|
||||
}
|
||||
String fullName = getName();
|
||||
int pos = fullName.lastIndexOf("$");
|
||||
if (pos == -1)
|
||||
pos = 0;
|
||||
else
|
||||
{
|
||||
++pos;
|
||||
while (Character.isDigit(fullName.charAt(pos)))
|
||||
++pos;
|
||||
fullName = fullName.substring(pos);
|
||||
}
|
||||
return getComponentType().getSimpleName() + "[]";
|
||||
|
||||
int packagePos = fullName.lastIndexOf(".");
|
||||
if (packagePos == -1)
|
||||
return fullName;
|
||||
else
|
||||
return fullName.substring(packagePos + 1);
|
||||
String fullName = getName();
|
||||
Class enclosingClass = getEnclosingClass();
|
||||
if (enclosingClass == null)
|
||||
// It's a top level class.
|
||||
return fullName.substring(fullName.lastIndexOf(".") + 1);
|
||||
|
||||
fullName = fullName.substring(enclosingClass.getName().length());
|
||||
|
||||
// We've carved off the enclosing class name; now we must have '$'
|
||||
// followed optionally by digits, followed by the class name.
|
||||
int pos = 1;
|
||||
while (Character.isDigit(fullName.charAt(pos)))
|
||||
++pos;
|
||||
fullName = fullName.substring(pos);
|
||||
|
||||
return fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue