summaryrefslogtreecommitdiff
path: root/test/529-checker-unresolved/src/Main.java
diff options
context:
space:
mode:
author Aart Bik <ajcbik@google.com> 2016-06-02 17:53:58 -0700
committer Aart Bik <ajcbik@google.com> 2016-06-03 14:32:49 -0700
commit1415413bddb3a9cd9432de3381ef27e5181e58cc (patch)
treec3f6e6593cbd93ee4f04683548bcf7e014ee1dcc /test/529-checker-unresolved/src/Main.java
parent3f432d5a7c184b7580bd5aba27158c1455c328ff (diff)
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
Diffstat (limited to 'test/529-checker-unresolved/src/Main.java')
-rw-r--r--test/529-checker-unresolved/src/Main.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/529-checker-unresolved/src/Main.java b/test/529-checker-unresolved/src/Main.java
index 872fa6d0dd..a934377ddf 100644
--- a/test/529-checker-unresolved/src/Main.java
+++ b/test/529-checker-unresolved/src/Main.java
@@ -114,6 +114,21 @@ public class Main extends UnresolvedSuperClass {
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 @@ public class Main extends UnresolvedSuperClass {
callInvokeUnresolvedSuper(m);
callUnresolvedStaticFieldAccess();
callUnresolvedInstanceFieldAccess(c);
+ callUnresolvedNull(null);
testInstanceOf(m);
testCheckCast(m);
testLicm(2);
@@ -185,7 +201,7 @@ public class Main extends UnresolvedSuperClass {
}
}
- 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);
}