test: another deboxing issue
This commit is contained in:
@@ -98,13 +98,20 @@ public class DeboxingVisitor extends AbstractVisitor {
|
||||
arg.add(AFlag.EXPLICIT_PRIMITIVE_TYPE);
|
||||
}
|
||||
arg.setType(primitiveType);
|
||||
boolean forbidInline;
|
||||
if (canChangeTypeToPrimitive(resArg)) {
|
||||
resArg.setType(primitiveType);
|
||||
forbidInline = false;
|
||||
} else {
|
||||
forbidInline = true;
|
||||
}
|
||||
|
||||
InsnNode constInsn = new InsnNode(InsnType.CONST, 1);
|
||||
constInsn.addArg(arg);
|
||||
constInsn.setResult(resArg);
|
||||
if (forbidInline) {
|
||||
constInsn.add(AFlag.DONT_INLINE);
|
||||
}
|
||||
return constInsn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,5 @@ public class TestDeboxing3 extends IntegrationTest {
|
||||
|
||||
assertThat(code, containsOne("Pair<Long, String> pair = this.cache.get(id);"));
|
||||
assertThat(code, containsOne("return pair.first + l > System.currentTimeMillis();"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package jadx.tests.integration.others;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jadx.NotYetImplemented;
|
||||
import jadx.core.dex.nodes.ClassNode;
|
||||
import jadx.tests.api.IntegrationTest;
|
||||
|
||||
import static jadx.tests.api.utils.JadxMatchers.containsOne;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
public class TestDeboxing4 extends IntegrationTest {
|
||||
|
||||
public static class TestCls {
|
||||
|
||||
public boolean test(Integer i) {
|
||||
return ((Integer) 1).equals(i);
|
||||
}
|
||||
|
||||
public void check() {
|
||||
assertThat(test(null), Matchers.is(false));
|
||||
assertThat(test(0), Matchers.is(false));
|
||||
assertThat(test(1), Matchers.is(true));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
noDebugInfo();
|
||||
|
||||
ClassNode cls = getClassNode(TestCls.class);
|
||||
String code = cls.getCode().toString();
|
||||
|
||||
assertThat(code, not(containsString("return 1.equals(num);")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@NotYetImplemented("Inline boxed types")
|
||||
public void testInline() {
|
||||
noDebugInfo();
|
||||
|
||||
ClassNode cls = getClassNode(TestCls.class);
|
||||
String code = cls.getCode().toString();
|
||||
|
||||
assertThat(code, containsOne("return ((Integer) 1).equals(i);"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user