summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-03-11 13:24:35 -0700
committerAndreas Gampe <agampe@google.com>2015-03-11 13:24:35 -0700
commit0f7e3d6a39a1ffb78a69ff5abaca24e32422a82c (patch)
treee6c96380fbdfeb8089f0257ad3923622a5657d4b /runtime/interpreter
parent58e278861e2dd77f32a23e75c72028e3657c7066 (diff)
downloadart-0f7e3d6a39a1ffb78a69ff5abaca24e32422a82c.zip
art-0f7e3d6a39a1ffb78a69ff5abaca24e32422a82c.tar.gz
art-0f7e3d6a39a1ffb78a69ff5abaca24e32422a82c.tar.bz2
ART: Fix finalizable class in Unstarted Runtime
Add a finalizable check for emulation of Class.newInstance, as this is not allowed in transactional mode. Change-Id: I9633929bf484ac8807b97209ab4b422c320b04da
Diffstat (limited to 'runtime/interpreter')
-rw-r--r--runtime/interpreter/unstarted_runtime.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc
index 6ea3f25..95f3357 100644
--- a/runtime/interpreter/unstarted_runtime.cc
+++ b/runtime/interpreter/unstarted_runtime.cc
@@ -144,6 +144,22 @@ static void UnstartedClassNewInstance(Thread* self, ShadowFrame* shadow_frame, J
StackHandleScope<3> hs(self); // Class, constructor, object.
mirror::Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass();
Handle<mirror::Class> h_klass(hs.NewHandle(klass));
+
+ // Check that it's not null.
+ if (h_klass.Get() == nullptr) {
+ AbortTransactionOrFail(self, "Class reference is null for newInstance");
+ return;
+ }
+
+ // If we're in a transaction, class must not be finalizable (it or a superclass has a finalizer).
+ if (Runtime::Current()->IsActiveTransaction()) {
+ if (h_klass.Get()->IsFinalizable()) {
+ AbortTransaction(self, "Class for newInstance is finalizable: '%s'",
+ PrettyClass(h_klass.Get()).c_str());
+ return;
+ }
+ }
+
// There are two situations in which we'll abort this run.
// 1) If the class isn't yet initialized and initialization fails.
// 2) If we can't find the default constructor. We'll postpone the exception to runtime.