List of usage examples for org.objectweb.asm Opcodes NOP
int NOP
To view the source code for org.objectweb.asm Opcodes NOP.
Click Source Link
From source file:org.jacoco.core.internal.analysis.filter.EnumFilterTest.java
License:Open Source License
@Test public void testNonValueOf() { final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, 0, "valueOf", "()V", null, null); m.visitInsn(Opcodes.NOP); context.superClassName = "java/lang/Enum"; filter.filter(m, context, output);//w w w.j av a 2 s . c o m assertIgnored(); }
From source file:org.jacoco.core.internal.analysis.filter.EnumFilterTest.java
License:Open Source License
@Test public void testNonEnum() { final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, 0, "values", "()[LFoo;", null, null); m.visitInsn(Opcodes.NOP); filter.filter(m, context, output);/*from w w w . j a v a 2 s . co m*/ assertIgnored(); }
From source file:org.jacoco.core.internal.analysis.filter.FinallyFilterTest.java
License:Open Source License
/** * <pre>/* www. j ava 2 s . c o m*/ * try { * ... * if (...) { * ... * return; * } else { * ... * return; * } * } finally { * ... * } * </pre> */ @Test public void should_analyze_control_flow() { final Label start1 = new Label(); final Label end1 = new Label(); final Label start2 = new Label(); final Label end2 = new Label(); final Label finallyStart = new Label(); m.visitTryCatchBlock(start1, end1, finallyStart, null); m.visitTryCatchBlock(start2, end2, finallyStart, null); m.visitLabel(start1); // jump to another region associated with same handler: m.visitJumpInsn(Opcodes.IFEQ, start2); m.visitInsn(Opcodes.NOP); m.visitLabel(end1); m.visitInsn(Opcodes.NOP); // finally block shouldMergeLast(); m.visitInsn(Opcodes.RETURN); m.visitLabel(start2); m.visitInsn(Opcodes.NOP); m.visitLabel(end2); m.visitInsn(Opcodes.NOP); // finally block shouldMergeLast(); m.visitInsn(Opcodes.RETURN); m.visitLabel(finallyStart); m.visitVarInsn(Opcodes.ASTORE, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.NOP); // finally block shouldMergeLast(); m.visitVarInsn(Opcodes.ALOAD, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.ATHROW); shouldIgnoreLast(); execute(); }
From source file:org.jacoco.core.internal.analysis.filter.FinallyFilterTest.java
License:Open Source License
@Test public void javac_try_catch_finally() { final Label tryStart = new Label(); final Label tryEnd = new Label(); final Label catchStart = new Label(); final Label catchEnd = new Label(); final Label finallyStart = new Label(); final Label finallyEnd = new Label(); m.visitTryCatchBlock(tryStart, tryEnd, catchStart, "java/lang/Exception"); m.visitTryCatchBlock(catchStart, catchEnd, finallyStart, null); m.visitTryCatchBlock(tryStart, tryEnd, finallyStart, null); m.visitLabel(tryStart);/* ww w . j a v a 2 s .com*/ m.visitInsn(Opcodes.NOP); // try body m.visitLabel(tryEnd); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitJumpInsn(Opcodes.GOTO, finallyEnd); shouldIgnoreLast(); m.visitLabel(catchStart); m.visitInsn(Opcodes.NOP); // catch body m.visitLabel(catchEnd); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitInsn(Opcodes.ATHROW); m.visitLabel(finallyStart); m.visitVarInsn(Opcodes.ASTORE, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitVarInsn(Opcodes.ALOAD, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.ATHROW); shouldIgnoreLast(); m.visitLabel(finallyEnd); m.visitInsn(Opcodes.NOP); execute(); }
From source file:org.jacoco.core.internal.analysis.filter.FinallyFilterTest.java
License:Open Source License
@Test public void ecj_try_catch_finally() { final Label tryStart = new Label(); final Label tryEnd = new Label(); final Label catchStart = new Label(); final Label catchEnd = new Label(); final Label finallyStart = new Label(); final Label finallyEnd = new Label(); final Label after = new Label(); m.visitTryCatchBlock(tryStart, tryEnd, catchStart, "java/lang/Exception"); m.visitTryCatchBlock(tryStart, catchEnd, finallyStart, null); m.visitLabel(tryStart);//from ww w.java 2 s. com m.visitInsn(Opcodes.NOP); // try body m.visitLabel(tryEnd); m.visitJumpInsn(Opcodes.GOTO, finallyEnd); m.visitLabel(catchStart); m.visitInsn(Opcodes.POP); m.visitInsn(Opcodes.NOP); // catch body m.visitLabel(catchEnd); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitJumpInsn(Opcodes.GOTO, after); shouldIgnoreLast(); m.visitLabel(finallyStart); m.visitVarInsn(Opcodes.ASTORE, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitVarInsn(Opcodes.ALOAD, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.ATHROW); shouldIgnoreLast(); m.visitLabel(finallyEnd); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitLabel(after); m.visitInsn(Opcodes.NOP); execute(); }
From source file:org.jacoco.core.internal.analysis.filter.FinallyFilterTest.java
License:Open Source License
/** * javac 1.5 - 1.7/* www. ja v a 2 s .c om*/ */ @Test public void javac_empty_catch() { final Label tryStart = new Label(); final Label tryEnd = new Label(); final Label catchStart = new Label(); final Label catchEnd = new Label(); final Label finallyStart = new Label(); final Label finallyEnd = new Label(); m.visitTryCatchBlock(tryStart, tryEnd, catchStart, "java/lang/Exception"); m.visitTryCatchBlock(tryStart, tryEnd, finallyStart, null); m.visitTryCatchBlock(catchStart, catchEnd, finallyStart, null); // actually one more useless TryCatchBlock for ASTORE in finally m.visitLabel(tryStart); m.visitInsn(Opcodes.NOP); // try body m.visitLabel(tryEnd); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitJumpInsn(Opcodes.GOTO, finallyEnd); shouldIgnoreLast(); m.visitLabel(catchStart); m.visitVarInsn(Opcodes.ASTORE, 1); m.visitLabel(catchEnd); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitJumpInsn(Opcodes.GOTO, finallyEnd); shouldIgnoreLast(); m.visitLabel(finallyStart); m.visitVarInsn(Opcodes.ASTORE, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitVarInsn(Opcodes.ALOAD, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.ATHROW); shouldIgnoreLast(); m.visitLabel(finallyEnd); m.visitInsn(Opcodes.NOP); execute(); }
From source file:org.jacoco.core.internal.analysis.filter.FinallyFilterTest.java
License:Open Source License
/** * javac >= 1.8//www . j av a2s .c om * * Probably related to https://bugs.openjdk.java.net/browse/JDK-7093325 */ @Test public void javac_8_empty_catch() throws Exception { final Label tryStart = new Label(); final Label tryEnd = new Label(); final Label catchStart = new Label(); final Label finallyStart = new Label(); final Label finallyEnd = new Label(); m.visitTryCatchBlock(tryStart, tryEnd, catchStart, "java/lang/Exception"); m.visitTryCatchBlock(tryStart, tryEnd, finallyStart, null); m.visitLabel(tryStart); m.visitInsn(Opcodes.NOP); // try body m.visitLabel(tryEnd); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitJumpInsn(Opcodes.GOTO, finallyEnd); shouldIgnoreLast(); shouldIgnoreLast(); m.visitLabel(catchStart); m.visitVarInsn(Opcodes.ASTORE, 1); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitJumpInsn(Opcodes.GOTO, finallyEnd); shouldIgnoreLast(); m.visitLabel(finallyStart); m.visitVarInsn(Opcodes.ASTORE, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitVarInsn(Opcodes.ALOAD, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.ATHROW); shouldIgnoreLast(); m.visitLabel(finallyEnd); execute(); }
From source file:org.jacoco.core.internal.analysis.filter.FinallyFilterTest.java
License:Open Source License
@Test public void ecj_empty_catch() { final Label tryStart = new Label(); final Label tryEnd = new Label(); final Label catchStart = new Label(); final Label catchEnd = new Label(); final Label finallyStart = new Label(); final Label finallyEnd = new Label(); final Label after = new Label(); m.visitTryCatchBlock(tryStart, tryEnd, catchStart, "java/lang/Exception"); m.visitTryCatchBlock(tryStart, catchEnd, finallyStart, null); m.visitLabel(tryStart);// w w w .j a v a 2s .c om m.visitInsn(Opcodes.NOP); // try body m.visitLabel(tryEnd); m.visitJumpInsn(Opcodes.GOTO, finallyEnd); m.visitLabel(catchStart); m.visitInsn(Opcodes.POP); m.visitLabel(catchEnd); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitJumpInsn(Opcodes.GOTO, after); shouldIgnoreLast(); m.visitLabel(finallyStart); m.visitVarInsn(Opcodes.ASTORE, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitVarInsn(Opcodes.ALOAD, 1); shouldIgnoreLast(); m.visitInsn(Opcodes.ATHROW); shouldIgnoreLast(); m.visitLabel(finallyEnd); m.visitInsn(Opcodes.NOP); // finally body shouldMergeLast(); m.visitLabel(after); m.visitInsn(Opcodes.NOP); execute(); }
From source file:org.jacoco.core.internal.analysis.filter.FinallyFilterTest.java
License:Open Source License
@Test public void javac_always_completes_abruptly() { final Label tryStart = new Label(); final Label tryEnd = new Label(); final Label finallyStart = new Label(); m.visitTryCatchBlock(tryStart, tryEnd, finallyStart, null); m.visitLabel(tryStart);/*from w w w .j av a2 s .c om*/ m.visitInsn(Opcodes.NOP); // try body m.visitLabel(tryEnd); m.visitInsn(Opcodes.RETURN); // finally body m.visitLabel(finallyStart); m.visitVarInsn(Opcodes.ASTORE, 1); m.visitInsn(Opcodes.RETURN); // finally body execute(); }
From source file:org.jacoco.core.internal.analysis.filter.FinallyFilterTest.java
License:Open Source License
@Test public void ecj_always_completes_abruptly() { final Label tryStart = new Label(); final Label tryEnd = new Label(); final Label finallyStart = new Label(); m.visitTryCatchBlock(tryStart, tryEnd, tryEnd, null); m.visitLabel(tryStart);//w w w . j av a2 s.c o m m.visitInsn(Opcodes.NOP); // try body m.visitJumpInsn(Opcodes.GOTO, finallyStart); m.visitLabel(tryEnd); m.visitInsn(Opcodes.POP); m.visitLabel(finallyStart); m.visitInsn(Opcodes.RETURN); // finally body execute(); }