Skip to content

Commit 2d93438

Browse files
committed
Prints invokeDynamic. See Konloch#66
1 parent 3dadae6 commit 2d93438

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.objectweb.asm.tree.IincInsnNode;
2020
import org.objectweb.asm.tree.InsnNode;
2121
import org.objectweb.asm.tree.IntInsnNode;
22+
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
2223
import org.objectweb.asm.tree.JumpInsnNode;
2324
import org.objectweb.asm.tree.LabelNode;
2425
import org.objectweb.asm.tree.LdcInsnNode;
@@ -128,6 +129,8 @@ public ArrayList<String> createPrint() {
128129
line = printTableSwitchInsnNode((TableSwitchInsnNode) ain);
129130
} else if (ain instanceof LookupSwitchInsnNode) {
130131
line = printLookupSwitchInsnNode((LookupSwitchInsnNode) ain);
132+
} else if (ain instanceof InvokeDynamicInsnNode) {
133+
line = printInvokeDynamicInsNode((InvokeDynamicInsnNode) ain);
131134
} else {
132135
line += "UNADDED OPCODE: " + nameOpcode(ain.opcode()) + " "
133136
+ ain.toString();
@@ -281,6 +284,29 @@ protected String printLookupSwitchInsnNode(LookupSwitchInsnNode lin) {
281284
return line;
282285
}
283286

287+
protected String printInvokeDynamicInsNode(InvokeDynamicInsnNode idin) {
288+
StringBuilder sb = new StringBuilder();
289+
sb.append(nameOpcode(idin.opcode()) + " " + idin.name + "(");
290+
291+
String desc = idin.desc;
292+
String partedDesc = idin.desc.substring(2);
293+
try {
294+
if(Type.getType(partedDesc) != null)
295+
desc = Type.getType(partedDesc).getClassName();
296+
297+
if (desc == null || desc.equals("null"))
298+
desc = idin.desc;
299+
} catch(java.lang.ArrayIndexOutOfBoundsException e) {
300+
301+
}
302+
303+
sb.append(desc);
304+
305+
sb.append(");");
306+
307+
return sb.toString();
308+
}
309+
284310
protected String nameOpcode(int opcode) {
285311
return " " + OpcodeInfo.OPCODES.get(opcode).toLowerCase();
286312
}

0 commit comments

Comments
 (0)