fix: correct args shift for instance invoke-custom (#1816)
This commit is contained in:
@@ -1014,9 +1014,10 @@ public class InsnGen {
|
||||
// force set external arg names into call method args
|
||||
int extArgsCount = customNode.getArgsCount();
|
||||
int startArg = customNode.getHandleType() == MethodHandleType.INVOKE_STATIC ? 0 : 1; // skip 'this' arg
|
||||
int callArg = 0;
|
||||
for (int i = startArg; i < extArgsCount; i++) {
|
||||
RegisterArg extArg = (RegisterArg) customNode.getArg(i);
|
||||
RegisterArg callRegArg = callArgs.get(i);
|
||||
RegisterArg callRegArg = callArgs.get(callArg++);
|
||||
callRegArg.getSVar().setCodeVar(extArg.getSVar().getCodeVar());
|
||||
}
|
||||
code.add(" -> {");
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package jadx.tests.integration.java8;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jadx.tests.api.IntegrationTest;
|
||||
|
||||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat;
|
||||
|
||||
public class TestLambdaInstance2 extends IntegrationTest {
|
||||
|
||||
public static class TestCls {
|
||||
private String field;
|
||||
|
||||
public Runnable test(String str, int i) {
|
||||
return () -> call(str, i);
|
||||
}
|
||||
|
||||
public void call(String str, int i) {
|
||||
field = str + '=' + i;
|
||||
}
|
||||
|
||||
public void check() throws Exception {
|
||||
field = "";
|
||||
test("num", 7).run();
|
||||
assertThat(field).isEqualTo("num=7");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
assertThat(getClassNode(TestCls.class))
|
||||
.code()
|
||||
.doesNotContain("lambda$")
|
||||
.containsOne("call(str, i)");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user