@Test public void testNoFramePaddingInsn() throws Exception { Method method = MethodVisitor.class.getDeclaredMethod(name, type); FramePaddingMethodVisitor visitor = new FramePaddingMethodVisitor(methodVisitor); visitor.visitFrame(0, 0, null, 0, null); method.invoke(visitor, argument); visitor.visitFrame(0, 0, null, 0, null); method.invoke(verify(methodVisitor), argument); verify(methodVisitor, times(2)).visitFrame(0, 0, null, 0, null); verifyNoMoreInteractions(methodVisitor); }
@Override public void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack) { if (padding) { super.visitInsn(Opcodes.NOP); } else { padding = true; } super.visitFrame(type, numLocal, local, numStack, stack); }
FramePaddingMethodVisitor extends MethodVisitor { @Override public void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack) { if (padding) { super.visitInsn(Opcodes.NOP); } else { padding = true; } super.visitFrame(type, numLocal, local, numStack, stack); } }
FramePaddingMethodVisitor extends MethodVisitor { @Override public void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack) { if (padding) { super.visitInsn(Opcodes.NOP); } else { padding = true; } super.visitFrame(type, numLocal, local, numStack, stack); } FramePaddingMethodVisitor(MethodVisitor methodVisitor); }
FramePaddingMethodVisitor extends MethodVisitor { @Override public void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack) { if (padding) { super.visitInsn(Opcodes.NOP); } else { padding = true; } super.visitFrame(type, numLocal, local, numStack, stack); } FramePaddingMethodVisitor(MethodVisitor methodVisitor); @Override void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack); @Override void visitInsn(int opcode); @Override void visitIntInsn(int opcode, int operand); @Override void visitVarInsn(int opcode, int offset); @Override void visitTypeInsn(int opcode, String type); @Override void visitFieldInsn(int opcode, String owner, String name, String descriptor); @Override @SuppressWarnings("deprecation") void visitMethodInsn(int opcode, String owner, String name, String descriptor); @Override void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface); @Override void visitInvokeDynamicInsn(String name, String descriptor, Handle handle, Object... argument); @Override void visitJumpInsn(int opcode, Label label); @Override void visitLdcInsn(Object value); @Override void visitIincInsn(int offset, int increment); @Override void visitTableSwitchInsn(int min, int max, Label dflt, Label... label); @Override void visitLookupSwitchInsn(Label dflt, int[] key, Label[] label); @Override void visitMultiANewArrayInsn(String descriptor, int dimensions); }
FramePaddingMethodVisitor extends MethodVisitor { @Override public void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack) { if (padding) { super.visitInsn(Opcodes.NOP); } else { padding = true; } super.visitFrame(type, numLocal, local, numStack, stack); } FramePaddingMethodVisitor(MethodVisitor methodVisitor); @Override void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack); @Override void visitInsn(int opcode); @Override void visitIntInsn(int opcode, int operand); @Override void visitVarInsn(int opcode, int offset); @Override void visitTypeInsn(int opcode, String type); @Override void visitFieldInsn(int opcode, String owner, String name, String descriptor); @Override @SuppressWarnings("deprecation") void visitMethodInsn(int opcode, String owner, String name, String descriptor); @Override void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface); @Override void visitInvokeDynamicInsn(String name, String descriptor, Handle handle, Object... argument); @Override void visitJumpInsn(int opcode, Label label); @Override void visitLdcInsn(Object value); @Override void visitIincInsn(int offset, int increment); @Override void visitTableSwitchInsn(int min, int max, Label dflt, Label... label); @Override void visitLookupSwitchInsn(Label dflt, int[] key, Label[] label); @Override void visitMultiANewArrayInsn(String descriptor, int dimensions);  }