[jboss-cvs] javassist SVN: r574 - in trunk: src/main/javassist and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 14 10:38:43 EDT 2010


Author: chiba
Date: 2010-09-14 10:38:43 -0400 (Tue, 14 Sep 2010)
New Revision: 574

Modified:
   trunk/Readme.html
   trunk/src/main/javassist/CtClass.java
   trunk/src/main/javassist/bytecode/AnnotationsAttribute.java
   trunk/src/main/javassist/bytecode/AttributeInfo.java
   trunk/src/main/javassist/bytecode/ClassFile.java
   trunk/src/main/javassist/bytecode/CodeAttribute.java
   trunk/src/main/javassist/bytecode/ParameterAnnotationsAttribute.java
   trunk/src/main/javassist/bytecode/SignatureAttribute.java
Log:
fixed JASSIST-128 and JASSIST-129

Modified: trunk/Readme.html
===================================================================
--- trunk/Readme.html	2010-09-12 12:59:04 UTC (rev 573)
+++ trunk/Readme.html	2010-09-14 14:38:43 UTC (rev 574)
@@ -284,7 +284,7 @@
 <p>-version 3.14
 
 <ul>
-	<li>JIRA JASSIST-130, 131, 132.
+	<li>JIRA JASSIST-128, 129, 130, 131, 132.
 </ul>
 
 <p>-version 3.13 on July 19, 2010

Modified: trunk/src/main/javassist/CtClass.java
===================================================================
--- trunk/src/main/javassist/CtClass.java	2010-09-12 12:59:04 UTC (rev 573)
+++ trunk/src/main/javassist/CtClass.java	2010-09-14 14:38:43 UTC (rev 574)
@@ -428,7 +428,7 @@
 
                 public void fix(String name) {}
             };
-            cf.renameClass(cm);
+            cf.getRefClasses(cm);
             return cm.values();
         }
         else

Modified: trunk/src/main/javassist/bytecode/AnnotationsAttribute.java
===================================================================
--- trunk/src/main/javassist/bytecode/AnnotationsAttribute.java	2010-09-12 12:59:04 UTC (rev 573)
+++ trunk/src/main/javassist/bytecode/AnnotationsAttribute.java	2010-09-14 14:38:43 UTC (rev 574)
@@ -285,6 +285,8 @@
         }
     }
 
+    void getRefClasses(Map classnames) { renameClass(classnames); }
+
     /**
      * Returns a string representation of this object.
      */

Modified: trunk/src/main/javassist/bytecode/AttributeInfo.java
===================================================================
--- trunk/src/main/javassist/bytecode/AttributeInfo.java	2010-09-12 12:59:04 UTC (rev 573)
+++ trunk/src/main/javassist/bytecode/AttributeInfo.java	2010-09-14 14:38:43 UTC (rev 574)
@@ -251,8 +251,9 @@
 
     /* The following two methods are used to implement
      * ClassFile.renameClass().
-     * Only CodeAttribute, LocalVariableAttribute, and
-     * AnnotationsAttribute override these methods.
+     * Only CodeAttribute, LocalVariableAttribute,
+     * AnnotationsAttribute, and SignatureAttribute
+     * override these methods.
      */
     void renameClass(String oldname, String newname) {}
     void renameClass(Map classnames) {}
@@ -272,4 +273,14 @@
             ai.renameClass(classnames);
         }
     }
+
+    void getRefClasses(Map classnames) {}
+
+    static void getRefClasses(List attributes, Map classnames) {
+        Iterator iterator = attributes.iterator();
+        while (iterator.hasNext()) {
+            AttributeInfo ai = (AttributeInfo)iterator.next();
+            ai.getRefClasses(classnames);
+        }
+    }
 }

Modified: trunk/src/main/javassist/bytecode/ClassFile.java
===================================================================
--- trunk/src/main/javassist/bytecode/ClassFile.java	2010-09-12 12:59:04 UTC (rev 573)
+++ trunk/src/main/javassist/bytecode/ClassFile.java	2010-09-14 14:38:43 UTC (rev 574)
@@ -466,6 +466,33 @@
     }
 
     /**
+     * Internal-use only.
+     * <code>CtClass.getRefClasses()</code> calls this method. 
+     */
+    public final void getRefClasses(Map classnames) {
+        constPool.renameClass(classnames);
+
+        AttributeInfo.getRefClasses(attributes, classnames);
+        ArrayList list = methods;
+        int n = list.size();
+        for (int i = 0; i < n; ++i) {
+            MethodInfo minfo = (MethodInfo)list.get(i);
+            String desc = minfo.getDescriptor();
+            Descriptor.rename(desc, classnames);
+            AttributeInfo.getRefClasses(minfo.getAttributes(), classnames);
+        }
+
+        list = fields;
+        n = list.size();
+        for (int i = 0; i < n; ++i) {
+            FieldInfo finfo = (FieldInfo)list.get(i);
+            String desc = finfo.getDescriptor();
+            Descriptor.rename(desc, classnames);
+            AttributeInfo.getRefClasses(finfo.getAttributes(), classnames);
+        }
+    }
+
+    /**
      * Returns the names of the interfaces implemented by the class.
      * The returned array is read only.
      */

Modified: trunk/src/main/javassist/bytecode/CodeAttribute.java
===================================================================
--- trunk/src/main/javassist/bytecode/CodeAttribute.java	2010-09-12 12:59:04 UTC (rev 573)
+++ trunk/src/main/javassist/bytecode/CodeAttribute.java	2010-09-14 14:38:43 UTC (rev 574)
@@ -200,6 +200,10 @@
         AttributeInfo.renameClass(attributes, classnames);
     }
 
+    void getRefClasses(Map classnames) {
+        AttributeInfo.getRefClasses(attributes, classnames);
+    }
+
     /**
      * Returns the name of the class declaring the method including
      * this code attribute.

Modified: trunk/src/main/javassist/bytecode/ParameterAnnotationsAttribute.java
===================================================================
--- trunk/src/main/javassist/bytecode/ParameterAnnotationsAttribute.java	2010-09-12 12:59:04 UTC (rev 573)
+++ trunk/src/main/javassist/bytecode/ParameterAnnotationsAttribute.java	2010-09-14 14:38:43 UTC (rev 574)
@@ -186,6 +186,8 @@
         }
     }
 
+    void getRefClasses(Map classnames) { renameClass(classnames); }
+
     /**
      * Returns a string representation of this object.
      */

Modified: trunk/src/main/javassist/bytecode/SignatureAttribute.java
===================================================================
--- trunk/src/main/javassist/bytecode/SignatureAttribute.java	2010-09-12 12:59:04 UTC (rev 573)
+++ trunk/src/main/javassist/bytecode/SignatureAttribute.java	2010-09-14 14:38:43 UTC (rev 574)
@@ -96,54 +96,16 @@
     }
 
     static String renameClass(String desc, String oldname, String newname) {
-        if (desc.indexOf(oldname) < 0)
-            return desc;
-
-        StringBuffer newdesc = new StringBuffer();
-        int head = 0;
-        int i = 0;
-        for (;;) {
-            int j = desc.indexOf('L', i);
-            if (j < 0)
-                break;
-
-            int k = j;
-            int p = 0;
-            char c;
-            boolean match = true;
-            try {
-                int len = oldname.length();
-                while (isNamePart(c = desc.charAt(++k)))
-                    if (p >= len || c != oldname.charAt(p++))
-                        match = false;
-            }
-            catch (IndexOutOfBoundsException e) { break; }
-            i = k + 1;
-            if (match && p == oldname.length()) {
-                newdesc.append(desc.substring(head, j));
-                newdesc.append('L');
-                newdesc.append(newname);
-                newdesc.append(c);
-                head = i;
-            }
-        }
-
-        if (head == 0)
-            return desc;
-        else {
-            int len = desc.length();
-            if (head < len)
-                newdesc.append(desc.substring(head, len));
-
-            return newdesc.toString();
-        }
+        Map map = new java.util.HashMap();
+        map.put(oldname, newname);
+        return renameClass(desc, map);
     }
 
     static String renameClass(String desc, Map map) {
         if (map == null)
             return desc;
 
-        StringBuffer newdesc = new StringBuffer();
+        StringBuilder newdesc = new StringBuilder();
         int head = 0;
         int i = 0;
         for (;;) {
@@ -151,12 +113,19 @@
             if (j < 0)
                 break;
 
-            StringBuffer nameBuf = new StringBuffer();
+            StringBuilder nameBuf = new StringBuilder();
             int k = j;
             char c;
             try {
-                while (isNamePart(c = desc.charAt(++k)))
+                while ((c = desc.charAt(++k)) != ';') {
                     nameBuf.append(c);
+                    if (c == '<') {
+                        while ((c = desc.charAt(++k)) != '>')
+                            nameBuf.append(c);
+
+                        nameBuf.append(c);
+                    }
+                }
             }
             catch (IndexOutOfBoundsException e) { break; }
             i = k + 1;



More information about the jboss-cvs-commits mailing list