Skip to content

Commit 7ca0f0f

Browse files
authored
Opcodes.RET should be processed by visitVarInsn instead of visitInsn (#1512)
1 parent 048d4f8 commit 7ca0f0f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

org.jacoco.core.test/src/org/jacoco/core/internal/flow/LabelFlowAnalyzerTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,6 @@ private void testInsn(int opcode, boolean expected) {
264264
assertFalse(analyzer.first);
265265
}
266266

267-
@Test(expected = AssertionError.class)
268-
public void testVisitInsnNegative() {
269-
analyzer.visitInsn(RET);
270-
}
271-
272267
@Test
273268
public void testIntInsn() {
274269
analyzer.visitIntInsn(BIPUSH, 0);
@@ -283,6 +278,11 @@ public void testVarInsn() {
283278
assertFalse(analyzer.first);
284279
}
285280

281+
@Test(expected = AssertionError.class)
282+
public void testVisitVarInsnNegative() {
283+
analyzer.visitVarInsn(RET, 0);
284+
}
285+
286286
@Test
287287
public void testTypeInsn() {
288288
analyzer.visitTypeInsn(NEW, "java/lang/String");

org.jacoco.core/src/org/jacoco/core/internal/flow/LabelFlowAnalyzer.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ private static void setTargetIfNotDone(final Label label) {
137137
@Override
138138
public void visitInsn(final int opcode) {
139139
switch (opcode) {
140-
case Opcodes.RET:
141-
throw new AssertionError("Subroutines not supported.");
142140
case Opcodes.IRETURN:
143141
case Opcodes.LRETURN:
144142
case Opcodes.FRETURN:
@@ -163,6 +161,9 @@ public void visitIntInsn(final int opcode, final int operand) {
163161

164162
@Override
165163
public void visitVarInsn(final int opcode, final int var) {
164+
if (Opcodes.RET == opcode) {
165+
throw new AssertionError("Subroutines not supported.");
166+
}
166167
successor = true;
167168
first = false;
168169
}

0 commit comments

Comments
 (0)