From: Andrew Haley Date: Fri, 23 May 2008 13:04:18 +0000 (+0000) Subject: re PR libgcj/35020 (Class.getSimpleName() differs from Sun Java) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cf38a465eca401054b78e6182f0dced39418554b;p=gcc.git re PR libgcj/35020 (Class.getSimpleName() differs from Sun Java) 2008-05-22 Andrew Haley PR libgcj/35020 * java/lang/Class.java (getSimpleName): Replace incorrect use of String.lastIndexOf(String, int) with String.substring. * testsuite/libjava.lang/PR35020.java: New file. * testsuite/libjava.lang/PR35020.out: New file. From-SVN: r135801 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 52061d2c1ed..37f12e2c892 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,11 @@ +2008-05-22 Andrew Haley + + PR libgcj/35020 + * java/lang/Class.java (getSimpleName): Replace incorrect use of + String.lastIndexOf(String, int) with String.substring. + * testsuite/libjava.lang/PR35020.java: New file. + * testsuite/libjava.lang/PR35020.out: New file. + 2008-05-22 Andrew Haley PR libgcj/35020 diff --git a/libjava/classpath/lib/java/lang/Class$1.class b/libjava/classpath/lib/java/lang/Class$1.class index 09e3e86f995..9c4806c0233 100644 Binary files a/libjava/classpath/lib/java/lang/Class$1.class and b/libjava/classpath/lib/java/lang/Class$1.class differ diff --git a/libjava/classpath/lib/java/lang/Class.class b/libjava/classpath/lib/java/lang/Class.class index bdcfcfe83bd..ce854558e54 100644 Binary files a/libjava/classpath/lib/java/lang/Class.class and b/libjava/classpath/lib/java/lang/Class.class differ diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java index d59e83ea4ec..868e370b819 100644 --- a/libjava/java/lang/Class.java +++ b/libjava/java/lang/Class.java @@ -1090,10 +1090,12 @@ public final class Class ++pos; while (Character.isDigit(fullName.charAt(pos))) ++pos; + fullName = fullName.substring(pos); } - int packagePos = fullName.lastIndexOf(".", pos); + + int packagePos = fullName.lastIndexOf("."); if (packagePos == -1) - return fullName.substring(pos); + return fullName; else return fullName.substring(packagePos + 1); } diff --git a/libjava/testsuite/libjava.lang/PR35020.jar b/libjava/testsuite/libjava.lang/PR35020.jar new file mode 100644 index 00000000000..bedaed7ecdb Binary files /dev/null and b/libjava/testsuite/libjava.lang/PR35020.jar differ diff --git a/libjava/testsuite/libjava.lang/PR35020.java b/libjava/testsuite/libjava.lang/PR35020.java new file mode 100644 index 00000000000..1850da79683 --- /dev/null +++ b/libjava/testsuite/libjava.lang/PR35020.java @@ -0,0 +1,21 @@ +public class PR35020 +{ + class inner + { + } + public static void main(String[] args) + { + System.out.println(inner.class.getSimpleName()); + System.out.println(PR35020.class.getSimpleName()); + System.out.println(Class.class.getSimpleName()); + System.out.println((new int[7]).getClass().getSimpleName()); + System.out.println((new Object[1][1][1][1][1][1][1][1]).getClass().getSimpleName()); + System.out.println((new java.security.PrivilegedAction() + { + public Object run() { + return null; + } + }).getClass().getSimpleName()); + } +} + diff --git a/libjava/testsuite/libjava.lang/PR35020.out b/libjava/testsuite/libjava.lang/PR35020.out new file mode 100644 index 00000000000..73eb0c917fc --- /dev/null +++ b/libjava/testsuite/libjava.lang/PR35020.out @@ -0,0 +1,6 @@ +inner +PR35020 +Class +int[] +Object[][][][][][][][] +