Do not place null check from unresolved field access.
Rationale:
These accesses go though the runtime anyway where various
checks are done, including null check. Since particular
checks, like access checks, need to occur prior to the
null check (to ensure link errors are not masked by
a null reference), the explicit null check should not
occur in the HIR.
BUG=29068831
Change-Id: I30fc9cb8cf4993e4176e235ceba3a38aef98d503
diff --git a/test/529-checker-unresolved/src/Main.java b/test/529-checker-unresolved/src/Main.java
index 872fa6d..a934377 100644
--- a/test/529-checker-unresolved/src/Main.java
+++ b/test/529-checker-unresolved/src/Main.java
@@ -114,6 +114,21 @@
expectEquals(o, c.instanceObject);
}
+ static public void callUnresolvedNull(UnresolvedClass c) {
+ int x = 0;
+ try {
+ x = c.instanceInt;
+ throw new Error("Expected NPE");
+ } catch (NullPointerException e) {
+ }
+ expectEquals(0, x);
+ try {
+ c.instanceInt = -1;
+ throw new Error("Expected NPE");
+ } catch (NullPointerException e) {
+ }
+ }
+
static public void testInstanceOf(Object o) {
if (o instanceof UnresolvedSuperClass) {
System.out.println("instanceof ok");
@@ -136,6 +151,7 @@
callInvokeUnresolvedSuper(m);
callUnresolvedStaticFieldAccess();
callUnresolvedInstanceFieldAccess(c);
+ callUnresolvedNull(null);
testInstanceOf(m);
testCheckCast(m);
testLicm(2);
@@ -185,7 +201,7 @@
}
}
- public static void expectEquals(float expected, float result) {
+ public static void expectEquals(float expected, float result) {
if (expected != result) {
throw new Error("Expected: " + expected + ", found: " + result);
}