Java 类org.mockito.asm.Opcodes 实例源码

项目:mockito-cglib    文件:FrameNode.java   
/**
 * Makes the given visitor visit this stack map frame.
 * 
 * @param mv a method visitor.
 */
public void accept(final MethodVisitor mv) {
    switch (type) {
        case Opcodes.F_NEW:
        case Opcodes.F_FULL:
            mv.visitFrame(type,
                    local.size(),
                    asArray(local),
                    stack.size(),
                    asArray(stack));
            break;
        case Opcodes.F_APPEND:
            mv.visitFrame(type, local.size(), asArray(local), 0, null);
            break;
        case Opcodes.F_CHOP:
            mv.visitFrame(type, local.size(), asArray(local), 0, null);
            break;
        case Opcodes.F_SAME:
            mv.visitFrame(type, 0, null, 0, null);
            break;
        case Opcodes.F_SAME1:
            mv.visitFrame(type, 0, null, 1, asArray(stack));
            break;
    }
}
项目:mockito-cglib    文件:LookupSwitchInsnNode.java   
/**
 * Constructs a new {@link LookupSwitchInsnNode}.
 * 
 * @param dflt beginning of the default handler block.
 * @param keys the values of the keys.
 * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
 *        the beginning of the handler block for the <tt>keys[i]</tt> key.
 */
public LookupSwitchInsnNode(
    final LabelNode dflt,
    final int[] keys,
    final LabelNode[] labels)
{
    super(Opcodes.LOOKUPSWITCH);
    this.dflt = dflt;
    this.keys = new ArrayList(keys == null ? 0 : keys.length);
    this.labels = new ArrayList(labels == null ? 0 : labels.length);
    if (keys != null) {
        for (int i = 0; i < keys.length; ++i) {
            this.keys.add(new Integer(keys[i]));
        }
    }
    if (labels != null) {
        this.labels.addAll(Arrays.asList(labels));
    }
}
项目:mockito-cglib    文件:MethodNode.java   
/**
 * Constructs a new {@link MethodNode}.
 * 
 * @param access the method's access flags (see {@link Opcodes}). This
 *        parameter also indicates if the method is synthetic and/or
 *        deprecated.
 * @param name the method's name.
 * @param desc the method's descriptor (see {@link Type}).
 * @param signature the method's signature. May be <tt>null</tt>.
 * @param exceptions the internal names of the method's exception classes
 *        (see {@link Type#getInternalName() getInternalName}). May be
 *        <tt>null</tt>.
 */
public MethodNode(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final String[] exceptions)
{
    this();
    this.access = access;
    this.name = name;
    this.desc = desc;
    this.signature = signature;
    this.exceptions = new ArrayList(exceptions == null
            ? 0
            : exceptions.length);
    boolean isAbstract = (access & Opcodes.ACC_ABSTRACT) != 0;
    if (!isAbstract) {
        this.localVariables = new ArrayList(5);
    }
    this.tryCatchBlocks = new ArrayList();
    if (exceptions != null) {
        this.exceptions.addAll(Arrays.asList(exceptions));
    }
}
项目:mockito-cglib    文件:TableSwitchInsnNode.java   
/**
 * Constructs a new {@link TableSwitchInsnNode}.
 * 
 * @param min the minimum key value.
 * @param max the maximum key value.
 * @param dflt beginning of the default handler block.
 * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
 *        the beginning of the handler block for the <tt>min + i</tt> key.
 */
public TableSwitchInsnNode(
    final int min,
    final int max,
    final LabelNode dflt,
    final LabelNode[] labels)
{
    super(Opcodes.TABLESWITCH);
    this.min = min;
    this.max = max;
    this.dflt = dflt;
    this.labels = new ArrayList();
    if (labels != null) {
        this.labels.addAll(Arrays.asList(labels));
    }
}
项目:mockito-cglib    文件:CheckClassAdapter.java   
public void visitInnerClass(
    final String name,
    final String outerName,
    final String innerName,
    final int access)
{
    checkState();
    CheckMethodAdapter.checkInternalName(name, "class name");
    if (outerName != null) {
        CheckMethodAdapter.checkInternalName(outerName, "outer class name");
    }
    if (innerName != null) {
        CheckMethodAdapter.checkIdentifier(innerName, "inner class name");
    }
    checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
            + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
            + Opcodes.ACC_FINAL + Opcodes.ACC_INTERFACE
            + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC
            + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM);
    cv.visitInnerClass(name, outerName, innerName, access);
}
项目:mockito-cglib    文件:CheckClassAdapter.java   
public FieldVisitor visitField(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final Object value)
{
    checkState();
    checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
            + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
            + Opcodes.ACC_FINAL + Opcodes.ACC_VOLATILE
            + Opcodes.ACC_TRANSIENT + Opcodes.ACC_SYNTHETIC
            + Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED);
    CheckMethodAdapter.checkIdentifier(name, "field name");
    CheckMethodAdapter.checkDesc(desc, false);
    if (signature != null) {
        CheckMethodAdapter.checkFieldSignature(signature);
    }
    if (value != null) {
        CheckMethodAdapter.checkConstant(value);
    }
    FieldVisitor av = cv.visitField(access, name, desc, signature, value);
    return new CheckFieldAdapter(av);
}
项目:mockito-cglib    文件:CheckClassAdapter.java   
/**
 * Checks that the given access flags do not contain invalid flags. This
 * method also checks that mutually incompatible flags are not set
 * simultaneously.
 * 
 * @param access the access flags to be checked
 * @param possibleAccess the valid access flags.
 */
static void checkAccess(final int access, final int possibleAccess) {
    if ((access & ~possibleAccess) != 0) {
        throw new IllegalArgumentException("Invalid access flags: "
                + access);
    }
    int pub = (access & Opcodes.ACC_PUBLIC) == 0 ? 0 : 1;
    int pri = (access & Opcodes.ACC_PRIVATE) == 0 ? 0 : 1;
    int pro = (access & Opcodes.ACC_PROTECTED) == 0 ? 0 : 1;
    if (pub + pri + pro > 1) {
        throw new IllegalArgumentException("public private and protected are mutually exclusive: "
                + access);
    }
    int fin = (access & Opcodes.ACC_FINAL) == 0 ? 0 : 1;
    int abs = (access & Opcodes.ACC_ABSTRACT) == 0 ? 0 : 1;
    if (fin + abs > 1) {
        throw new IllegalArgumentException("final and abstract are mutually exclusive: "
                + access);
    }
}
项目:mockito-cglib    文件:CheckMethodAdapter.java   
public void visitIntInsn(final int opcode, final int operand) {
    checkStartCode();
    checkEndCode();
    checkOpcode(opcode, 1);
    switch (opcode) {
        case Opcodes.BIPUSH:
            checkSignedByte(operand, "Invalid operand");
            break;
        case Opcodes.SIPUSH:
            checkSignedShort(operand, "Invalid operand");
            break;
        // case Constants.NEWARRAY:
        default:
            if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) {
                throw new IllegalArgumentException("Invalid operand (must be an array type code T_...): "
                        + operand);
            }
    }
    mv.visitIntInsn(opcode, operand);
}
项目:mockito-cglib    文件:CheckMethodAdapter.java   
/**
 * Checks a stack frame value.
 * 
 * @param value the value to be checked.
 */
static void checkFrameValue(final Object value) {
    if (value == Opcodes.TOP || value == Opcodes.INTEGER
            || value == Opcodes.FLOAT || value == Opcodes.LONG
            || value == Opcodes.DOUBLE || value == Opcodes.NULL
            || value == Opcodes.UNINITIALIZED_THIS)
    {
        return;
    }
    if (value instanceof String) {
        checkInternalName((String) value, "Invalid stack frame value");
        return;
    }
    if (!(value instanceof Label)) {
        throw new IllegalArgumentException("Invalid stack frame value: "
                + value);
    }
}
项目:mockito-cglib    文件:TraceClassVisitor.java   
public void visitInnerClass(
    final String name,
    final String outerName,
    final String innerName,
    final int access)
{
    buf.setLength(0);
    buf.append(tab).append("// access flags ");
    buf.append(access & ~Opcodes.ACC_SUPER).append('\n');
    buf.append(tab);
    appendAccess(access);
    buf.append("INNERCLASS ");
    appendDescriptor(INTERNAL_NAME, name);
    buf.append(' ');
    appendDescriptor(INTERNAL_NAME, outerName);
    buf.append(' ');
    appendDescriptor(INTERNAL_NAME, innerName);
    buf.append('\n');
    text.add(buf.toString());

    if (cv != null) {
        cv.visitInnerClass(name, outerName, innerName, access);
    }
}
项目:nedis    文件:TestNedisClientImpl.java   
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature,
        String[] exceptions) {
    if ((Opcodes.ACC_PUBLIC & access) == 0 || EXCLUDE_METHODS.contains(name)
            || name.contains("<")) {
        return null;
    }
    if (name.endsWith("0")) {
        name = name.substring(0, name.length() - 1);
    }
    int index = -1;
    for (int i = 0; i < name.length(); i++) {
        if (Character.isUpperCase(name.charAt(i))) {
            index = i;
            break;
        }
    }
    if (index < 0) {
        return new FindEnumVisitor(name, name.toUpperCase(), null);
    } else {
        String cmd = name.substring(0, index).toUpperCase();
        return new FindEnumVisitor(name, cmd, name.substring(index).toUpperCase());
    }
}
项目:astor    文件:FrameNode.java   
/**
 * Makes the given visitor visit this stack map frame.
 * 
 * @param mv a method visitor.
 */
public void accept(final MethodVisitor mv) {
    switch (type) {
        case Opcodes.F_NEW:
        case Opcodes.F_FULL:
            mv.visitFrame(type,
                    local.size(),
                    asArray(local),
                    stack.size(),
                    asArray(stack));
            break;
        case Opcodes.F_APPEND:
            mv.visitFrame(type, local.size(), asArray(local), 0, null);
            break;
        case Opcodes.F_CHOP:
            mv.visitFrame(type, local.size(), asArray(local), 0, null);
            break;
        case Opcodes.F_SAME:
            mv.visitFrame(type, 0, null, 0, null);
            break;
        case Opcodes.F_SAME1:
            mv.visitFrame(type, 0, null, 1, asArray(stack));
            break;
    }
}
项目:astor    文件:LookupSwitchInsnNode.java   
/**
 * Constructs a new {@link LookupSwitchInsnNode}.
 * 
 * @param dflt beginning of the default handler block.
 * @param keys the values of the keys.
 * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
 *        the beginning of the handler block for the <tt>keys[i]</tt> key.
 */
public LookupSwitchInsnNode(
    final LabelNode dflt,
    final int[] keys,
    final LabelNode[] labels)
{
    super(Opcodes.LOOKUPSWITCH);
    this.dflt = dflt;
    this.keys = new ArrayList(keys == null ? 0 : keys.length);
    this.labels = new ArrayList(labels == null ? 0 : labels.length);
    if (keys != null) {
        for (int i = 0; i < keys.length; ++i) {
            this.keys.add(new Integer(keys[i]));
        }
    }
    if (labels != null) {
        this.labels.addAll(Arrays.asList(labels));
    }
}
项目:astor    文件:MethodNode.java   
/**
 * Constructs a new {@link MethodNode}.
 * 
 * @param access the method's access flags (see {@link Opcodes}). This
 *        parameter also indicates if the method is synthetic and/or
 *        deprecated.
 * @param name the method's name.
 * @param desc the method's descriptor (see {@link Type}).
 * @param signature the method's signature. May be <tt>null</tt>.
 * @param exceptions the internal names of the method's exception classes
 *        (see {@link Type#getInternalName() getInternalName}). May be
 *        <tt>null</tt>.
 */
public MethodNode(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final String[] exceptions)
{
    this();
    this.access = access;
    this.name = name;
    this.desc = desc;
    this.signature = signature;
    this.exceptions = new ArrayList(exceptions == null
            ? 0
            : exceptions.length);
    boolean isAbstract = (access & Opcodes.ACC_ABSTRACT) != 0;
    if (!isAbstract) {
        this.localVariables = new ArrayList(5);
    }
    this.tryCatchBlocks = new ArrayList();
    if (exceptions != null) {
        this.exceptions.addAll(Arrays.asList(exceptions));
    }
}
项目:astor    文件:TableSwitchInsnNode.java   
/**
 * Constructs a new {@link TableSwitchInsnNode}.
 * 
 * @param min the minimum key value.
 * @param max the maximum key value.
 * @param dflt beginning of the default handler block.
 * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
 *        the beginning of the handler block for the <tt>min + i</tt> key.
 */
public TableSwitchInsnNode(
    final int min,
    final int max,
    final LabelNode dflt,
    final LabelNode[] labels)
{
    super(Opcodes.TABLESWITCH);
    this.min = min;
    this.max = max;
    this.dflt = dflt;
    this.labels = new ArrayList();
    if (labels != null) {
        this.labels.addAll(Arrays.asList(labels));
    }
}
项目:astor    文件:CheckClassAdapter.java   
public void visitInnerClass(
    final String name,
    final String outerName,
    final String innerName,
    final int access)
{
    checkState();
    CheckMethodAdapter.checkInternalName(name, "class name");
    if (outerName != null) {
        CheckMethodAdapter.checkInternalName(outerName, "outer class name");
    }
    if (innerName != null) {
        CheckMethodAdapter.checkIdentifier(innerName, "inner class name");
    }
    checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
            + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
            + Opcodes.ACC_FINAL + Opcodes.ACC_INTERFACE
            + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC
            + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM);
    cv.visitInnerClass(name, outerName, innerName, access);
}
项目:astor    文件:CheckClassAdapter.java   
public FieldVisitor visitField(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final Object value)
{
    checkState();
    checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
            + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
            + Opcodes.ACC_FINAL + Opcodes.ACC_VOLATILE
            + Opcodes.ACC_TRANSIENT + Opcodes.ACC_SYNTHETIC
            + Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED);
    CheckMethodAdapter.checkIdentifier(name, "field name");
    CheckMethodAdapter.checkDesc(desc, false);
    if (signature != null) {
        CheckMethodAdapter.checkFieldSignature(signature);
    }
    if (value != null) {
        CheckMethodAdapter.checkConstant(value);
    }
    FieldVisitor av = cv.visitField(access, name, desc, signature, value);
    return new CheckFieldAdapter(av);
}
项目:astor    文件:CheckClassAdapter.java   
/**
 * Checks that the given access flags do not contain invalid flags. This
 * method also checks that mutually incompatible flags are not set
 * simultaneously.
 * 
 * @param access the access flags to be checked
 * @param possibleAccess the valid access flags.
 */
static void checkAccess(final int access, final int possibleAccess) {
    if ((access & ~possibleAccess) != 0) {
        throw new IllegalArgumentException("Invalid access flags: "
                + access);
    }
    int pub = (access & Opcodes.ACC_PUBLIC) == 0 ? 0 : 1;
    int pri = (access & Opcodes.ACC_PRIVATE) == 0 ? 0 : 1;
    int pro = (access & Opcodes.ACC_PROTECTED) == 0 ? 0 : 1;
    if (pub + pri + pro > 1) {
        throw new IllegalArgumentException("public private and protected are mutually exclusive: "
                + access);
    }
    int fin = (access & Opcodes.ACC_FINAL) == 0 ? 0 : 1;
    int abs = (access & Opcodes.ACC_ABSTRACT) == 0 ? 0 : 1;
    if (fin + abs > 1) {
        throw new IllegalArgumentException("final and abstract are mutually exclusive: "
                + access);
    }
}
项目:astor    文件:CheckMethodAdapter.java   
public void visitIntInsn(final int opcode, final int operand) {
    checkStartCode();
    checkEndCode();
    checkOpcode(opcode, 1);
    switch (opcode) {
        case Opcodes.BIPUSH:
            checkSignedByte(operand, "Invalid operand");
            break;
        case Opcodes.SIPUSH:
            checkSignedShort(operand, "Invalid operand");
            break;
        // case Constants.NEWARRAY:
        default:
            if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) {
                throw new IllegalArgumentException("Invalid operand (must be an array type code T_...): "
                        + operand);
            }
    }
    mv.visitIntInsn(opcode, operand);
}
项目:astor    文件:CheckMethodAdapter.java   
/**
 * Checks a stack frame value.
 * 
 * @param value the value to be checked.
 */
static void checkFrameValue(final Object value) {
    if (value == Opcodes.TOP || value == Opcodes.INTEGER
            || value == Opcodes.FLOAT || value == Opcodes.LONG
            || value == Opcodes.DOUBLE || value == Opcodes.NULL
            || value == Opcodes.UNINITIALIZED_THIS)
    {
        return;
    }
    if (value instanceof String) {
        checkInternalName((String) value, "Invalid stack frame value");
        return;
    }
    if (!(value instanceof Label)) {
        throw new IllegalArgumentException("Invalid stack frame value: "
                + value);
    }
}
项目:astor    文件:TraceClassVisitor.java   
public void visitInnerClass(
    final String name,
    final String outerName,
    final String innerName,
    final int access)
{
    buf.setLength(0);
    buf.append(tab).append("// access flags ");
    buf.append(access & ~Opcodes.ACC_SUPER).append('\n');
    buf.append(tab);
    appendAccess(access);
    buf.append("INNERCLASS ");
    appendDescriptor(INTERNAL_NAME, name);
    buf.append(' ');
    appendDescriptor(INTERNAL_NAME, outerName);
    buf.append(' ');
    appendDescriptor(INTERNAL_NAME, innerName);
    buf.append('\n');
    text.add(buf.toString());

    if (cv != null) {
        cv.visitInnerClass(name, outerName, innerName, access);
    }
}
项目:astor    文件:FrameNode.java   
/**
 * Makes the given visitor visit this stack map frame.
 * 
 * @param mv a method visitor.
 */
public void accept(final MethodVisitor mv) {
    switch (type) {
        case Opcodes.F_NEW:
        case Opcodes.F_FULL:
            mv.visitFrame(type,
                    local.size(),
                    asArray(local),
                    stack.size(),
                    asArray(stack));
            break;
        case Opcodes.F_APPEND:
            mv.visitFrame(type, local.size(), asArray(local), 0, null);
            break;
        case Opcodes.F_CHOP:
            mv.visitFrame(type, local.size(), asArray(local), 0, null);
            break;
        case Opcodes.F_SAME:
            mv.visitFrame(type, 0, null, 0, null);
            break;
        case Opcodes.F_SAME1:
            mv.visitFrame(type, 0, null, 1, asArray(stack));
            break;
    }
}
项目:astor    文件:LookupSwitchInsnNode.java   
/**
 * Constructs a new {@link LookupSwitchInsnNode}.
 * 
 * @param dflt beginning of the default handler block.
 * @param keys the values of the keys.
 * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
 *        the beginning of the handler block for the <tt>keys[i]</tt> key.
 */
public LookupSwitchInsnNode(
    final LabelNode dflt,
    final int[] keys,
    final LabelNode[] labels)
{
    super(Opcodes.LOOKUPSWITCH);
    this.dflt = dflt;
    this.keys = new ArrayList(keys == null ? 0 : keys.length);
    this.labels = new ArrayList(labels == null ? 0 : labels.length);
    if (keys != null) {
        for (int i = 0; i < keys.length; ++i) {
            this.keys.add(new Integer(keys[i]));
        }
    }
    if (labels != null) {
        this.labels.addAll(Arrays.asList(labels));
    }
}
项目:astor    文件:MethodNode.java   
/**
 * Constructs a new {@link MethodNode}.
 * 
 * @param access the method's access flags (see {@link Opcodes}). This
 *        parameter also indicates if the method is synthetic and/or
 *        deprecated.
 * @param name the method's name.
 * @param desc the method's descriptor (see {@link Type}).
 * @param signature the method's signature. May be <tt>null</tt>.
 * @param exceptions the internal names of the method's exception classes
 *        (see {@link Type#getInternalName() getInternalName}). May be
 *        <tt>null</tt>.
 */
public MethodNode(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final String[] exceptions)
{
    this();
    this.access = access;
    this.name = name;
    this.desc = desc;
    this.signature = signature;
    this.exceptions = new ArrayList(exceptions == null
            ? 0
            : exceptions.length);
    boolean isAbstract = (access & Opcodes.ACC_ABSTRACT) != 0;
    if (!isAbstract) {
        this.localVariables = new ArrayList(5);
    }
    this.tryCatchBlocks = new ArrayList();
    if (exceptions != null) {
        this.exceptions.addAll(Arrays.asList(exceptions));
    }
}
项目:astor    文件:TableSwitchInsnNode.java   
/**
 * Constructs a new {@link TableSwitchInsnNode}.
 * 
 * @param min the minimum key value.
 * @param max the maximum key value.
 * @param dflt beginning of the default handler block.
 * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is
 *        the beginning of the handler block for the <tt>min + i</tt> key.
 */
public TableSwitchInsnNode(
    final int min,
    final int max,
    final LabelNode dflt,
    final LabelNode[] labels)
{
    super(Opcodes.TABLESWITCH);
    this.min = min;
    this.max = max;
    this.dflt = dflt;
    this.labels = new ArrayList();
    if (labels != null) {
        this.labels.addAll(Arrays.asList(labels));
    }
}
项目:astor    文件:CheckClassAdapter.java   
public void visitInnerClass(
    final String name,
    final String outerName,
    final String innerName,
    final int access)
{
    checkState();
    CheckMethodAdapter.checkInternalName(name, "class name");
    if (outerName != null) {
        CheckMethodAdapter.checkInternalName(outerName, "outer class name");
    }
    if (innerName != null) {
        CheckMethodAdapter.checkIdentifier(innerName, "inner class name");
    }
    checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
            + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
            + Opcodes.ACC_FINAL + Opcodes.ACC_INTERFACE
            + Opcodes.ACC_ABSTRACT + Opcodes.ACC_SYNTHETIC
            + Opcodes.ACC_ANNOTATION + Opcodes.ACC_ENUM);
    cv.visitInnerClass(name, outerName, innerName, access);
}
项目:astor    文件:CheckClassAdapter.java   
public FieldVisitor visitField(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final Object value)
{
    checkState();
    checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
            + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
            + Opcodes.ACC_FINAL + Opcodes.ACC_VOLATILE
            + Opcodes.ACC_TRANSIENT + Opcodes.ACC_SYNTHETIC
            + Opcodes.ACC_ENUM + Opcodes.ACC_DEPRECATED);
    CheckMethodAdapter.checkIdentifier(name, "field name");
    CheckMethodAdapter.checkDesc(desc, false);
    if (signature != null) {
        CheckMethodAdapter.checkFieldSignature(signature);
    }
    if (value != null) {
        CheckMethodAdapter.checkConstant(value);
    }
    FieldVisitor av = cv.visitField(access, name, desc, signature, value);
    return new CheckFieldAdapter(av);
}
项目:astor    文件:CheckClassAdapter.java   
/**
 * Checks that the given access flags do not contain invalid flags. This
 * method also checks that mutually incompatible flags are not set
 * simultaneously.
 * 
 * @param access the access flags to be checked
 * @param possibleAccess the valid access flags.
 */
static void checkAccess(final int access, final int possibleAccess) {
    if ((access & ~possibleAccess) != 0) {
        throw new IllegalArgumentException("Invalid access flags: "
                + access);
    }
    int pub = (access & Opcodes.ACC_PUBLIC) == 0 ? 0 : 1;
    int pri = (access & Opcodes.ACC_PRIVATE) == 0 ? 0 : 1;
    int pro = (access & Opcodes.ACC_PROTECTED) == 0 ? 0 : 1;
    if (pub + pri + pro > 1) {
        throw new IllegalArgumentException("public private and protected are mutually exclusive: "
                + access);
    }
    int fin = (access & Opcodes.ACC_FINAL) == 0 ? 0 : 1;
    int abs = (access & Opcodes.ACC_ABSTRACT) == 0 ? 0 : 1;
    if (fin + abs > 1) {
        throw new IllegalArgumentException("final and abstract are mutually exclusive: "
                + access);
    }
}
项目:astor    文件:CheckMethodAdapter.java   
public void visitIntInsn(final int opcode, final int operand) {
    checkStartCode();
    checkEndCode();
    checkOpcode(opcode, 1);
    switch (opcode) {
        case Opcodes.BIPUSH:
            checkSignedByte(operand, "Invalid operand");
            break;
        case Opcodes.SIPUSH:
            checkSignedShort(operand, "Invalid operand");
            break;
        // case Constants.NEWARRAY:
        default:
            if (operand < Opcodes.T_BOOLEAN || operand > Opcodes.T_LONG) {
                throw new IllegalArgumentException("Invalid operand (must be an array type code T_...): "
                        + operand);
            }
    }
    mv.visitIntInsn(opcode, operand);
}
项目:astor    文件:CheckMethodAdapter.java   
/**
 * Checks a stack frame value.
 * 
 * @param value the value to be checked.
 */
static void checkFrameValue(final Object value) {
    if (value == Opcodes.TOP || value == Opcodes.INTEGER
            || value == Opcodes.FLOAT || value == Opcodes.LONG
            || value == Opcodes.DOUBLE || value == Opcodes.NULL
            || value == Opcodes.UNINITIALIZED_THIS)
    {
        return;
    }
    if (value instanceof String) {
        checkInternalName((String) value, "Invalid stack frame value");
        return;
    }
    if (!(value instanceof Label)) {
        throw new IllegalArgumentException("Invalid stack frame value: "
                + value);
    }
}
项目:astor    文件:TraceClassVisitor.java   
public void visitInnerClass(
    final String name,
    final String outerName,
    final String innerName,
    final int access)
{
    buf.setLength(0);
    buf.append(tab).append("// access flags ");
    buf.append(access & ~Opcodes.ACC_SUPER).append('\n');
    buf.append(tab);
    appendAccess(access);
    buf.append("INNERCLASS ");
    appendDescriptor(INTERNAL_NAME, name);
    buf.append(' ');
    appendDescriptor(INTERNAL_NAME, outerName);
    buf.append(' ');
    appendDescriptor(INTERNAL_NAME, innerName);
    buf.append('\n');
    text.add(buf.toString());

    if (cv != null) {
        cv.visitInnerClass(name, outerName, innerName, access);
    }
}
项目:mockito-cglib    文件:LocalVariablesSorter.java   
public LocalVariablesSorter(
    final int access,
    final String desc,
    final MethodVisitor mv)
{
    super(mv);
    state = new State();
    Type[] args = Type.getArgumentTypes(desc);
    state.nextLocal = ((Opcodes.ACC_STATIC & access) != 0) ? 0 : 1;
    for (int i = 0; i < args.length; i++) {
        state.nextLocal += args[i].getSize();
    }
    firstLocal = state.nextLocal;
}
项目:mockito-cglib    文件:LocalVariablesSorter.java   
public void visitVarInsn(final int opcode, final int var) {
    int size;
    switch (opcode) {
        case Opcodes.LLOAD:
        case Opcodes.LSTORE:
        case Opcodes.DLOAD:
        case Opcodes.DSTORE:
            size = 2;
            break;
        default:
            size = 1;
    }
    mv.visitVarInsn(opcode, remap(var, size));
}
项目:mockito-cglib    文件:FrameNode.java   
/**
 * Constructs a new {@link FrameNode}.
 * 
 * @param type the type of this frame. Must be {@link Opcodes#F_NEW} for
 *        expanded frames, or {@link Opcodes#F_FULL},
 *        {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP},
 *        {@link Opcodes#F_SAME} or {@link Opcodes#F_APPEND},
 *        {@link Opcodes#F_SAME1} for compressed frames.
 * @param nLocal number of local variables of this stack map frame.
 * @param local the types of the local variables of this stack map frame.
 *        Elements of this list can be Integer, String or LabelNode objects
 *        (for primitive, reference and uninitialized types respectively -
 *        see {@link MethodVisitor}).
 * @param nStack number of operand stack elements of this stack map frame.
 * @param stack the types of the operand stack elements of this stack map
 *        frame. Elements of this list can be Integer, String or LabelNode
 *        objects (for primitive, reference and uninitialized types
 *        respectively - see {@link MethodVisitor}).
 */
public FrameNode(
    final int type,
    final int nLocal,
    final Object[] local,
    final int nStack,
    final Object[] stack)
{
    super(-1);
    this.type = type;
    switch (type) {
        case Opcodes.F_NEW:
        case Opcodes.F_FULL:
            this.local = asList(nLocal, local);
            this.stack = asList(nStack, stack);
            break;
        case Opcodes.F_APPEND:
            this.local = asList(nLocal, local);
            break;
        case Opcodes.F_CHOP:
            this.local = asList(nLocal, local);
            break;
        case Opcodes.F_SAME:
            break;
        case Opcodes.F_SAME1:
            this.stack = asList(1, stack);
            break;
    }
}
项目:mockito-cglib    文件:CheckClassAdapter.java   
public MethodVisitor visitMethod(
    final int access,
    final String name,
    final String desc,
    final String signature,
    final String[] exceptions)
{
    checkState();
    checkAccess(access, Opcodes.ACC_PUBLIC + Opcodes.ACC_PRIVATE
            + Opcodes.ACC_PROTECTED + Opcodes.ACC_STATIC
            + Opcodes.ACC_FINAL + Opcodes.ACC_SYNCHRONIZED
            + Opcodes.ACC_BRIDGE + Opcodes.ACC_VARARGS + Opcodes.ACC_NATIVE
            + Opcodes.ACC_ABSTRACT + Opcodes.ACC_STRICT
            + Opcodes.ACC_SYNTHETIC + Opcodes.ACC_DEPRECATED);
    CheckMethodAdapter.checkMethodIdentifier(name, "method name");
    CheckMethodAdapter.checkMethodDesc(desc);
    if (signature != null) {
        CheckMethodAdapter.checkMethodSignature(signature);
    }
    if (exceptions != null) {
        for (int i = 0; i < exceptions.length; ++i) {
            CheckMethodAdapter.checkInternalName(exceptions[i],
                    "exception name at index " + i);
        }
    }
    return new CheckMethodAdapter(cv.visitMethod(access,
            name,
            desc,
            signature,
            exceptions));
}
项目:mockito-cglib    文件:CheckMethodAdapter.java   
public void visitTypeInsn(final int opcode, final String type) {
    checkStartCode();
    checkEndCode();
    checkOpcode(opcode, 3);
    checkInternalName(type, "type");
    if (opcode == Opcodes.NEW && type.charAt(0) == '[') {
        throw new IllegalArgumentException("NEW cannot be used to create arrays: "
                + type);
    }
    mv.visitTypeInsn(opcode, type);
}
项目:mockito-cglib    文件:TraceMethodVisitor.java   
public void visitIntInsn(final int opcode, final int operand) {
    buf.setLength(0);
    buf.append(tab2)
            .append(OPCODES[opcode])
            .append(' ')
            .append(opcode == Opcodes.NEWARRAY
                    ? TYPES[operand]
                    : Integer.toString(operand))
            .append('\n');
    text.add(buf.toString());

    if (mv != null) {
        mv.visitIntInsn(opcode, operand);
    }
}
项目:mockito-cglib    文件:TraceClassVisitor.java   
/**
 * Appends a string representation of the given access modifiers to {@link
 * #buf buf}.
 * 
 * @param access some access modifiers.
 */
private void appendAccess(final int access) {
    if ((access & Opcodes.ACC_PUBLIC) != 0) {
        buf.append("public ");
    }
    if ((access & Opcodes.ACC_PRIVATE) != 0) {
        buf.append("private ");
    }
    if ((access & Opcodes.ACC_PROTECTED) != 0) {
        buf.append("protected ");
    }
    if ((access & Opcodes.ACC_FINAL) != 0) {
        buf.append("final ");
    }
    if ((access & Opcodes.ACC_STATIC) != 0) {
        buf.append("static ");
    }
    if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) {
        buf.append("synchronized ");
    }
    if ((access & Opcodes.ACC_VOLATILE) != 0) {
        buf.append("volatile ");
    }
    if ((access & Opcodes.ACC_TRANSIENT) != 0) {
        buf.append("transient ");
    }
    if ((access & Opcodes.ACC_ABSTRACT) != 0) {
        buf.append("abstract ");
    }
    if ((access & Opcodes.ACC_STRICT) != 0) {
        buf.append("strictfp ");
    }
    if ((access & Opcodes.ACC_ENUM) != 0) {
        buf.append("enum ");
    }
}
项目:mockito-cglib    文件:ASMifierMethodVisitor.java   
public void visitIntInsn(final int opcode, final int operand) {
    buf.setLength(0);
    buf.append("mv.visitIntInsn(")
            .append(OPCODES[opcode])
            .append(", ")
            .append(opcode == Opcodes.NEWARRAY
                    ? TYPES[operand]
                    : Integer.toString(operand))
            .append(");\n");
    text.add(buf.toString());
}
项目:nedis    文件:TestNedisClientImpl.java   
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
    if (opcode != Opcodes.GETSTATIC) {
        return;
    }
    if (owner.endsWith("RedisCommand")) {
        visitedCmds.add(name);
    } else if (owner.endsWith("RedisKeyword")) {
        visitedKeywords.add(name);
    }
}