Commit 513766d4 authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

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

parent 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% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment