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


Java ConstPool.addClassInfo方法代码示例

本文整理汇总了Java中scouter.javassist.bytecode.ConstPool.addClassInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ConstPool.addClassInfo方法的具体用法?Java ConstPool.addClassInfo怎么用?Java ConstPool.addClassInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scouter.javassist.bytecode.ConstPool的用法示例。


在下文中一共展示了ConstPool.addClassInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: match

import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
protected int match(int c, int pos, CodeIterator iterator,
                    int typedesc, ConstPool cp) throws BadBytecode
{
    if (newIndex == 0) {
        int nt = cp.addNameAndTypeInfo(cp.addUtf8Info(newMethodname),
                                       typedesc);
        int ci = cp.addClassInfo(newClassname);
        if (c == INVOKEINTERFACE)
            newIndex = cp.addInterfaceMethodrefInfo(ci, nt);
        else {
            if (newMethodIsPrivate && c == INVOKEVIRTUAL)
                iterator.writeByte(INVOKESPECIAL, pos);

            newIndex = cp.addMethodrefInfo(ci, nt);
        }

        constPool = cp;
    }

    iterator.write16bit(newIndex, pos + 1);
    return pos;
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:23,代码来源:TransformCall.java

示例2: match

import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
protected int match(int c, int pos, CodeIterator iterator,
                    int typedesc, ConstPool cp) throws BadBytecode
{
    if (newIndex == 0) {
        String desc = Descriptor.ofParameters(parameterTypes) + 'V';
        desc = Descriptor.insertParameter(classname, desc);
        int nt = cp.addNameAndTypeInfo(newMethodname, desc);
        int ci = cp.addClassInfo(newClassname);
        newIndex = cp.addMethodrefInfo(ci, nt);
        constPool = cp;
    }

    if (saveCode == null)
        makeCode(parameterTypes, cp);

    return match2(pos, iterator);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:18,代码来源:TransformBefore.java

示例3: transform

import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
/**
 * Modifies a sequence of
 *    NEW classname
 *    DUP
 *    ...
 *    INVOKESPECIAL classname:method
 */
public int transform(CtClass clazz, int pos, CodeIterator iterator,
                     ConstPool cp) throws CannotCompileException
{
    int index;
    int c = iterator.byteAt(pos);
    if (c == NEW) {
        index = iterator.u16bitAt(pos + 1);
        if (cp.getClassInfo(index).equals(classname)) {
            if (iterator.byteAt(pos + 3) != DUP)
                throw new CannotCompileException(
                            "NEW followed by no DUP was found");

            if (newClassIndex == 0)
                newClassIndex = cp.addClassInfo(newClassName);

            iterator.write16bit(newClassIndex, pos + 1);
            ++nested;
        }
    }
    else if (c == INVOKESPECIAL) {
        index = iterator.u16bitAt(pos + 1);
        int typedesc = cp.isConstructor(classname, index);
        if (typedesc != 0 && nested > 0) {
            int nt = cp.getMethodrefNameAndType(index);
            if (newMethodNTIndex != nt) {
                newMethodNTIndex = nt;
                newMethodIndex = cp.addMethodrefInfo(newClassIndex, nt);
            }

            iterator.write16bit(newMethodIndex, pos + 1);
            --nested;
        }
    }

    return pos;
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:44,代码来源:TransformNewClass.java

示例4: transform

import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
public int transform(CtClass tclazz, int pos, CodeIterator iterator,
                     ConstPool cp) throws BadBytecode
{
    int c = iterator.byteAt(pos);
    if (c == GETFIELD || c == GETSTATIC) {
        int index = iterator.u16bitAt(pos + 1);
        String typedesc = isField(tclazz.getClassPool(), cp,
                            fieldClass, fieldname, isPrivate, index);
        if (typedesc != null) {
            if (c == GETSTATIC) {
                iterator.move(pos);
                pos = iterator.insertGap(1); // insertGap() may insert 4 bytes.
                iterator.writeByte(ACONST_NULL, pos);
                pos = iterator.next();
            }

            String type = "(Ljava/lang/Object;)" + typedesc;
            int mi = cp.addClassInfo(methodClassname);
            int methodref = cp.addMethodrefInfo(mi, methodName, type);
            iterator.writeByte(INVOKESTATIC, pos);
            iterator.write16bit(methodref, pos + 1);
            return pos;
        }
    }

    return pos;
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:28,代码来源:TransformReadField.java

示例5: replace

import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
private int replace(ConstPool cp, CodeIterator iterator, int pos,
        int opcode, String signature) throws BadBytecode {
    String castType = null;
    String methodName = getMethodName(opcode);
    if (methodName != null) {
        // See if the object must be cast
        if (opcode == AALOAD) {
            castType = getTopType(iterator.lookAhead());
            // Do not replace an AALOAD instruction that we do not have a type for
            // This happens when the state is guaranteed to be null (Type.UNINIT)
            // So we don't really care about this case.
            if (castType == null)
                return pos;
            if ("java/lang/Object".equals(castType))
                castType = null;
        }

        // The gap may include extra padding
        // Write a nop in case the padding pushes the instruction forward
        iterator.writeByte(NOP, pos);
        CodeIterator.Gap gap
            = iterator.insertGapAt(pos, castType != null ? 5 : 2, false);
        pos = gap.position;
        int mi = cp.addClassInfo(methodClassname);
        int methodref = cp.addMethodrefInfo(mi, methodName, signature);
        iterator.writeByte(INVOKESTATIC, pos);
        iterator.write16bit(methodref, pos + 1);

        if (castType != null) {
            int index = cp.addClassInfo(castType);
            iterator.writeByte(CHECKCAST, pos + 3);
            iterator.write16bit(index, pos + 4);
        }

        pos = updatePos(pos, gap.length);
    }

    return pos;
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:40,代码来源:TransformAccessArrayField.java

示例6: computeMethodref

import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
private int computeMethodref(int typedesc, ConstPool cp) {
    int classIndex = cp.addClassInfo(trapClass);
    int mnameIndex = cp.addUtf8Info(trapMethod);
    typedesc = cp.addUtf8Info(
            Descriptor.changeReturnType(classname,
                                        cp.getUtf8Info(typedesc)));
    return cp.addMethodrefInfo(classIndex,
                    cp.addNameAndTypeInfo(mnameIndex, typedesc));
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:10,代码来源:TransformNew.java

示例7: addFieldrefInfo

import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
private int addFieldrefInfo(CtField f, FieldInfo finfo) {
    ConstPool cp = bytecode.getConstPool();
    String cname = f.getDeclaringClass().getName();
    int ci = cp.addClassInfo(cname);
    String name = finfo.getName();
    String type = finfo.getDescriptor();
    return cp.addFieldrefInfo(ci, name, type);
}
 
开发者ID:scouter-project,项目名称:scouter,代码行数:9,代码来源:MemberCodeGen.java

示例8: transform

import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
public int transform(CtClass tclazz, int pos, CodeIterator iterator,
                     ConstPool cp) throws BadBytecode
{
    int c = iterator.byteAt(pos);
    if (c == PUTFIELD || c == PUTSTATIC) {
        int index = iterator.u16bitAt(pos + 1);
        String typedesc = isField(tclazz.getClassPool(), cp,
                            fieldClass, fieldname, isPrivate, index);
        if (typedesc != null) {
            if (c == PUTSTATIC) {
                CodeAttribute ca = iterator.get();
                iterator.move(pos);
                char c0 = typedesc.charAt(0);
                if (c0 == 'J' || c0 == 'D') {       // long or double
                    // insertGap() may insert 4 bytes.
                    pos = iterator.insertGap(3);
                    iterator.writeByte(ACONST_NULL, pos);
                    iterator.writeByte(DUP_X2, pos + 1);
                    iterator.writeByte(POP, pos + 2);
                    ca.setMaxStack(ca.getMaxStack() + 2);
                }
                else {
                    // insertGap() may insert 4 bytes.
                    pos = iterator.insertGap(2);
                    iterator.writeByte(ACONST_NULL, pos);
                    iterator.writeByte(SWAP, pos + 1);
                    ca.setMaxStack(ca.getMaxStack() + 1);
                }

                pos = iterator.next();
            }

            int mi = cp.addClassInfo(methodClassname);
            String type = "(Ljava/lang/Object;" + typedesc + ")V";
            int methodref = cp.addMethodrefInfo(mi, methodName, type);
            iterator.writeByte(INVOKESTATIC, pos);
            iterator.write16bit(methodref, pos + 1);
        }
    }

    return pos;
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:43,代码来源:TransformWriteField.java

示例9: getTypeData

import scouter.javassist.bytecode.ConstPool; //导入方法依赖的package包/类
public int getTypeData(ConstPool cp) {
    return cp.addClassInfo(getName());
}
 
开发者ID:scouter-project,项目名称:bytescope,代码行数:4,代码来源:TypeData.java


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