From 9f8e4e845ba0240f599fd541c5cee10cf8654cc5 Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Thu, 22 May 2008 16:20:55 +0000 Subject: [PATCH] re PR libgcj/35020 (Class.getSimpleName() differs from Sun Java) 2008-05-22 Andrew Haley PR libgcj/35020 * java/lang/Class.java (getSimpleName): Import from GNU Classpath. From-SVN: r135771 --- libjava/ChangeLog | 5 +++ libjava/classpath/lib/java/lang/Class$1.class | Bin 677 -> 677 bytes libjava/classpath/lib/java/lang/Class.class | Bin 15647 -> 15581 bytes libjava/java/lang/Class.java | 29 ++++++++++-------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index e8cd46e8947..52061d2c1ed 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2008-05-22 Andrew Haley + + PR libgcj/35020 + * java/lang/Class.java (getSimpleName): Import from GNU Classpath. + 2008-05-20 David Daney PR libgcj/36252 diff --git a/libjava/classpath/lib/java/lang/Class$1.class b/libjava/classpath/lib/java/lang/Class$1.class index 51ef8849385cda3875ba35c8353cd59c40f3e8e8..09e3e86f9954b60f48813dff60c6349d9a59a6f1 100644 GIT binary patch delta 23 fcmZ3=x|DT;1`}iNWKAYV)`<)ptdl0^GnoMZPU;3L delta 23 ecmZ3=x|DT;1`}h)WKAYV)*c29*51kaOlAO1Sq2;c diff --git a/libjava/classpath/lib/java/lang/Class.class b/libjava/classpath/lib/java/lang/Class.class index ffe072f5337a6bcc931dad981f40f1c6cad76519..bdcfcfe83bda48e1ab9fce5acf4427d4f3df4cc3 100644 GIT binary patch delta 2161 zcmZuzX>e0j6#mYA_x7d9qg%R#CTR-=Y0^asv?bjJiqK-q;^<&eXNXL!(KKa9aRx@G zE{uN|arBK#(P8-`;}2)*Fq5{jBa6!7zFWb4!4<_7splmz$mpNkbMO7`x!?KDJ?CZH zhVk{okGodbK{RU67-bW3!m)YL{^5V6?Zk{np^x;Oc?U zT7!<$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UbcK%fRM9;BCa>YsrJ9bU?>6y+UYO zoG4ts8}ICg05WiaPhFfhA? zQ1MH#2;Nj*Uusw9&Vfun!M$yuw|8CY?zHvb!fE}eP9I@hqfZE7tF$WY_0lmqu46uZ zW=&R_?qhU9r+?F7>rCbEcyUUn)AW^ff7PGle+kuAsxn~ht#aqQ>|Gow1sNf1dZf zPCw8E>tHbMxkxh_{YVH|$Acl4E?_lOPu6(}r8!jw`g?jCf1S$iNT%-b3QtaTF<%$O z>|PwIbbG`Vx+oP3tYx9jDvv1Bg&(^KMO$}f`cplb?2YMNnkaXu91r?qYcf01eLel@ zJGf55(8WS3CHQ)>9huC|{#1X@&di3sbT*yo=c`1OPD3Kd!Y!`18fyaci|{MlHp8XS8MtPaTXE^z|9jh);&h!iEz@j>S+{3Y(J}=?#zj8hBPI`6x3!cH<_W}phQP`>0z70)jTL19&*p@BU{Dqj=KqXY@>|$C zN8|QNKa4>dLiaAn!NZjtWI$rBK$PHbc9>@klJR wPPH`~J1)WMbFHfjvf}NP28j;m<)eM%G$V */ 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); } /**