@Test public void probeByteCodeDebug() { PrintStream sysOut = mock(PrintStream.class); System.out.println("Sysout hijack!"); PrintStream oldPrintStream = System.out; try { System.setOut(sysOut); InvokeInstruction ins = mock(InvokeInstruction.class); ConstantPoolGen cpg = mock(ConstantPoolGen.class); when(ins.getClassName(Matchers.<ConstantPoolGen>any())).thenReturn("ClassTest"); when(ins.getMethodName(Matchers.<ConstantPoolGen>any())).thenReturn("method"); when(ins.getSignature(Matchers.<ConstantPoolGen>any())).thenReturn("(Lsignature)Lblah"); ByteCode.printOpCode(ins, cpg); verify(sysOut, atLeastOnce()).println(contains("ClassTest.method")); } finally { System.setOut(oldPrintStream); System.out.println("Sysout is back!"); } }
public static void printOpCode(InstructionHandle insHandle, ConstantPoolGen cpg) { System.out.print("[" + String.format("%02d", insHandle.getPosition()) + "] "); printOpCode(insHandle.getInstruction(),cpg); }
ByteCode { public static void printOpCode(InstructionHandle insHandle, ConstantPoolGen cpg) { System.out.print("[" + String.format("%02d", insHandle.getPosition()) + "] "); printOpCode(insHandle.getInstruction(),cpg); } }
ByteCode { public static void printOpCode(InstructionHandle insHandle, ConstantPoolGen cpg) { System.out.print("[" + String.format("%02d", insHandle.getPosition()) + "] "); printOpCode(insHandle.getInstruction(),cpg); }  }
ByteCode { public static void printOpCode(InstructionHandle insHandle, ConstantPoolGen cpg) { System.out.print("[" + String.format("%02d", insHandle.getPosition()) + "] "); printOpCode(insHandle.getInstruction(),cpg); }  static void printOpCode(InstructionHandle insHandle, ConstantPoolGen cpg); static void printOpCode(Instruction ins, ConstantPoolGen cpg); static T getConstantLDC(InstructionHandle h, ConstantPoolGen cpg, Class<T> clazz); static Integer getConstantInt(InstructionHandle h); static Number getPushNumber(InstructionHandle h); static T getPrevInstruction(InstructionHandle startHandle, Class<T> clazz); }
ByteCode { public static void printOpCode(InstructionHandle insHandle, ConstantPoolGen cpg) { System.out.print("[" + String.format("%02d", insHandle.getPosition()) + "] "); printOpCode(insHandle.getInstruction(),cpg); }  static void printOpCode(InstructionHandle insHandle, ConstantPoolGen cpg); static void printOpCode(Instruction ins, ConstantPoolGen cpg); static T getConstantLDC(InstructionHandle h, ConstantPoolGen cpg, Class<T> clazz); static Integer getConstantInt(InstructionHandle h); static Number getPushNumber(InstructionHandle h); static T getPrevInstruction(InstructionHandle startHandle, Class<T> clazz);  }