Do not place null check on unresolved method calls.
Rationale:
These invokes drop through the runtime anyway where various
checks are done, including null check. A few of these
checks need to occur before the null check.
With fail-before/pass-after smali test.
BUG=29068831
Change-Id: I260715e742365433a323598d97f7fdab321e8512
diff --git a/test/529-checker-unresolved/src/Main.java b/test/529-checker-unresolved/src/Main.java
index a934377..5a36ba5 100644
--- a/test/529-checker-unresolved/src/Main.java
+++ b/test/529-checker-unresolved/src/Main.java
@@ -114,19 +114,31 @@
expectEquals(o, c.instanceObject);
}
+ /// CHECK-START: void Main.callUnresolvedNull(UnresolvedClass) register (before)
+ /// CHECK-NOT: NullCheck
static public void callUnresolvedNull(UnresolvedClass c) {
int x = 0;
try {
x = c.instanceInt;
throw new Error("Expected NPE");
} catch (NullPointerException e) {
+ x -= 1;
}
- expectEquals(0, x);
+ expectEquals(-1, x);
try {
c.instanceInt = -1;
throw new Error("Expected NPE");
} catch (NullPointerException e) {
+ x -= 1;
}
+ expectEquals(-2, x);
+ try {
+ c.virtualMethod();
+ throw new Error("Expected NPE");
+ } catch (NullPointerException e) {
+ x -= 1;
+ }
+ expectEquals(-3, x);
}
static public void testInstanceOf(Object o) {