Java Code Examples for jdk.internal.org.objectweb.asm.MethodVisitor#visitIntInsn()

The following examples show how to use jdk.internal.org.objectweb.asm.MethodVisitor#visitIntInsn() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void buildConstructor() {
    MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PUBLIC, DEFAULT_CONSTRUCTOR.getName(), DEFAULT_CONSTRUCTOR.getDescriptor(), null, null);
    mv.visitIntInsn(Opcodes.ALOAD, 0);
    ASMToolkit.invokeSpecial(mv, TYPE_EVENT.getInternalName(), DEFAULT_CONSTRUCTOR);
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
}
 
Example 2
public static byte[] dumpT1() {
    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;

    cw.visit(52, ACC_PUBLIC | ACC_SUPER, "p1/T1", null, "java/lang/Object", null);
    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
        mv.visitInsn(RETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null);
        mv.visitCode();
        mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
        mv.visitLdcInsn("p1/T1.m()");
        mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "print", "(Ljava/lang/String;)V", false);
        mv.visitIntInsn(BIPUSH, 3);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(2, 1);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}
 
Example 3
public static byte[] dumpT1() {
    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;

    cw.visit(52, ACC_PUBLIC | ACC_SUPER, "p1/T1", null, "java/lang/Object", null);
    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
        mv.visitInsn(RETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null);
        mv.visitCode();
        mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
        mv.visitLdcInsn("p1/T1.m()");
        mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "print", "(Ljava/lang/String;)V", false);
        mv.visitIntInsn(BIPUSH, 3);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(2, 1);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}
 
Example 4
Source Project: Bytecoder   File: ProxyGenerator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Visit a bytecode for a constant.
 *
 * @param mv  The MethodVisitor
 * @param cst The constant value
 */
private void emitIconstInsn(MethodVisitor mv, final int cst) {
    if (cst >= -1 && cst <= 5) {
        mv.visitInsn(Opcodes.ICONST_0 + cst);
    } else if (cst >= Byte.MIN_VALUE && cst <= Byte.MAX_VALUE) {
        mv.visitIntInsn(Opcodes.BIPUSH, cst);
    } else if (cst >= Short.MIN_VALUE && cst <= Short.MAX_VALUE) {
        mv.visitIntInsn(Opcodes.SIPUSH, cst);
    } else {
        mv.visitLdcInsn(cst);
    }
}
 
Example 5
/**
 * The following method is copied from
 * org.objectweb.asm.commons.InstructionAdapter. Part of ASM: a very small
 * and fast Java bytecode manipulation framework.
 * Copyright (c) 2000-2005 INRIA, France Telecom All rights reserved.
 */
private static void iconst(MethodVisitor mv, final int cst) {
    if (cst >= -1 && cst <= 5) {
        mv.visitInsn(Opcodes.ICONST_0 + cst);
    } else if (cst >= Byte.MIN_VALUE && cst <= Byte.MAX_VALUE) {
        mv.visitIntInsn(Opcodes.BIPUSH, cst);
    } else if (cst >= Short.MIN_VALUE && cst <= Short.MAX_VALUE) {
        mv.visitIntInsn(Opcodes.SIPUSH, cst);
    } else {
        mv.visitLdcInsn(cst);
    }
}
 
Example 6
public static byte[] dumpT1() {
    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;

    cw.visit(52, ACC_PUBLIC | ACC_SUPER, "p1/T1", null, "java/lang/Object", null);
    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
        mv.visitInsn(RETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null);
        mv.visitCode();
        mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
        mv.visitLdcInsn("p1/T1.m()");
        mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "print", "(Ljava/lang/String;)V", false);
        mv.visitIntInsn(BIPUSH, 3);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(2, 1);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}
 
Example 7
public static byte[] dumpP1A() {

        ClassWriter cw = new ClassWriter(0);
        MethodVisitor mv;

        cw.visit(V1_7, ACC_PUBLIC + ACC_SUPER, "P1/A", null, "java/lang/Object", null);

        {
            mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
            mv.visitCode();
            mv.visitVarInsn(ALOAD, 0);
            mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
            mv.visitInsn(RETURN);
            mv.visitMaxs(1, 1);
            mv.visitEnd();
        }
        {
            mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null);
            mv.visitCode();
            mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
            mv.visitLdcInsn("A.m");
            mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
            mv.visitIntInsn(BIPUSH, 1);
            mv.visitInsn(IRETURN);
            mv.visitMaxs(2, 1);
            mv.visitEnd();
        }
        cw.visitEnd();

        return cw.toByteArray();
    }
 
Example 8
@Override
public void accept(final MethodVisitor mv) {
    mv.visitIntInsn(opcode, operand);
    acceptAnnotations(mv);
}
 
Example 9
@Override
public void accept(final MethodVisitor mv) {
    mv.visitIntInsn(opcode, operand);
    acceptAnnotations(mv);
}
 
Example 10
Source Project: openjdk-jdk9   File: Type.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type newarray(final MethodVisitor method) {
    method.visitIntInsn(NEWARRAY, T_LONG);
    return this;
}
 
Example 11
public static byte[] dumpT3() {
    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;

    cw.visit(52, ACC_PUBLIC + ACC_SUPER, "p1/T3", null, "p1/T2", null);

    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "p1/T2", "<init>", "()V", false);
        mv.visitInsn(RETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null);
        mv.visitCode();
        mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
        mv.visitLdcInsn("p1/T3.m()");
        mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "print", "(Ljava/lang/String;)V", false);
        mv.visitIntInsn(BIPUSH, 2);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(2, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "()I", null, null);
        mv.visitCode();
        mv.visitTypeInsn(NEW, "p1/T3");
        mv.visitInsn(DUP);
        mv.visitMethodInsn(INVOKESPECIAL, "p1/T3", "<init>", "()V", false);
        mv.visitMethodInsn(INVOKEVIRTUAL, "p1/T2", "m", "()I", false);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(3, 2);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}
 
Example 12
Source Project: openjdk-jdk8u   File: Type.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type newarray(final MethodVisitor method) {
    method.visitIntInsn(NEWARRAY, T_LONG);
    return this;
}
 
Example 13
@Override
public void accept(final MethodVisitor mv) {
    mv.visitIntInsn(opcode, operand);
    acceptAnnotations(mv);
}
 
Example 14
@Override
public void accept(final MethodVisitor mv) {
    mv.visitIntInsn(opcode, operand);
    acceptAnnotations(mv);
}
 
Example 15
@Override
public void accept(final MethodVisitor mv) {
    mv.visitIntInsn(opcode, operand);
    acceptAnnotations(mv);
}
 
Example 16
public static byte[] dumpT3() {
    ClassWriter cw = new ClassWriter(0);
    MethodVisitor mv;

    cw.visit(52, ACC_PUBLIC + ACC_SUPER, "p1/T3", null, "p1/T2", null);

    {
        mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        mv.visitVarInsn(ALOAD, 0);
        mv.visitMethodInsn(INVOKESPECIAL, "p1/T2", "<init>", "()V", false);
        mv.visitInsn(RETURN);
        mv.visitMaxs(1, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC, "m", "()I", null, null);
        mv.visitCode();
        mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
        mv.visitLdcInsn("p1/T3.m()");
        mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "print", "(Ljava/lang/String;)V", false);
        mv.visitIntInsn(BIPUSH, 2);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(2, 1);
        mv.visitEnd();
    }
    {
        mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "test", "()I", null, null);
        mv.visitCode();
        mv.visitTypeInsn(NEW, "p1/T3");
        mv.visitInsn(DUP);
        mv.visitMethodInsn(INVOKESPECIAL, "p1/T3", "<init>", "()V", false);
        mv.visitMethodInsn(INVOKEVIRTUAL, "p1/T2", "m", "()I", false);
        mv.visitInsn(IRETURN);
        mv.visitMaxs(3, 2);
        mv.visitEnd();
    }
    cw.visitEnd();

    return cw.toByteArray();
}
 
Example 17
Source Project: jdk8u60   File: Type.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type newarray(final MethodVisitor method) {
    method.visitIntInsn(NEWARRAY, T_DOUBLE);
    return this;
}
 
Example 18
Source Project: openjdk-jdk9   File: Type.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type newarray(final MethodVisitor method) {
    method.visitIntInsn(NEWARRAY, T_INT);
    return this;
}
 
Example 19
Source Project: hottub   File: IntInsnNode.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void accept(final MethodVisitor mv) {
    mv.visitIntInsn(opcode, operand);
    acceptAnnotations(mv);
}
 
Example 20
Source Project: hottub   File: Type.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type newarray(final MethodVisitor method) {
    method.visitIntInsn(NEWARRAY, T_INT);
    return this;
}