]> source.dussan.org Git - javassist.git/commitdiff
implemented CtBehavior.setBody with $proceed.
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Tue, 2 Sep 2003 05:23:16 +0000 (05:23 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Tue, 2 Sep 2003 05:23:16 +0000 (05:23 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@41 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/CtBehavior.java
src/main/javassist/CtMethod.java

index 54338a0a5fed75994129b766081ca5fb4da63441..636a81051b0f44249dfb389957193d989543e1f0 100644 (file)
@@ -158,9 +158,31 @@ public abstract class CtBehavior extends CtMember {
      *                  body does nothing except returning zero or null.
      */
     public void setBody(String src) throws CannotCompileException {
+        setBody(src, null, null);
+    }
+
+    /**
+     * Sets a member body.
+     *
+     * @param src       the source code representing the member body.
+     *                  It must be a single statement or block.
+     *                  If it is <code>null</code>, the substituted member
+     *                  body does nothing except returning zero or null.
+     * @param delegateObj       the source text specifying the object
+     *                          that is called on by <code>$proceed()</code>.
+     * @param delegateMethod    the name of the method
+     *                          that is called by <code>$proceed()</code>.
+     */
+    public void setBody(String src,
+                        String delegateObj, String delegateMethod)
+        throws CannotCompileException
+    {
         declaringClass.checkModify();
         try {
             Javac jv = new Javac(declaringClass);
+            if (delegateMethod != null)
+                jv.recordProceed(delegateObj, delegateMethod);
+
             Bytecode b = jv.compileBody(this, src);
             methodInfo.setCodeAttribute(b.toCodeAttribute());
             methodInfo.setAccessFlags(methodInfo.getAccessFlags()
index 227964675b16b2b20564b2d44a394109b79cf347..035a3b9e9b121ea1e58145962b35e1b174530a07 100644 (file)
@@ -311,6 +311,25 @@ public final class CtMethod extends CtBehavior {
         super.setBody(src);
     }
 
+    /**
+     * Sets a method body.
+     *
+     * @param src       the source code representing the method body.
+     *                  It must be a single statement or block.
+     *                  If it is <code>null</code>, the substituted method
+     *                  body does nothing except returning zero or null.
+     * @param delegateObj       the source text specifying the object
+     *                          that is called on by <code>$proceed()</code>.
+     * @param delegateMethod    the name of the method
+     *                          that is called by <code>$proceed()</code>.
+     */
+    public void setBody(String src,
+                        String delegateObj, String delegateMethod)
+        throws CannotCompileException
+    {
+        super.setBody(src, delegateObj, delegateMethod);
+    }
+
     /**
      * Copies a method body from another method.
      * If this method is abstract, the abstract modifier is removed