提交 513766d4 编写于 作者: A Ahmed Ashour 提交者: skylot

fix: remove field redundant array type when initialized (PR #567)

上级 79ccaada
......@@ -165,6 +165,10 @@ public class ExtractFieldInit extends AbstractVisitor {
// all checks passed
for (InitInfo info : infoList) {
for (InsnNode putInsn : info.getPutInsns()) {
InsnArg arg = putInsn.getArg(0);
if (arg instanceof InsnWrapArg) {
((InsnWrapArg) arg).getWrapInsn().add(AFlag.DECLARE_VAR);
}
InsnRemover.remove(info.getConstrMth(), putInsn);
}
}
......
package jadx.tests.integration.arrays;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
public class TestArrayInitField extends IntegrationTest {
public static class TestCls {
byte[] bytes = new byte[]{10, 20, 30};
}
@Test
public void test() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();
assertThat(code, containsString("= {10, 20, 30};"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册