PR libgcj/35020: Class.getSimpleName() differs from Sun Java
Andrew Haley
aph@redhat.com
Thu May 22 16:08:00 GMT 2008
2008-05-22 Andrew Haley <aph@redhat.com>
PR libgcj/35020
* java/lang/Class.java (getSimpleName): Import from GNU Classpath.
Index: java/lang/Class.java
===================================================================
*** java/lang/Class.java (revision 135765)
--- java/lang/Class.java (working copy)
***************
*** 1075,1096 ****
*/
public String getSimpleName()
{
! StringBuffer sb = new StringBuffer();
! Class klass = this;
! int arrayCount = 0;
! while (klass.isArray())
{
! klass = klass.getComponentType();
! ++arrayCount;
}
! if (! klass.isAnonymousClass())
{
! String fullName = klass.getName();
! sb.append(fullName, fullName.lastIndexOf(".") + 1, fullName.length());
}
! while (arrayCount-- > 0)
! sb.append("[]");
! return sb.toString();
}
/**
--- 1075,1101 ----
*/
public String getSimpleName()
{
! 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;
}
! int packagePos = fullName.lastIndexOf(".", pos);
! if (packagePos == -1)
! return fullName.substring(pos);
! else
! return fullName.substring(packagePos + 1);
}
/**
More information about the Java-patches
mailing list