]> source.dussan.org Git - javassist.git/commitdiff
[bugfix]fix TransformCallToStatic with invokeinterface or invokedynamic
authorcatsalty <23442547+catsalty@users.noreply.github.com>
Thu, 25 Jul 2024 11:16:23 +0000 (19:16 +0800)
committerGitHub <noreply@github.com>
Thu, 25 Jul 2024 11:16:23 +0000 (19:16 +0800)
Replacing invokeinterface or invokedynamic with invokestatic will result in a missing instruction. This solution can fix the problem.
Reference document:
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokestatic
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokedynamic
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.invokeinterface

src/main/javassist/convert/TransformCallToStatic.java

index 6f1dfef34514e260cd729a4212311a844e7f6438..a7b435d755e0e554092690eb04795705beb74288 100644 (file)
@@ -23,6 +23,9 @@ public class TransformCallToStatic extends TransformCall {
         }
         iterator.writeByte(Opcode.INVOKESTATIC, pos);
         iterator.write16bit(newIndex, pos + 1);
+        if (c == Opcode.INVOKEINTERFACE || c == Opcode.INVOKEDYNAMIC) {
+            iterator.writeByte(0, pos + 3);
+        }
         return pos;
     }
 }