summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2006-03-25 01:46:10 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2006-03-25 01:46:10 +0000
commit6e5998c74acb9f802a6429f9647e540d07ce53d5 (patch)
tree26385df35f2fa67b6a5b2600f617ad515732fdfe /gnu
parentd0d52d2affe815851d6e7f83735c66ea889431be (diff)
downloadclasspath-6e5998c74acb9f802a6429f9647e540d07ce53d5.tar.gz
2006-03-05 Robert Schuster <robertschuster@fsfe.org>
* javax/swing/text/GapContent.java: (insertString): Throw exception when argument is below zero. 2006-03-05 David Gilbert <david.gilbert@object-refinery.com> * javax/swing/filechooser/FileFilter.java: (accept): Fixed API doc tag, (getDescription): Likewise, * javax/swing/filechooser/FileView.java: (isTraversable): Fixed API doc tag. 2006-03-05 David Gilbert <david.gilbert@object-refinery.com> * javax/swing/colorchooser/ColorSelectionModel.java: Reformatted and added API docs all over. 2006-03-05 David Gilbert <david.gilbert@object-refinery.com> * javax/swing/plaf/ComboBoxUI.java: Fixed typo in class description, and corrected a bad API doc tag. 2006-03-05 David Gilbert <david.gilbert@object-refinery.com> * javax/swing/undo/StateEditable.java (restoreState): Fixed bad API doc tag, * javax/swing/undo/UndoableEdit.java: Copied API doc comments from AbstractUndoableEdit.java, * javax/swing/undo/UndoableEditSupport.java (createCompoundEdit): Fixed bad API doc tag, * javax/swing/undo/UndoManager.java (editToBeUndone): Fixed bad API doc tag, (editToBeRedone): Likewise. 2006-03-05 David Gilbert <david.gilbert@object-refinery.com> * javax/swing/DefaultFocusManager.java: Fixed bad API doc tags, * javax/swing/FocusManager.java: Likewise. 2006-03-05 David Gilbert <david.gilbert@object-refinery.com> * javax/swing/plaf/metal/MetalComboBoxButton.java (MetalComboBoxButton(JComboBox, Icon, boolean, CellRendererPane, JList)): Fixed API doc tag, * javax/swing/plaf/metal/MetalInternalFrameTitlePane (createLayout): Fixed API doc warning. 2006-03-05 Tom Tromey <tromey@redhat.com> * vm/reference/java/lang/reflect/Constructor.java (toString): Use ClassHelper.getUserName. * vm/reference/java/lang/reflect/Method.java (toString): Use ClassHelper.getUserName. (getUserTypeName): Removed. * gnu/java/lang/ClassHelper.java (getUserName): New method. * vm/reference/java/lang/reflect/Field.java (toString): Use ClassHelper.getUserName. 2006-03-05 Olivier Jolly <olivier.jolly@pcedev.com> Fixes PR 22813 * java/net/URLClassLoader.java (FileURLLoader.getResource): Allows directories as valid resources.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/java/lang/ClassHelper.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/gnu/java/lang/ClassHelper.java b/gnu/java/lang/ClassHelper.java
index 14c8a39c4..49dce21ea 100644
--- a/gnu/java/lang/ClassHelper.java
+++ b/gnu/java/lang/ClassHelper.java
@@ -81,6 +81,34 @@ public class ClassHelper
return name.substring(lastInd + 1);
}
+ /**
+ * Return the name of the class as written by the user.
+ * This is used by the various reflection toString methods.
+ * It differs from {@link Class#getName()} in that it prints
+ * arrays with trailing "[]"s. Note that it does not treat
+ * member classes specially, so a dollar sign may still appear
+ * in the result. This is intentional.
+ * @param klass the class
+ * @return a pretty form of the class' name
+ */
+ public static String getUserName(Class klass)
+ {
+ int arrayCount = 0;
+ while (klass.isArray())
+ {
+ ++arrayCount;
+ klass = klass.getComponentType();
+ }
+ String name = klass.getName();
+ if (arrayCount == 0)
+ return name;
+ StringBuilder b = new StringBuilder(name.length() + 2 * arrayCount);
+ b.append(name);
+ for (int i = 0; i < arrayCount; ++i)
+ b.append("[]");
+ return b.toString();
+ }
+
/** Cache of methods found in getAllMethods(). */
private static Map allMethods = new HashMap();