Skip to content

Commit

Permalink
Opcodes.RET should be processed by visitVarInsn instead of `visit…
Browse files Browse the repository at this point in the history
…Insn` (#1512)
  • Loading branch information
Godin authored Sep 27, 2023
1 parent 048d4f8 commit 7ca0f0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,6 @@ private void testInsn(int opcode, boolean expected) {
assertFalse(analyzer.first);
}

@Test(expected = AssertionError.class)
public void testVisitInsnNegative() {
analyzer.visitInsn(RET);
}

@Test
public void testIntInsn() {
analyzer.visitIntInsn(BIPUSH, 0);
Expand All @@ -283,6 +278,11 @@ public void testVarInsn() {
assertFalse(analyzer.first);
}

@Test(expected = AssertionError.class)
public void testVisitVarInsnNegative() {
analyzer.visitVarInsn(RET, 0);
}

@Test
public void testTypeInsn() {
analyzer.visitTypeInsn(NEW, "java/lang/String");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ private static void setTargetIfNotDone(final Label label) {
@Override
public void visitInsn(final int opcode) {
switch (opcode) {
case Opcodes.RET:
throw new AssertionError("Subroutines not supported.");
case Opcodes.IRETURN:
case Opcodes.LRETURN:
case Opcodes.FRETURN:
Expand All @@ -163,6 +161,9 @@ public void visitIntInsn(final int opcode, final int operand) {

@Override
public void visitVarInsn(final int opcode, final int var) {
if (Opcodes.RET == opcode) {
throw new AssertionError("Subroutines not supported.");
}
successor = true;
first = false;
}
Expand Down

0 comments on commit 7ca0f0f

Please sign in to comment.