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


Java MethodInfo.getAccessFlags方法代碼示例

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


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

示例1: firstFrame

import scouter.javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
private Frame firstFrame(MethodInfo method, int maxLocals, int maxStack) {
    int pos = 0;

    Frame first = new Frame(maxLocals, maxStack);
    if ((method.getAccessFlags() & AccessFlag.STATIC) == 0) {
        first.setLocal(pos++, Type.get(clazz));
    }

    CtClass[] parameters;
    try {
        parameters = Descriptor.getParameterTypes(method.getDescriptor(), clazz.getClassPool());
    } catch (NotFoundException e) {
        throw new RuntimeException(e);
    }

    for (int i = 0; i < parameters.length; i++) {
        Type type = zeroExtend(Type.get(parameters[i]));
        first.setLocal(pos++, type);
        if (type.getSize() == 2)
            first.setLocal(pos++, Type.TOP);
    }

    return first;
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:25,代碼來源:Analyzer.java

示例2: makeBlocks

import scouter.javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
/**
 * Divides the method body into basic blocks.
 * The type information of the first block is initialized.
 *
 * @param optimize       if it is true and the method does not include
 *                      branches, this method returns null.
 */
public static TypedBlock[] makeBlocks(MethodInfo minfo, CodeAttribute ca,
                                      boolean optimize)
    throws BadBytecode
{
    TypedBlock[] blocks = (TypedBlock[])new Maker().make(minfo);
    if (optimize && blocks.length < 2)
        if (blocks.length == 0 || blocks[0].incoming == 0)
            return null;

    ConstPool pool = minfo.getConstPool();
    boolean isStatic = (minfo.getAccessFlags() & AccessFlag.STATIC) != 0;
    blocks[0].initFirstBlock(ca.getMaxStack(), ca.getMaxLocals(),
                             pool.getClassName(), minfo.getDescriptor(),
                             isStatic, minfo.isConstructor());
    return blocks;
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:24,代碼來源:TypedBlock.java

示例3: addBodyMethod

import scouter.javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
private static String addBodyMethod(CtClassType clazz,
                                    ClassFile classfile,
                                    CtMethod src)
    throws BadBytecode, CannotCompileException
{
    Hashtable bodies = clazz.getHiddenMethods();
    String bodyname = (String)bodies.get(src);
    if (bodyname == null) {
        do {
            bodyname = addedWrappedMethod + clazz.getUniqueNumber();
        } while (classfile.getMethod(bodyname) != null);
        ClassMap map = new ClassMap();
        map.put(src.getDeclaringClass().getName(), clazz.getName());
        MethodInfo body = new MethodInfo(classfile.getConstPool(),
                                         bodyname, src.getMethodInfo2(),
                                         map);
        int acc = body.getAccessFlags();
        body.setAccessFlags(AccessFlag.setPrivate(acc));
        body.addAttribute(new SyntheticAttribute(classfile.getConstPool()));
        // a stack map is copied.  rebuilding it is not needed.
        classfile.addMethod(body);
        bodies.put(src, bodyname);
        CtMember.Cache cache = clazz.hasMemberCache();
        if (cache != null)
            cache.addMethod(new CtMethod(body, clazz));
    }

    return bodyname;
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:30,代碼來源:CtNewWrappedMethod.java

示例4: atMethodCallCore2

import scouter.javassist.bytecode.MethodInfo; //導入方法依賴的package包/類
private void atMethodCallCore2(CtClass targetClass, String mname,
                               boolean isStatic, boolean isSpecial,
                               int aload0pos,
                               MemberResolver.Method found)
    throws CompileError
{
    CtClass declClass = found.declaring;
    MethodInfo minfo = found.info;
    String desc = minfo.getDescriptor();
    int acc = minfo.getAccessFlags();

    if (mname.equals(MethodInfo.nameInit)) {
        isSpecial = true;
        if (declClass != targetClass)
            throw new CompileError("no such constructor: " + targetClass.getName());

        if (declClass != thisClass && AccessFlag.isPrivate(acc)) {
            desc = getAccessibleConstructor(desc, declClass, minfo);
            bytecode.addOpcode(Opcode.ACONST_NULL); // the last parameter
        }
    }
    else if (AccessFlag.isPrivate(acc))
        if (declClass == thisClass)
            isSpecial = true;
        else {
            isSpecial = false;
            isStatic = true;
            String origDesc = desc;
            if ((acc & AccessFlag.STATIC) == 0)
                desc = Descriptor.insertParameter(declClass.getName(),
                                                  origDesc);

            acc = AccessFlag.setPackage(acc) | AccessFlag.STATIC;
            mname = getAccessiblePrivate(mname, origDesc, desc,
                                         minfo, declClass);
        }

    boolean popTarget = false;
    if ((acc & AccessFlag.STATIC) != 0) {
        if (!isStatic) {
            /* this method is static but the target object is
               on stack.  It must be popped out.  If aload0pos >= 0,
               then the target object was pushed by aload_0.  It is
               overwritten by NOP.
            */
            isStatic = true;
            if (aload0pos >= 0)
                bytecode.write(aload0pos, NOP);
            else
                popTarget = true;
        }

        bytecode.addInvokestatic(declClass, mname, desc);
    }
    else if (isSpecial)    // if (isSpecial && notStatic(acc))
        bytecode.addInvokespecial(targetClass, mname, desc);
    else {
        if (!Modifier.isPublic(declClass.getModifiers())
            || declClass.isInterface() != targetClass.isInterface())
            declClass = targetClass;

        if (declClass.isInterface()) {
            int nargs = Descriptor.paramSize(desc) + 1;
            bytecode.addInvokeinterface(declClass, mname, desc, nargs);
        }
        else
            if (isStatic)
                throw new CompileError(mname + " is not static");
            else
                bytecode.addInvokevirtual(declClass, mname, desc);
    }

    setReturnType(desc, isStatic, popTarget);
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:75,代碼來源:MemberCodeGen.java


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