Skip to content

Commit

Permalink
fix: ignore not generated insns in CodeShrinker visitor (PR #560)
Browse files Browse the repository at this point in the history
  • Loading branch information
asashour authored and skylot committed Apr 8, 2019
1 parent 058e4c9 commit 7b18d3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 9 additions & 1 deletion jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import java.util.List;
import java.util.Objects;

import org.jetbrains.annotations.Nullable;

import com.android.dx.io.instructions.DecodedInstruction;
import com.rits.cloning.Cloner;
import org.jetbrains.annotations.Nullable;

import jadx.core.dex.attributes.AFlag;
import jadx.core.dex.attributes.nodes.LineAttrNode;
import jadx.core.dex.instructions.InsnType;
import jadx.core.dex.instructions.args.ArgType;
Expand Down Expand Up @@ -195,6 +197,12 @@ public boolean isConstInsn() {
}

public boolean canReorder() {
if (contains(AFlag.DONT_GENERATE)) {
if (getType() == InsnType.MONITOR_EXIT) {
return false;
}
return true;
}
switch (getType()) {
case CONST:
case CONST_STR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import org.junit.jupiter.api.Test;

import jadx.NotYetImplemented;
import jadx.core.dex.nodes.ClassNode;
import jadx.tests.api.IntegrationTest;

Expand Down Expand Up @@ -59,14 +58,7 @@ public void test() {
String code = cls.getCode().toString();

assertThat(code, containsOne("decode(inputStream);"));
}

@Test
@NotYetImplemented
public void test2() {
ClassNode cls = getClassNode(TestCls.class);
String code = cls.getCode().toString();

assertThat(code, containsOne("return new Result(400);"));
assertThat(code, not(containsOne("result =")));
}
}

0 comments on commit 7b18d3a

Please sign in to comment.