Skip to content

Commit

Permalink
feat(objectionary#488): handle all opcodes up to 53 instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Mar 13, 2024
1 parent 0c24d6a commit fdae044
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ public int foo(int x) {
}
return 2;
}

public void sipush() {
short s = 256;
System.out.println(s);
}
}
2 changes: 1 addition & 1 deletion src/it/spring-fat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ SOFTWARE.
support many java features. We need to implement them and enable
the test.
-->
<disabled>true</disabled>
<disabled>false</disabled>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ private enum Instruction {
visitor.visitIntInsn(Opcodes.BIPUSH, (int) arguments.get(0))
),

/**
* Push a short onto the stack as an integer value.
*/
SIPUSH(Opcodes.SIPUSH, (visitor, arguments) ->
visitor.visitIntInsn(Opcodes.SIPUSH, (int) arguments.get(0))
),

/**
* Push a constant #index from a constant pool onto the stack.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,17 @@ void failsBecauseBytecodeIsBroken() {
"We expect an exception here because the bytecode is broken"
);
}

@Test
void returnsShortValue() {
Assertions.assertDoesNotThrow(
() -> new BytecodeClass("ShortValue")
.withMethod("j$foo", "()S", Opcodes.ACC_PUBLIC)
.opcode(Opcodes.SIPUSH, 256)
.opcode(Opcodes.IRETURN)
.up()
.bytecode(),
"We expect no exception here because all instructions are valid"
);
}
}

0 comments on commit fdae044

Please sign in to comment.