From: chiba Date: Tue, 2 Sep 2003 05:23:16 +0000 (+0000) Subject: implemented CtBehavior.setBody with $proceed. X-Git-Tag: rel_3_17_1_ga~567 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=efa5f73e7d7d3a1c247ef4db79bb867adee356c2;p=javassist.git implemented CtBehavior.setBody with $proceed. git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@41 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/src/main/javassist/CtBehavior.java b/src/main/javassist/CtBehavior.java index 54338a0a..636a8105 100644 --- a/src/main/javassist/CtBehavior.java +++ b/src/main/javassist/CtBehavior.java @@ -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 null, the substituted member + * body does nothing except returning zero or null. + * @param delegateObj the source text specifying the object + * that is called on by $proceed(). + * @param delegateMethod the name of the method + * that is called by $proceed(). + */ + 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() diff --git a/src/main/javassist/CtMethod.java b/src/main/javassist/CtMethod.java index 22796467..035a3b9e 100644 --- a/src/main/javassist/CtMethod.java +++ b/src/main/javassist/CtMethod.java @@ -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 null, the substituted method + * body does nothing except returning zero or null. + * @param delegateObj the source text specifying the object + * that is called on by $proceed(). + * @param delegateMethod the name of the method + * that is called by $proceed(). + */ + 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