diff --git a/jasm-composition-jvm/src/main/java/me/darknet/assembler/compile/visitor/BlwCodeVisitor.java b/jasm-composition-jvm/src/main/java/me/darknet/assembler/compile/visitor/BlwCodeVisitor.java index 02c9a79..f2a8d30 100644 --- a/jasm-composition-jvm/src/main/java/me/darknet/assembler/compile/visitor/BlwCodeVisitor.java +++ b/jasm-composition-jvm/src/main/java/me/darknet/assembler/compile/visitor/BlwCodeVisitor.java @@ -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); diff --git a/jasm-composition-jvm/src/test/resources/samples/jasm/Example-try-with-resources.jasm b/jasm-composition-jvm/src/test/resources/samples/jasm/Example-try-with-resources.jasm index 2e22ca8..31347ca 100644 --- a/jasm-composition-jvm/src/test/resources/samples/jasm/Example-try-with-resources.jasm +++ b/jasm-composition-jvm/src/test/resources/samples/jasm/Example-try-with-resources.jasm @@ -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