List of usage examples for org.objectweb.asm Opcodes ICONST_0
int ICONST_0
To view the source code for org.objectweb.asm Opcodes ICONST_0.
Click Source Link
From source file:org.jacoco.core.internal.instr.ProbeInserterTest.java
License:Open Source License
@Test public void testVariableStatic() { ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "()V", actualVisitor, arrayStrategy); pi.insertProbe(0);/*www.ja v a 2 s . c o m*/ expectedVisitor.visitVarInsn(Opcodes.ALOAD, 0); expectedVisitor.visitInsn(Opcodes.ICONST_0); expectedVisitor.visitInsn(Opcodes.ICONST_1); expectedVisitor.visitInsn(Opcodes.BASTORE); }
From source file:org.jacoco.core.internal.instr.ProbeInserterTest.java
License:Open Source License
@Test public void testVariableNonStatic() { ProbeInserter pi = new ProbeInserter(0, "()V", actualVisitor, arrayStrategy); pi.insertProbe(0);//ww w . j a v a2 s . co m expectedVisitor.visitVarInsn(Opcodes.ALOAD, 1); expectedVisitor.visitInsn(Opcodes.ICONST_0); expectedVisitor.visitInsn(Opcodes.ICONST_1); expectedVisitor.visitInsn(Opcodes.BASTORE); }
From source file:org.jacoco.core.internal.instr.ProbeInserterTest.java
License:Open Source License
@Test public void testVariableNonStatic_IZObject() { ProbeInserter pi = new ProbeInserter(0, "(IZLjava/lang/Object;)V", actualVisitor, arrayStrategy); pi.insertProbe(0);// w ww . j a v a2s. com expectedVisitor.visitVarInsn(Opcodes.ALOAD, 4); expectedVisitor.visitInsn(Opcodes.ICONST_0); expectedVisitor.visitInsn(Opcodes.ICONST_1); expectedVisitor.visitInsn(Opcodes.BASTORE); }
From source file:org.jacoco.core.internal.instr.ProbeInserterTest.java
License:Open Source License
@Test public void testVariableNonStatic_JD() { ProbeInserter pi = new ProbeInserter(0, "(JD)V", actualVisitor, arrayStrategy); pi.insertProbe(0);// w ww . java 2 s .c om expectedVisitor.visitVarInsn(Opcodes.ALOAD, 5); expectedVisitor.visitInsn(Opcodes.ICONST_0); expectedVisitor.visitInsn(Opcodes.ICONST_1); expectedVisitor.visitInsn(Opcodes.BASTORE); }
From source file:org.jacoco.core.runtime.AbstractRuntimeData.java
License:Open Source License
/** * Generates code that creates the argument array for the * {@link #getProbes(Object[])} method. The array instance is left on the * operand stack. The generated code requires a stack size of 5. * /*from ww w . j a v a2s. co m*/ * @param classid * class identifier * @param classname * VM class name * @param probecount * probe count for this class * @param mv * visitor to emit generated code */ public static void generateArgumentArray(final long classid, final String classname, final int probecount, final MethodVisitor mv) { mv.visitInsn(Opcodes.ICONST_3); mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object"); // Class Id: mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_0); mv.visitLdcInsn(Long.valueOf(classid)); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false); mv.visitInsn(Opcodes.AASTORE); // Class Name: mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_1); mv.visitLdcInsn(classname); mv.visitInsn(Opcodes.AASTORE); // Probe Count: mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_2); InstrSupport.push(mv, probecount); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false); mv.visitInsn(Opcodes.AASTORE); }
From source file:org.jacoco.core.runtime.AbstractRuntimeData.java
License:Open Source License
/** * Generates the code that calls a {@link ControlFlowRuntimeData} instance through the * JRE API method {@link Object#equals(Object)}. The code pops a * {@link Object} instance from the stack and pushes the probe array of type * <code>boolean[]</code> on the operand stack. The generated code requires * a stack size of 6.//from w ww. j a v a2 s . com * * @param classid * class identifier * @param classname * VM class name * @param probecount * probe count for this class * @param mv * visitor to emit generated code */ public static void generateAccessCall(final long classid, final String classname, final int probecount, final MethodVisitor mv) { // stack[0]: Ljava/lang/Object; generateArgumentArray(classid, classname, probecount, mv); // stack[1]: [Ljava/lang/Object; // stack[0]: Ljava/lang/Object; mv.visitInsn(Opcodes.DUP_X1); // stack[2]: [Ljava/lang/Object; // stack[1]: Ljava/lang/Object; // stack[0]: [Ljava/lang/Object; mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z", false); mv.visitInsn(Opcodes.POP); // stack[0]: [Ljava/lang/Object; mv.visitInsn(Opcodes.ICONST_0); mv.visitInsn(Opcodes.AALOAD); // stack[0]: [Z mv.visitTypeInsn(Opcodes.CHECKCAST, InstrSupport.DATAFIELD_DESC); }
From source file:org.jacoco.core.runtime.ExecutionDataAccess.java
License:Open Source License
/** * Generates code that creates the argument array for the * <code>getExecutionData()</code> method. The array instance is left on the * operand stack. The generated code requires a stack size of 5. * //from w ww . j ava2 s .c om * @param classid * class identifier * @param classname * VM class name * @param probecount * probe count for this class * @param mv * visitor to emit generated code */ public static void generateArgumentArray(final long classid, final String classname, final int probecount, final MethodVisitor mv) { mv.visitInsn(Opcodes.ICONST_3); mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object"); // Class Id: mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_0); mv.visitLdcInsn(Long.valueOf(classid)); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;"); mv.visitInsn(Opcodes.AASTORE); // Class Name: mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_1); mv.visitLdcInsn(classname); mv.visitInsn(Opcodes.AASTORE); // Probe Count: mv.visitInsn(Opcodes.DUP); mv.visitInsn(Opcodes.ICONST_2); InstrSupport.push(mv, probecount); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;"); mv.visitInsn(Opcodes.AASTORE); }
From source file:org.jacoco.core.runtime.ExecutionDataAccess.java
License:Open Source License
/** * Generates the code that calls the runtime data access through the JRE API * method {@link Object#equals(Object)}. The code pops a {@link Object} * instance from the stack and pushes the probe array of type * <code>boolean[]</code> on the operand stack. The generated code requires * a stack size of 6.// w w w.j a va 2 s . c o m * * @param classid * @param classname * @param probecount * @param mv */ public static void generateAccessCall(final long classid, final String classname, final int probecount, final MethodVisitor mv) { // stack[0]: Ljava/lang/Object; generateArgumentArray(classid, classname, probecount, mv); // stack[1]: [Ljava/lang/Object; // stack[0]: Ljava/lang/Object; mv.visitInsn(Opcodes.DUP_X1); // stack[2]: [Ljava/lang/Object; // stack[1]: Ljava/lang/Object; // stack[0]: [Ljava/lang/Object; mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z"); mv.visitInsn(Opcodes.POP); // stack[0]: [Ljava/lang/Object; mv.visitInsn(Opcodes.ICONST_0); mv.visitInsn(Opcodes.AALOAD); // stack[0]: [Z mv.visitTypeInsn(Opcodes.CHECKCAST, InstrSupport.DATAFIELD_DESC); }
From source file:org.jacoco.core.runtime.LoggerRuntime.java
License:Open Source License
public int generateDataAccessor(final long classid, final String classname, final int probecount, final MethodVisitor mv) { // The data accessor performs the following steps: ////from w w w . ja v a 2 s . c o m // final Object[] args = new Object[3]; // args[0] = Long.valueOf(classid); // args[1] = classname; // args[2] = Integer.valueOf(probecount); // Logger.getLogger(CHANNEL).log(Level.INFO, key, args); // final byte[] probedata = (byte[]) args[0]; // // Note that local variable 'args' is used at two places. As were not // allowed to allocate local variables we have to keep this value with // DUP and SWAP operations on the operand stack. // 1. Create parameter array: RuntimeData.generateArgumentArray(classid, classname, probecount, mv); // Stack[0]: [Ljava/lang/Object; mv.visitInsn(Opcodes.DUP); // Stack[1]: [Ljava/lang/Object; // Stack[0]: [Ljava/lang/Object; // 2. Call Logger: mv.visitLdcInsn(CHANNEL); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/util/logging/Logger", "getLogger", "(Ljava/lang/String;)Ljava/util/logging/Logger;"); // Stack[2]: Ljava/util/logging/Logger; // Stack[1]: [Ljava/lang/Object; // Stack[0]: [Ljava/lang/Object; mv.visitInsn(Opcodes.SWAP); // Stack[2]: [Ljava/lang/Object; // Stack[1]: Ljava/util/logging/Logger; // Stack[0]: [Ljava/lang/Object; mv.visitFieldInsn(Opcodes.GETSTATIC, "java/util/logging/Level", "INFO", "Ljava/util/logging/Level;"); // Stack[3]: Ljava/util/logging/Level; // Stack[2]: [Ljava/lang/Object; // Stack[1]: Ljava/util/logging/Logger; // Stack[0]: [Ljava/lang/Object; mv.visitInsn(Opcodes.SWAP); // Stack[3]: [Ljava/lang/Object; // Stack[2]: Ljava/util/logging/Level; // Stack[1]: Ljava/util/logging/Logger; // Stack[0]: [Ljava/lang/Object; mv.visitLdcInsn(key); // Stack[4]: Ljava/lang/String; // Stack[3]: [Ljava/lang/Object; // Stack[2]: Ljava/util/logging/Level; // Stack[1]: Ljava/util/logging/Logger; // Stack[0]: [Ljava/lang/Object; mv.visitInsn(Opcodes.SWAP); // Stack[4]: [Ljava/lang/Object; // Stack[3]: Ljava/lang/String; // Stack[2]: Ljava/util/logging/Level; // Stack[1]: Ljava/util/logging/Logger; // Stack[0]: [Ljava/lang/Object; mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/logging/Logger", "log", "(Ljava/util/logging/Level;Ljava/lang/String;[Ljava/lang/Object;)V"); // Stack[0]: [Ljava/lang/Object; // 3. Load data structure from parameter array: mv.visitInsn(Opcodes.ICONST_0); mv.visitInsn(Opcodes.AALOAD); mv.visitTypeInsn(Opcodes.CHECKCAST, InstrSupport.DATAFIELD_DESC); // Stack[0]: [Z return 5; // Maximum local stack size is 5 }
From source file:org.jacoco.core.runtime.URLStreamHandlerRuntime.java
License:Open Source License
public int generateDataAccessor(final long classid, final String classname, final int probecount, final MethodVisitor mv) { // The data accessor performs the following steps: ////from w ww . j a va 2s . c o m // final URL url = new URL(protocol, null, ""); // final URLConnection connection = url.openConnection(); // final Object[] args = new Object[3]; // args[0] = Long.valueOf(classid); // args[1] = classname; // args[2] = Integer.valueOf(probecount); // connection.equals(args); // final byte[] probedata = (byte[]) args[0]; RuntimeData.generateArgumentArray(classid, classname, probecount, mv); mv.visitInsn(Opcodes.DUP); // Stack[1]: [Ljava/lang/Object; // Stack[0]: [Ljava/lang/Object; mv.visitTypeInsn(Opcodes.NEW, "java/net/URL"); mv.visitInsn(Opcodes.DUP); mv.visitLdcInsn(protocol); mv.visitInsn(Opcodes.ACONST_NULL); mv.visitLdcInsn(""); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/net/URL", "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); // Stack[2]: [Ljava/net/URL; // Stack[1]: [Ljava/lang/Object; // Stack[0]: [Ljava/lang/Object; mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/net/URL", "openConnection", "()Ljava/net/URLConnection;"); // Stack[2]: [Ljava/net/URLConnection; // Stack[1]: [Ljava/lang/Object; // Stack[0]: [Ljava/lang/Object; mv.visitInsn(Opcodes.SWAP); // Stack[2]: [Ljava/lang/Object; // Stack[1]: [Ljava/net/URLConnection; // Stack[0]: [Ljava/lang/Object; mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z"); // Stack[1]: Z; // Stack[0]: [Ljava/lang/Object; mv.visitInsn(Opcodes.POP); // Stack[0]: [Ljava/lang/Object; mv.visitInsn(Opcodes.ICONST_0); mv.visitInsn(Opcodes.AALOAD); mv.visitTypeInsn(Opcodes.CHECKCAST, InstrSupport.DATAFIELD_DESC); return 7; }