diff options
author | 2019-09-24 14:36:27 -0700 | |
---|---|---|
committer | 2019-09-27 17:08:33 +0000 | |
commit | c18eba327c4e207ff7b38817f097ee2220b44b39 (patch) | |
tree | 1978e64abd3e9fd3df99179f4a2110a724a9565f /runtime/reflective_value_visitor.cc | |
parent | 371390f775c90b8b3df11a9890585598a2a39da9 (diff) |
Consolidate updating of reflective Field/Method references
Previously we used several different visitors to update Field &
Method references for structural redefinition. We also did not visit
or update JVMTI based references.
This consolidates all the visitors to a single
Runtime::VisitReflectiveTargets function with a single
ReflectiveTargetVisitor type. This simplifies the code around
structural redefinition and ensures that the reflective value holders
are in charge of the actual replacement.
Support was also added for walking internal openjdkjvmti references
for things like field-read/modification events.
Test: ./test.py --host
Bug: 134162467
Change-Id: Ic5fc1db7db0a30f947a1a67259dc024e149ebd57
Diffstat (limited to 'runtime/reflective_value_visitor.cc')
-rw-r--r-- | runtime/reflective_value_visitor.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/runtime/reflective_value_visitor.cc b/runtime/reflective_value_visitor.cc new file mode 100644 index 0000000000..69fd51ff6e --- /dev/null +++ b/runtime/reflective_value_visitor.cc @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "reflective_value_visitor.h" +#include <sstream> + +#include "base/locks.h" +#include "base/mutex-inl.h" +#include "mirror/class.h" +#include "mirror/object-inl.h" + +namespace art { + +void HeapReflectiveSourceInfo::Describe(std::ostream& os) const { + Locks::mutator_lock_->AssertExclusiveHeld(Thread::Current()); + ReflectionSourceInfo::Describe(os); + os << " Class=" << src_->GetClass()->PrettyClass(); +} + +template<> +void JniIdReflectiveSourceInfo<jfieldID>::Describe(std::ostream& os) const { + ReflectionSourceInfo::Describe(os); + os << " jfieldID=" << reinterpret_cast<uintptr_t>(id_); +} + +template<> +void JniIdReflectiveSourceInfo<jmethodID>::Describe(std::ostream& os) const { + ReflectionSourceInfo::Describe(os); + os << " jmethodID=" << reinterpret_cast<uintptr_t>(id_); +} + +} // namespace art |