11package club .bytecode .the .jda .decompilers .bytecode ;
22
3+ import club .bytecode .the .jda .api .ExceptionUI ;
34import org .apache .commons .lang3 .StringEscapeUtils ;
45import org .objectweb .asm .Type ;
56import org .objectweb .asm .tree .*;
6- import club .bytecode .the .jda .api .ExceptionUI ;
77
88import java .io .BufferedWriter ;
99import java .io .File ;
@@ -283,7 +283,9 @@ protected String printLookupSwitchInsnNode(LookupSwitchInsnNode lin) {
283283
284284 protected String printInvokeDynamicInsNode (InvokeDynamicInsnNode idin ) {
285285 StringBuilder sb = new StringBuilder ();
286- sb .append (nameOpcode (idin .opcode ())).append (" " ).append (idin .bsm .getName ()).append ("(" );
286+ final String bsmName = idin .bsm .getName ();
287+ final boolean isMetafactory = bsmName .equals ("metafactory" );
288+ sb .append (nameOpcode (idin .opcode ())).append (" " ).append (bsmName ).append ("<" );
287289
288290 String desc = idin .desc ;
289291 String partedDesc = idin .desc .substring (2 );
@@ -298,8 +300,32 @@ protected String printInvokeDynamicInsNode(InvokeDynamicInsnNode idin) {
298300 }
299301
300302 sb .append (desc );
303+ sb .append (">(\n " );
304+ Object [] bsmArgs = idin .bsmArgs ;
305+ for (int i = 0 ; i < bsmArgs .length ; i ++) {
306+ Object arg = bsmArgs [i ];
307+ sb .append (" " );
308+ sb .append (arg );
309+ if (i < bsmArgs .length - 1 ) {
310+ sb .append (", " );
311+ }
312+ if (isMetafactory ) {
313+ switch (i ) {
314+ case 0 :
315+ sb .append (" // caller" );
316+ break ;
317+ case 1 :
318+ sb .append (" // invokedName" );
319+ break ;
320+ case 2 :
321+ sb .append (" // invokedType" );
322+ break ;
323+ }
324+ }
325+ sb .append ("\n " );
326+ }
301327
302- sb .append (");" );
328+ sb .append (" );" );
303329
304330 return sb .toString ();
305331 }
@@ -334,4 +360,4 @@ public static void saveTo(File file, InstructionPrinter printer) {
334360 new ExceptionUI (e );
335361 }
336362 }
337- }
363+ }
0 commit comments