Merge "ART: Relax verifier checks"
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 9bcbdbd..55d1720 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -4258,7 +4258,7 @@
       }
     } else if (!array_type.IsArrayTypes()) {
       Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "not array type " << array_type << " with aget";
-    } else if (array_type.IsUnresolvedTypes()) {
+    } else if (array_type.IsUnresolvedMergedReference()) {
       // Unresolved array types must be reference array types.
       if (is_primitive) {
         Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "reference array type " << array_type
@@ -4266,6 +4266,10 @@
       } else {
         Fail(VERIFY_ERROR_NO_CLASS) << "cannot verify aget for " << array_type
             << " because of missing class";
+        // Approximate with java.lang.Object[].
+        work_line_->SetRegisterType<LockOp::kClear>(this,
+                                                    inst->VRegA_23x(),
+                                                    reg_types_.JavaLangObject(false));
       }
     } else {
       /* verify the class */
@@ -4377,7 +4381,7 @@
       work_line_->VerifyRegisterType(this, inst->VRegA_23x(), *modified_reg_type);
     } else if (!array_type.IsArrayTypes()) {
       Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "not array type " << array_type << " with aput";
-    } else if (array_type.IsUnresolvedTypes()) {
+    } else if (array_type.IsUnresolvedMergedReference()) {
       // Unresolved array types must be reference array types.
       if (is_primitive) {
         Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "put insn has type '" << insn_type
diff --git a/runtime/verifier/reg_type.cc b/runtime/verifier/reg_type.cc
index bd0308b..308c2aa 100644
--- a/runtime/verifier/reg_type.cc
+++ b/runtime/verifier/reg_type.cc
@@ -878,7 +878,7 @@
     return false;
   }
 
-  if (IsUnresolvedTypes() || src.IsUnresolvedTypes()) {
+  if (IsUnresolvedMergedReference() || src.IsUnresolvedMergedReference()) {
     // An unresolved array type means that it's an array of some reference type. Reference arrays
     // can never be assigned to primitive-type arrays, and vice versa. So it is a soft error if
     // both arrays are reference arrays, otherwise a hard error.
diff --git a/runtime/verifier/reg_type_cache.cc b/runtime/verifier/reg_type_cache.cc
index 208ef51..71c2a90 100644
--- a/runtime/verifier/reg_type_cache.cc
+++ b/runtime/verifier/reg_type_cache.cc
@@ -611,7 +611,7 @@
   if (!array.IsArrayTypes()) {
     return Conflict();
   } else if (array.IsUnresolvedTypes()) {
-    DCHECK(!array.IsUnresolvedTypes());  // Caller must make sure not to ask for this.
+    DCHECK(!array.IsUnresolvedMergedReference());  // Caller must make sure not to ask for this.
     const std::string descriptor(array.GetDescriptor().as_string());
     return FromDescriptor(loader, descriptor.c_str() + 1, false);
   } else {
diff --git a/test/800-smali/expected.txt b/test/800-smali/expected.txt
index 5a3857d..c2a9a31 100644
--- a/test/800-smali/expected.txt
+++ b/test/800-smali/expected.txt
@@ -65,4 +65,5 @@
 b/27799205 (3)
 b/27799205 (4)
 b/27799205 (5)
+b/27799205 (6)
 Done!
diff --git a/test/800-smali/smali/b_27799205_6.smali b/test/800-smali/smali/b_27799205_6.smali
new file mode 100644
index 0000000..d0154f7
--- /dev/null
+++ b/test/800-smali/smali/b_27799205_6.smali
@@ -0,0 +1,24 @@
+.class public LB27799205_6;
+.super Ljava/lang/Object;
+
+# A class with an unresolved array type should not fail hard (unless it's a primitive-type access).
+# Make sure that non-merged types still work.
+
+.method public static run()V
+.registers 1
+       return-void
+.end method
+
+# Use some non-resolvable array type.
+.method public static test([Ldo/not/resolve/K;)Ldo/not/resolve/K;
+.registers 3
+       const v0, 0
+       const v1, 0
+       # v2 = p0
+
+       # v0 := v2[v1]
+       aget-object v0, v2, v1
+
+       return-object v0
+
+.end method
diff --git a/test/800-smali/smali/b_27799205_helper.smali b/test/800-smali/smali/b_27799205_helper.smali
index 145c93d..e6d0985 100644
--- a/test/800-smali/smali/b_27799205_helper.smali
+++ b/test/800-smali/smali/b_27799205_helper.smali
@@ -38,3 +38,10 @@
 
        return-void
 .end method
+
+.method public static run6()V
+.registers 1
+       invoke-static {}, LB27799205_6;->run()V
+
+       return-void
+.end method
diff --git a/test/800-smali/src/Main.java b/test/800-smali/src/Main.java
index 20c3065..2001cb4 100644
--- a/test/800-smali/src/Main.java
+++ b/test/800-smali/src/Main.java
@@ -173,6 +173,7 @@
                 new VerifyError(), null));
         testCases.add(new TestCase("b/27799205 (5)", "B27799205Helper", "run5", null,
                 new VerifyError(), null));
+        testCases.add(new TestCase("b/27799205 (6)", "B27799205Helper", "run6", null, null, null));
     }
 
     public void runTests() {