Skip to content

Commit

Permalink
fix: Checkcast not supporting array casts
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Sep 6, 2024
1 parent 96b4f98 commit 7d44c7d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ public void visitTypeInsn(ASTIdentifier type) {
ObjectType objectType = Types.instanceTypeFromInternalName(literal);
add(new AllocateInstruction(objectType));
} else if (opcode == CHECKCAST || opcode == INSTANCEOF) {
literal = adaptDescToInternalName("checkcast/instanceof", literal);
ObjectType objectType = Types.instanceTypeFromInternalName(literal);
literal = adaptDescToInternalNameOrArray(literal);
ObjectType objectType = Types.objectTypeFromInternalName(literal);
Instruction instruction = switch (opcode) {
case CHECKCAST -> new CheckCastInstruction(objectType);
case INSTANCEOF -> new InstanceofInstruction(objectType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,46 @@
{ E, J, J, Ljava/lang/Throwable; }
},
code: {
// Source code:
//
// try (ByteArrayOutputStream out = new ByteArrayOutputStream(1024)) {
// return "ret";
// } catch (Throwable x) {
// return "err";
// }
//
// Compiled code semantics:
//
// public static String foo(int i) {
// String string;
// ByteArrayOutputStream out = new ByteArrayOutputStream(i);
// try {
// // B
// string = "ret";
// }
// catch (Throwable xx) {
// // E
// try {
// // F
// try {
// out.close(); // G
// }
// catch (Throwable xxx) {
// // H
// xx.addSuppressed(xxx);
// }
// // I
// throw xx;
// }
// catch (Throwable x) {
// // K
// return "error";
// }
// }
// // C
// out.close();
// return string;
// }
A:
// try-start: range=[A-D] handler=J:java/lang/Throwable
new java/io/ByteArrayOutputStream
Expand Down

0 comments on commit 7d44c7d

Please sign in to comment.