From 6722b966e685afb225b7372e771672d1d392c333 Mon Sep 17 00:00:00 2001 From: catsalty <23442547+catsalty@users.noreply.github.com> Date: Thu, 25 Jul 2024 19:16:23 +0800 Subject: [PATCH] [bugfix]fix TransformCallToStatic with invokeinterface or invokedynamic 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/javassist/convert/TransformCallToStatic.java b/src/main/javassist/convert/TransformCallToStatic.java index 6f1dfef3..a7b435d7 100644 --- a/src/main/javassist/convert/TransformCallToStatic.java +++ b/src/main/javassist/convert/TransformCallToStatic.java @@ -23,6 +23,9 @@ protected int match(int c, int pos, CodeIterator iterator, int typedesc, ConstPo } iterator.writeByte(Opcode.INVOKESTATIC, pos); iterator.write16bit(newIndex, pos + 1); + if (c == Opcode.INVOKEINTERFACE || c == Opcode.INVOKEDYNAMIC) { + iterator.writeByte(0, pos + 3); + } return pos; } }