classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [generics] Modifier.toString()


From: Mark Wielaard
Subject: [cp-patches] [generics] Modifier.toString()
Date: Fri, 13 Jan 2006 14:24:30 +0100

Hi,

there is a somewhat unfortunate situation on the generics branch with
Modifier.toString() which takes a StringBuffer on the trunk, but a
StringBuilder on the branch. Officially this isn't part of the Vm
interface, but there are runtimes that override the Method, Constructor
and Field classes and that do use this package private method.

To make them work again for now I just duplicated this method to work
with either a Stringbuffer or a StringBuilder.

2005-01-13  Mark Wielaard  <address@hidden>

        * java/lang/reflect/Modifier.java (toString(int, StringBuffer)):
        Duplicate of toString(int, StringBuilder).

Committed to the branch.

Cheers,

Mark
Index: java/lang/reflect/Modifier.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/reflect/Modifier.java,v
retrieving revision 1.8.2.3
diff -u -r1.8.2.3 Modifier.java
--- java/lang/reflect/Modifier.java     2 Aug 2005 20:12:23 -0000       1.8.2.3
+++ java/lang/reflect/Modifier.java     13 Jan 2006 13:13:44 -0000
@@ -292,12 +292,54 @@
   }
 
   /**
+   * Package helper method that can take a StringBuilder.
+   * @param mod the modifier
+   * @param r the StringBuilder to which the String representation is appended
+   * @return r, with information appended
+   */
+  static StringBuilder toString(int mod, StringBuilder r)
+  {
+    if (isPublic(mod))
+      r.append("public ");
+    if (isProtected(mod))
+      r.append("protected ");
+    if (isPrivate(mod))
+      r.append("private ");
+    if (isAbstract(mod))
+      r.append("abstract ");
+    if (isStatic(mod))
+      r.append("static ");
+    if (isFinal(mod))
+      r.append("final ");
+    if (isTransient(mod))
+      r.append("transient ");
+    if (isVolatile(mod))
+      r.append("volatile ");
+    if (isSynchronized(mod))
+      r.append("synchronized ");
+    if (isNative(mod))
+      r.append("native ");
+    if (isStrict(mod))
+      r.append("strictfp ");
+    if (isInterface(mod))
+      r.append("interface ");
+    
+    // Trim trailing space.
+    if ((mod & ALL_FLAGS) != 0)
+      r.setLength(r.length() - 1);
+    return r;
+  }
+
+  /**
    * Package helper method that can take a StringBuffer.
+   * This is indeed a duplicate of the method that takes a StringBuilder
+   * since some runtimes override the given Method, Constructor and Field
+   * classes that and use a StringBuffer.
    * @param mod the modifier
    * @param r the StringBuffer to which the String representation is appended
    * @return r, with information appended
    */
-  static StringBuilder toString(int mod, StringBuilder r)
+  static StringBuffer toString(int mod, StringBuffer r)
   {
     if (isPublic(mod))
       r.append("public ");

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]