Skip to content

Commit d23d4bd

Browse files
committed
Annotate finally blocks
1 parent 1f3bf3b commit d23d4bd

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/main/java/the/bytecode/club/jda/decompilers/bytecode/InstructionPrinter.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,27 @@ public ArrayList<String> createPrint() {
105105
info.add("}");
106106

107107
line = printLabelnode((LabelNode) ain) + ":";
108+
int labelId = resolveLabel((LabelNode) ain);
108109

109110
if (parent.createLabelBrackets()) {
110111
if (!firstLabel)
111112
firstLabel = true;
112113
line += " {";
113114
}
114115

115-
if (parent.appendHandlerComments()) {
116-
List<Integer> handlerLabels = handlers[labels.get(ain) - 1];
117-
if (handlerLabels.size() > 0) {
118-
StringBuilder sb = new StringBuilder(line);
119-
sb.append(" // Handlers: ");
120-
for (int handler : handlerLabels) {
121-
sb.append("L").append(handler).append(" ");
122-
}
123-
line = sb.toString();
124-
}
116+
StringBuilder comment = new StringBuilder();
117+
List<Integer> handlerLabels = handlers[labels.get(ain) - 1];
118+
if (parent.appendHandlerComments() && handlerLabels.size() > 0) {
119+
comment.append("Handlers: ");
120+
}
121+
for (int handler : handlerLabels) {
122+
if (parent.appendHandlerComments())
123+
comment.append("L").append(handler).append(" ");
124+
if (handler == labelId && parent.createComments())
125+
comment.insert(0, "Finally block" + (parent.appendHandlerComments() ? ", " : ""));
126+
}
127+
if (comment.length() > 0) {
128+
line += " // " + comment;
125129
}
126130
} else if (ain instanceof TypeInsnNode) {
127131
line = printTypeInsnNode((TypeInsnNode) ain);

0 commit comments

Comments
 (0)