Fix for interpreter crash on new instance of class
Rationale:
Fuzz testing found divergences between the compiler and interpreter
which turned out to be caused by calling instance on java.lang.Class
(this worked for compiler but crashed interpeter). Since RI does not
allow this construct, solution is to force interpreter in this
unlikely case and throw run time exception like RI. This fixes
two cases found with fuzz testing. CL also includes
fail-before/pass-after test.
Test: 600-verifier-fails
BUG=29758098
Change-Id: Ie80f7758def44e6655d28fec4c10c34ffa0fd60b
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h
index 7ecd595..68c954f 100644
--- a/runtime/entrypoints/entrypoint_utils-inl.h
+++ b/runtime/entrypoints/entrypoint_utils-inl.h
@@ -148,6 +148,11 @@
*slow_path = true;
return nullptr; // Failure
}
+ if (UNLIKELY(klass->IsClassClass())) {
+ ThrowIllegalAccessError(nullptr, "Class %s is inaccessible", PrettyDescriptor(klass).c_str());
+ *slow_path = true;
+ return nullptr; // Failure
+ }
mirror::Class* referrer = method->GetDeclaringClass();
if (UNLIKELY(!referrer->CanAccess(klass))) {
ThrowIllegalAccessErrorClass(referrer, klass);