summaryrefslogtreecommitdiffstats
path: root/runtime/reflection_test.cc
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2014-06-24 14:35:40 +0200
committerSebastien Hertz <shertz@google.com>2014-07-10 17:03:15 +0200
commit4e99b3d8955131f3fc71aa113f0fa71f0092cb6f (patch)
treebcaf4e5119a74c836d8598e064a20cdead757efb /runtime/reflection_test.cc
parent5fa647d5f663033e4ed3d398aece1f8211d7f460 (diff)
downloadart-4e99b3d8955131f3fc71aa113f0fa71f0092cb6f.tar.gz
art-4e99b3d8955131f3fc71aa113f0fa71f0092cb6f.tar.bz2
art-4e99b3d8955131f3fc71aa113f0fa71f0092cb6f.zip
Add missing class initialization during compilation and tests
Adds missing class initialization during compilation and tests, especially java.lang.Class. Otherwise, we'd be able to execute code while the referring class is not initialized or initializing. Also adds mirror::Class::AssertInitializedOrInitializingInThread method to check class initialization when entering the interpreter: the called method's declaring class must either be initialized or be initializing by the current thread (other threads must be waiting for the class initialization to complete holding its lock). Note we only do this check in debug build. Bump oat version to force compilation. Bug: 15899971 Change-Id: I9a4edd3739a3ca4cf1c4929dcbb44cdf7a1ca1fe
Diffstat (limited to 'runtime/reflection_test.cc')
-rw-r--r--runtime/reflection_test.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/reflection_test.cc b/runtime/reflection_test.cc
index 3b66abee2a..abe68ef8d7 100644
--- a/runtime/reflection_test.cc
+++ b/runtime/reflection_test.cc
@@ -109,7 +109,16 @@ class ReflectionTest : public CommonCompilerTest {
: c->FindVirtualMethod(method_name, method_signature);
CHECK(method != nullptr);
- *receiver = (is_static ? nullptr : c->AllocObject(self));
+ if (is_static) {
+ *receiver = nullptr;
+ } else {
+ // Ensure class is initialized before allocating object
+ StackHandleScope<1> hs(self);
+ Handle<mirror::Class> h_class(hs.NewHandle(c));
+ bool initialized = class_linker_->EnsureInitialized(h_class, true, true);
+ CHECK(initialized);
+ *receiver = c->AllocObject(self);
+ }
// Start runtime.
bool started = runtime_->Start();