当前位置: 首页>>代码示例>>Java>>正文


Java Javac.recordProceed方法代码示例

本文整理汇总了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");
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:37,代码来源:CtNewMethod.java


注:本文中的javassist.compiler.Javac.recordProceed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。