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() .
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
Source File: TransitiveOverrideCFV50.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 2
Source File: EventClassBuilder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 3
Source File: TestConcreteClassWithAbstractMethod.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 File: TestConcreteClassWithAbstractMethod.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 5
Source File: TestConcreteClassWithAbstractMethod.java From hottub with GNU General Public License v2.0 | 5 votes |
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 6
Source File: ProxyGenerator.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * 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 7
Source File: StringConcatFactory.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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 8
Source File: IntInsnNode.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Override public void accept(final MethodVisitor mv) { mv.visitIntInsn(opcode, operand); acceptAnnotations(mv); }
Example 9
Source File: Type.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public Type newarray(final MethodVisitor method) { method.visitIntInsn(NEWARRAY, T_INT); return this; }
Example 10
Source File: IntInsnNode.java From hottub with GNU General Public License v2.0 | 4 votes |
@Override public void accept(final MethodVisitor mv) { mv.visitIntInsn(opcode, operand); acceptAnnotations(mv); }
Example 11
Source File: Type.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Type newarray(final MethodVisitor method) { method.visitIntInsn(NEWARRAY, T_INT); return this; }
Example 12
Source File: Type.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override public Type newarray(final MethodVisitor method) { method.visitIntInsn(NEWARRAY, T_DOUBLE); return this; }
Example 13
Source File: TestConcreteClassWithAbstractMethod.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
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 14
Source File: IntInsnNode.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Override public void accept(final MethodVisitor mv) { mv.visitIntInsn(opcode, operand); acceptAnnotations(mv); }
Example 15
Source File: IntInsnNode.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
@Override public void accept(final MethodVisitor mv) { mv.visitIntInsn(opcode, operand); acceptAnnotations(mv); }
Example 16
Source File: IntInsnNode.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
@Override public void accept(final MethodVisitor mv) { mv.visitIntInsn(opcode, operand); acceptAnnotations(mv); }
Example 17
Source File: Type.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public Type newarray(final MethodVisitor method) { method.visitIntInsn(NEWARRAY, T_LONG); return this; }
Example 18
Source File: TestConcreteClassWithAbstractMethod.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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 19
Source File: Type.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public Type newarray(final MethodVisitor method) { method.visitIntInsn(NEWARRAY, T_LONG); return this; }
Example 20
Source File: IntInsnNode.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
@Override public void accept(final MethodVisitor mv) { mv.visitIntInsn(opcode, operand); acceptAnnotations(mv); }