aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2013-03-01 19:55:43 +0100
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2013-03-01 19:55:43 +0100
commit1b1935e739a09eb467c86036b480f513cd8bef4a (patch)
treea929cb38794574ca57aaa312139b64db69933732 /org.jacoco.core.test/src/org
parent5ae70c92dc9b39251fc4a96bac322ac29b28bd72 (diff)
downloadjacoco-1b1935e739a09eb467c86036b480f513cd8bef4a.tar.gz
Fixed inconsistent stackmap frames when instrumenting class files
produced by certain tools like ProGuard (GitHub #85).
Diffstat (limited to 'org.jacoco.core.test/src/org')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java69
1 files changed, 54 insertions, 15 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java
index e6f3ce1b..250aa14b 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java
@@ -209,25 +209,64 @@ public class ProbeInserterTest {
}
@Test
- public void testVisitFrameDeadCode() {
- ProbeInserter pi = new ProbeInserter(0, "(J)V", actualVisitor,
- arrayStrategy);
+ public void testVisitFrameNoLocals() {
+ ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "()V",
+ actualVisitor, arrayStrategy);
+
+ pi.visitFrame(Opcodes.F_NEW, 0, new Object[] {}, 0, new Object[0]);
+
+ expectedVisitor.visitFrame(Opcodes.F_NEW, 1, new Object[] { "[Z" }, 0,
+ new Object[0]);
+ }
+
+ @Test
+ public void testVisitFrameProbeAt0() {
+ ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "()V",
+ actualVisitor, arrayStrategy);
+
+ pi.visitFrame(Opcodes.F_NEW, 2, new Object[] { Opcodes.DOUBLE, "Foo" },
+ 0, new Object[0]);
- // Such sequences are generated by ASM to replace dead code, see
- // http://asm.ow2.org/doc/developer-guide.html#deadcode
- pi.visitFrame(Opcodes.F_NEW, 0, new Object[] {}, 1,
- new Object[] { "java/lang/Throwable" });
- pi.visitInsn(Opcodes.NOP);
- pi.visitInsn(Opcodes.NOP);
- pi.visitInsn(Opcodes.ATHROW);
+ expectedVisitor.visitFrame(Opcodes.F_NEW, 3, new Object[] { "[Z",
+ Opcodes.DOUBLE, "Foo" }, 0, new Object[0]);
+ }
+
+ @Test
+ public void testFillOneWord() {
+ ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "(I)V",
+ actualVisitor, arrayStrategy);
+
+ pi.visitFrame(Opcodes.F_NEW, 0, new Object[] {}, 0, new Object[] {});
+
+ // The locals in this frame are filled with TOP up to the probe variable
+ expectedVisitor.visitFrame(Opcodes.F_NEW, 2, new Object[] {
+ Opcodes.TOP, "[Z", }, 0, new Object[] {});
+ }
+
+ @Test
+ public void testFillTwoWord() {
+ ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "(J)V",
+ actualVisitor, arrayStrategy);
+
+ pi.visitFrame(Opcodes.F_NEW, 0, new Object[] {}, 0, new Object[] {});
// The locals in this frame are filled with TOP up to the probe variable
expectedVisitor.visitFrame(Opcodes.F_NEW, 3, new Object[] {
- Opcodes.TOP, Opcodes.TOP, "[Z", }, 1,
- new Object[] { "java/lang/Throwable" });
- expectedVisitor.visitInsn(Opcodes.NOP);
- expectedVisitor.visitInsn(Opcodes.NOP);
- expectedVisitor.visitInsn(Opcodes.ATHROW);
+ Opcodes.TOP, Opcodes.TOP, "[Z", }, 0, new Object[] {});
+ }
+
+ @Test
+ public void testFillPartly() {
+ ProbeInserter pi = new ProbeInserter(Opcodes.ACC_STATIC, "(DIJ)V",
+ actualVisitor, arrayStrategy);
+
+ pi.visitFrame(Opcodes.F_NEW, 1, new Object[] { Opcodes.DOUBLE }, 0,
+ new Object[] {});
+
+ // The locals in this frame are filled with TOP up to the probe variable
+ expectedVisitor.visitFrame(Opcodes.F_NEW, 5, new Object[] {
+ Opcodes.DOUBLE, Opcodes.TOP, Opcodes.TOP, Opcodes.TOP, "[Z", },
+ 0, new Object[] {});
}
@Test(expected = IllegalArgumentException.class)