本文整理汇总了Java中javassist.compiler.Javac.recordProceed方法的典型用法代码示例。如果您正苦于以下问题:Java Javac.recordProceed方法的具体用法?Java Javac.recordProceed怎么用?Java Javac.recordProceed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javassist.compiler.Javac
的用法示例。
在下文中一共展示了Javac.recordProceed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: make
import javassist.compiler.Javac; //导入方法依赖的package包/类
/**
* Compiles the given source code and creates a method.
* The source code must include not only the method body
* but the whole declaration, for example,
*
* <ul><pre>"public Object id(Object obj) { return obj; }"</pre></ul>
*
* <p>If the source code includes <code>$proceed()</code>, then
* it is compiled into a method call on the specified object.
*
* @param src the source text.
* @param declaring the class to which the created method is added.
* @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 static CtMethod make(String src, CtClass declaring,
String delegateObj, String delegateMethod)
throws CannotCompileException
{
Javac compiler = new Javac(declaring);
try {
if (delegateMethod != null)
compiler.recordProceed(delegateObj, delegateMethod);
CtMember obj = compiler.compile(src);
if (obj instanceof CtMethod)
return (CtMethod)obj;
}
catch (CompileError e) {
throw new CannotCompileException(e);
}
throw new CannotCompileException("not a method");
}