]> source.dussan.org Git - javassist.git/commitdiff
fixed a bug of CtClassType#removeMehtod() etc.
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 18 Jun 2007 23:51:07 +0000 (23:51 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 18 Jun 2007 23:51:07 +0000 (23:51 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@390 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/CtClass.java
src/main/javassist/CtMember.java
src/main/javassist/CtMethod.java

index a757ef0e75bbf4f3d067a006686dabd991a05114..48a8ca21b6b302e47fe72335d60a1f07d2d32be5 100644 (file)
@@ -560,6 +560,9 @@ public abstract class CtClass {
      * to <code>addInterface()</code>; it appends <code>clazz</code> to
      * the list of the super interfaces extended by that interface.
      * Note that an interface can extend multiple super interfaces.
+     *
+     * @see #replaceClassName(String, String)
+     * @see #replaceClassName(ClassMap)
      */
     public void setSuperclass(CtClass clazz) throws CannotCompileException {
         checkModify();
index 2fde6cee3079b517ea0d46268062cb9d1e3a090e..16ccc536aa750803214fac175d431dfc7dca9f1b 100644 (file)
@@ -106,9 +106,11 @@ public abstract class CtMember {
                     m.next = node.next;
                     if (node == methodTail)
                         methodTail = m;
-                    else if (node == consTail)
+
+                    if (node == consTail)
                         consTail = m;
-                    else if (node == fieldTail)
+
+                    if (node == fieldTail)
                         fieldTail = m;
 
                     break;
index 158f21af96b471cd6b5335856980e956d75991e7..3ed6aa77e6d4428084aa9555497556493b7e1a21 100644 (file)
@@ -125,6 +125,24 @@ public final class CtMethod extends CtBehavior {
         return CtNewMethod.make(src, declaring);
     }
 
+    /**
+     * Creates a method from a <code>MethodInfo</code> object.
+     *
+     * @param declaring     the class declaring the method.
+     * @throws CannotCompileException       if the the <code>MethodInfo</code>
+     *          object and the declaring class have different
+     *          <code>ConstPool</code> objects
+     * @since 3.6
+     */
+    public static CtMethod make(MethodInfo minfo, CtClass declaring)
+        throws CannotCompileException
+    {
+        if (declaring.getClassFile2().getConstPool() != minfo.getConstPool())
+            throw new CannotCompileException("bad declaring class");
+
+        return new CtMethod(minfo, declaring);
+    }
+
     /**
      * Returns a hash code value for the method.
      * If two methods have the same name and signature, then