當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodInfo.setExceptionsAttribute方法代碼示例

本文整理匯總了Java中scouter.javassist.bytecode.MethodInfo.setExceptionsAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodInfo.setExceptionsAttribute方法的具體用法?Java MethodInfo.setExceptionsAttribute怎麽用?Java MethodInfo.setExceptionsAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scouter.javassist.bytecode.MethodInfo的用法示例。


在下文中一共展示了MethodInfo.setExceptionsAttribute方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: makeWriteReplace

import scouter.javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
private static MethodInfo makeWriteReplace(ConstPool cp) {
    MethodInfo minfo = new MethodInfo(cp, "writeReplace", "()Ljava/lang/Object;");
    String[] list = new String[1];
    list[0] = "java.io.ObjectStreamException";
    ExceptionsAttribute ea = new ExceptionsAttribute(cp);
    ea.setExceptions(list);
    minfo.setExceptionsAttribute(ea);
    Bytecode code = new Bytecode(cp, 0, 1);
    code.addAload(0);
    code.addInvokestatic("RuntimeSupport",
                         "makeSerializedProxy",
                         "(Ljava/lang/Object;)Ljavassist/util/proxy/SerializedProxy;");
    code.addOpcode(Opcode.ARETURN);
    minfo.setCodeAttribute(code.toCodeAttribute());
    return minfo;
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:17,代碼來源:ProxyFactory.java

示例2: delegator0

import scouter.javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
private static CtMethod delegator0(CtMethod delegate, CtClass declaring)
    throws CannotCompileException, NotFoundException
{
    MethodInfo deleInfo = delegate.getMethodInfo2();
    String methodName = deleInfo.getName();
    String desc = deleInfo.getDescriptor();
    ConstPool cp = declaring.getClassFile2().getConstPool();
    MethodInfo minfo = new MethodInfo(cp, methodName, desc);
    minfo.setAccessFlags(deleInfo.getAccessFlags());

    ExceptionsAttribute eattr = deleInfo.getExceptionsAttribute();
    if (eattr != null)
        minfo.setExceptionsAttribute(
                            (ExceptionsAttribute)eattr.copy(cp, null));

    Bytecode code = new Bytecode(cp, 0, 0);
    boolean isStatic = Modifier.isStatic(delegate.getModifiers());
    CtClass deleClass = delegate.getDeclaringClass();
    CtClass[] params = delegate.getParameterTypes();
    int s;
    if (isStatic) {
        s = code.addLoadParameters(params, 0);
        code.addInvokestatic(deleClass, methodName, desc);
    }
    else {
        code.addLoad(0, deleClass);
        s = code.addLoadParameters(params, 1);
        code.addInvokespecial(deleClass, methodName, desc);
    }

    code.addReturn(delegate.getReturnType());
    code.setMaxLocals(++s);
    code.setMaxStack(s < 2 ? 2 : s); // for a 2-word return value
    minfo.setCodeAttribute(code.toCodeAttribute());
    // a stack map is not needed. 
    return new CtMethod(minfo, declaring);
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:38,代碼來源:CtNewMethod.java

示例3: setThrows

import scouter.javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
private static void setThrows(MethodInfo minfo, ConstPool cp,
                              Class[] exceptions) {
    if (exceptions.length == 0)
        return;

    String[] list = new String[exceptions.length];
    for (int i = 0; i < exceptions.length; i++)
        list[i] = exceptions[i].getName();

    ExceptionsAttribute ea = new ExceptionsAttribute(cp);
    ea.setExceptions(list);
    minfo.setExceptionsAttribute(ea);
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:14,代碼來源:ProxyFactory.java


注:本文中的scouter.javassist.bytecode.MethodInfo.setExceptionsAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。