diff options
author | Alex Light <allight@google.com> | 2020-01-07 22:51:03 +0000 |
---|---|---|
committer | Alex Light <allight@google.com> | 2020-01-07 22:51:55 +0000 |
commit | 0b1afb7c63d99c88f90f17770ad94ccb0b0c57d3 (patch) | |
tree | 92e88de49a2e79c2a00ce8990e412febc81e5318 /openjdkjvmti | |
parent | 93be70effba70b78596fc4bda6b583615c3b6d0c (diff) |
Revert "Remove finalizable restriction on structural redefinition"
This reverts commit 55d6fa4c352a1fadbd21b8d8e0929833e547b9e5.
Bug: 134162467
Test: None, pure revert.
Reason for revert: Flaky segvs across multiple configurations.
Change-Id: Iaa8ec6cbd2eee141e271cd3a56a1b6be8bbb3a7c
Diffstat (limited to 'openjdkjvmti')
-rw-r--r-- | openjdkjvmti/ti_redefine.cc | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/openjdkjvmti/ti_redefine.cc b/openjdkjvmti/ti_redefine.cc index dccc226f60..c505933853 100644 --- a/openjdkjvmti/ti_redefine.cc +++ b/openjdkjvmti/ti_redefine.cc @@ -1131,6 +1131,10 @@ bool Redefiner::ClassRedefinition::CheckRedefinable() { jvmtiError res; if (driver_->type_ == RedefinitionType::kStructural && this->IsStructuralRedefinition()) { res = Redefiner::GetClassRedefinitionError<RedefinitionType::kStructural>(h_klass, &err); + if (res == OK && HasVirtualMembers() && h_klass->IsFinalizable()) { + res = ERR(INTERNAL); + err = "Cannot redefine finalizable objects at this time."; + } } else { res = Redefiner::GetClassRedefinitionError<RedefinitionType::kNormal>(h_klass, &err); } @@ -1746,21 +1750,7 @@ bool Redefiner::ClassRedefinition::CollectAndCreateNewInstances( [&](auto class_pair) REQUIRES_SHARED(art::Locks::mutator_lock_) { return class_pair.first == hinstance->GetClass(); })); - // Make sure when allocating the new instance we don't add it's finalizer since we will directly - // replace the old object in the finalizer reference. If we added it here to we would call - // finalize twice. - // NB If a type is changed from being non-finalizable to finalizable the finalizers on any - // objects created before the redefine will never be called. This is (sort of) allowable by - // the spec and greatly simplifies implementation. - // TODO Make it so we will always call all finalizers, even if the object when it was created - // wasn't finalizable. To do this we need to be careful of handling failure correctly and making - // sure that objects aren't finalized multiple times and that instances of failed redefinitions - // aren't finalized. - art::ObjPtr<art::mirror::Object> new_instance( - new_type->Alloc</*kIsInstrumented=*/true, - art::mirror::Class::AddFinalizer::kNoAddFinalizer, - /*kCheckAddFinalizer=*/false>( - driver_->self_, driver_->runtime_->GetHeap()->GetCurrentAllocator())); + art::ObjPtr<art::mirror::Object> new_instance(new_type->AllocObject(driver_->self_)); if (new_instance.IsNull()) { driver_->self_->AssertPendingOOMException(); driver_->self_->ClearException(); |