diff options
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/lang/Class.java | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/libjava/java/lang/Class.java b/libjava/java/lang/Class.java index 868e370..a4e8ee5 100644 --- a/libjava/java/lang/Class.java +++ b/libjava/java/lang/Class.java @@ -1078,26 +1078,24 @@ public final class Class<T> if (isAnonymousClass()) return ""; if (isArray()) - { - return getComponentType().getSimpleName() + "[]"; - } + 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); - } + Class enclosingClass = getEnclosingClass(); + if (enclosingClass == null) + // It's a top level class. + return fullName.substring(fullName.lastIndexOf(".") + 1); - int packagePos = fullName.lastIndexOf("."); - if (packagePos == -1) - return fullName; - else - return fullName.substring(packagePos + 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; } /** |