Avoid verifier crash for quickened invoke on null.
When verifying an invoke-virtual-quick on a "null" instance, we can't infer the
class of the method being invoked. This CL handles this case and avoid a crash
due to a failed check in RegType::GetClass.
Also revert changes made to test 082-inline-execute since it succeeds with this
CL now.
Bug: 11427954
Change-Id: I4b2c1deaa43b144684539acea471543716f36fb3
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 7d2ee19..6632681 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -3140,6 +3140,8 @@
const RegType& actual_arg_type = reg_line->GetInvocationThis(inst, is_range);
if (actual_arg_type.IsConflict()) { // GetInvocationThis failed.
return NULL;
+ } else if (actual_arg_type.IsZero()) { // Invoke on "null" instance: we can't go further.
+ return NULL;
}
mirror::Class* this_class = NULL;
if (!actual_arg_type.IsUnresolvedTypes()) {
diff --git a/test/082-inline-execute/src/Main.java b/test/082-inline-execute/src/Main.java
index b881b34..f4d2dd1 100644
--- a/test/082-inline-execute/src/Main.java
+++ b/test/082-inline-execute/src/Main.java
@@ -37,10 +37,6 @@
test_String_length();
}
- private static String nullString() {
- return null;
- }
-
public static void test_String_length() {
String str0 = "";
String str1 = "x";
@@ -50,7 +46,7 @@
Assert.assertEquals(str1.length(), 1);
Assert.assertEquals(str80.length(), 80);
- String strNull = nullString();
+ String strNull = null;
try {
strNull.length();
Assert.fail();
@@ -65,7 +61,7 @@
Assert.assertTrue(str0.isEmpty());
Assert.assertFalse(str1.isEmpty());
- String strNull = nullString();
+ String strNull = null;
try {
strNull.isEmpty();
Assert.fail();
@@ -92,7 +88,7 @@
} catch (StringIndexOutOfBoundsException expected) {
}
- String strNull = nullString();
+ String strNull = null;
try {
strNull.charAt(0);
Assert.fail();
@@ -137,7 +133,7 @@
Assert.assertEquals(str40.indexOf('a',10), 10);
Assert.assertEquals(str40.indexOf('b',40), -1);
- String strNull = nullString();
+ String strNull = null;
try {
strNull.indexOf('a');
Assert.fail();