re PR libgcj/35020 (Class.getSimpleName() differs from Sun Java)
authorAndrew Haley <aph@redhat.com>
Fri, 23 May 2008 13:04:18 +0000 (13:04 +0000)
committerAndrew Haley <aph@gcc.gnu.org>
Fri, 23 May 2008 13:04:18 +0000 (13:04 +0000)
2008-05-22  Andrew Haley  <aph@redhat.com>

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

libjava/ChangeLog
libjava/classpath/lib/java/lang/Class$1.class
libjava/classpath/lib/java/lang/Class.class
libjava/java/lang/Class.java
libjava/testsuite/libjava.lang/PR35020.jar [new file with mode: 0644]
libjava/testsuite/libjava.lang/PR35020.java [new file with mode: 0644]
libjava/testsuite/libjava.lang/PR35020.out [new file with mode: 0644]

index 52061d2c1edaa7cd82ab33a88d31895a42fce69b..37f12e2c8927cbb248c5f3bb4a26cb265b1edd1d 100644 (file)
@@ -1,3 +1,11 @@
+2008-05-22  Andrew Haley  <aph@redhat.com>
+
+       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  <aph@redhat.com>
 
        PR libgcj/35020
index 09e3e86f9954b60f48813dff60c6349d9a59a6f1..9c4806c02337392a561302e5da00c839f9d02193 100644 (file)
Binary files a/libjava/classpath/lib/java/lang/Class$1.class and b/libjava/classpath/lib/java/lang/Class$1.class differ
index bdcfcfe83bda48e1ab9fce5acf4427d4f3df4cc3..ce854558e542fb0e5114f54b01889a3be01df88d 100644 (file)
Binary files a/libjava/classpath/lib/java/lang/Class.class and b/libjava/classpath/lib/java/lang/Class.class differ
index d59e83ea4ec336c19f96d4c79090eb7ac1ee4dc5..868e370b819da70f334f261f1c59791175a2f858 100644 (file)
@@ -1090,10 +1090,12 @@ public final class Class<T>
        ++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 (file)
index 0000000..bedaed7
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 (file)
index 0000000..1850da7
--- /dev/null
@@ -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 (file)
index 0000000..73eb0c9
--- /dev/null
@@ -0,0 +1,6 @@
+inner
+PR35020
+Class
+int[]
+Object[][][][][][][][]
+