blob: d7c7b89899dc7c7573669a351a874698c9331553 [file] [log] [blame]
Alex Lighta01de592016-11-15 10:43:06 -08001/* Copyright (C) 2016 The Android Open Source Project
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This file implements interfaces from the file jvmti.h. This implementation
5 * is licensed under the same terms as the file jvmti.h. The
6 * copyright and license information for the file jvmti.h follows.
7 *
8 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10 *
11 * This code is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 only, as
13 * published by the Free Software Foundation. Oracle designates this
14 * particular file as subject to the "Classpath" exception as provided
15 * by Oracle in the LICENSE file that accompanied this code.
16 *
17 * This code is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * version 2 for more details (a copy is included in the LICENSE file that
21 * accompanied this code).
22 *
23 * You should have received a copy of the GNU General Public License version
24 * 2 along with this work; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26 *
27 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28 * or visit www.oracle.com if you need additional information or have any
29 * questions.
30 */
31
Andreas Gampe06c42a52017-07-26 14:17:14 -070032#ifndef ART_OPENJDKJVMTI_TI_REDEFINE_H_
33#define ART_OPENJDKJVMTI_TI_REDEFINE_H_
Alex Lighta01de592016-11-15 10:43:06 -080034
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +000035#include <functional>
Alex Lighta01de592016-11-15 10:43:06 -080036#include <string>
37
38#include <jni.h>
39
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +000040#include "art_field.h"
Alex Lighta01de592016-11-15 10:43:06 -080041#include "art_jvmti.h"
Vladimir Markoe1993c72017-06-14 17:01:38 +010042#include "base/array_ref.h"
David Sehr1979c642018-04-26 14:41:18 -070043#include "base/globals.h"
Alex Light986914b2019-11-19 01:12:25 +000044#include "dex/class_accessor.h"
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +000045#include "dex/dex_file.h"
46#include "dex/dex_file_structs.h"
Vladimir Markoa3ad0cd2018-05-04 10:06:38 +010047#include "jni/jni_env_ext-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080048#include "jvmti.h"
Alex Lighta01de592016-11-15 10:43:06 -080049#include "mirror/array.h"
Alex Lighta01de592016-11-15 10:43:06 -080050#include "mirror/class.h"
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +000051#include "mirror/dex_cache.h"
Alex Lighta01de592016-11-15 10:43:06 -080052#include "obj_ptr.h"
Alex Lighta01de592016-11-15 10:43:06 -080053
Andreas Gampe3f1dcd32018-12-28 09:39:56 -080054namespace art {
Alex Light270db1c2019-12-03 12:20:01 +000055class ClassAccessor;
Andreas Gampe3f1dcd32018-12-28 09:39:56 -080056namespace dex {
57struct ClassDef;
58} // namespace dex
Andreas Gampe3f1dcd32018-12-28 09:39:56 -080059} // namespace art
60
Alex Lighta01de592016-11-15 10:43:06 -080061namespace openjdkjvmti {
62
Vladimir Marko5924a4a2018-05-29 17:40:41 +010063class ArtClassDefinition;
Alex Light0e692732017-01-10 15:00:05 -080064class RedefinitionDataHolder;
Alex Lightc5f5a6e2017-03-01 16:57:08 -080065class RedefinitionDataIter;
Alex Light0e692732017-01-10 15:00:05 -080066
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +000067enum class RedefinitionType {
68 kStructural,
69 kNormal,
70};
71
Alex Lighta01de592016-11-15 10:43:06 -080072// Class that can redefine a single class's methods.
73class Redefiner {
74 public:
Alex Light0e692732017-01-10 15:00:05 -080075 // Redefine the given classes with the given dex data. Note this function does not take ownership
76 // of the dex_data pointers. It is not used after this call however and may be freed if desired.
Alex Light6ac57502017-01-19 15:05:06 -080077 // The caller is responsible for freeing it. The runtime makes its own copy of the data. This
78 // function does not call the transformation events.
Alex Light6ac57502017-01-19 15:05:06 -080079 static jvmtiError RedefineClassesDirect(ArtJvmTiEnv* env,
80 art::Runtime* runtime,
81 art::Thread* self,
82 const std::vector<ArtClassDefinition>& definitions,
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +000083 RedefinitionType type,
Alex Light6ac57502017-01-19 15:05:06 -080084 /*out*/std::string* error_msg);
85
86 // Redefine the given classes with the given dex data. Note this function does not take ownership
87 // of the dex_data pointers. It is not used after this call however and may be freed if desired.
Alex Light0b772572016-12-02 17:27:31 -080088 // The caller is responsible for freeing it. The runtime makes its own copy of the data.
Alex Light3732beb2019-10-04 13:35:34 -070089 static jvmtiError RedefineClasses(jvmtiEnv* env,
Alex Light0e692732017-01-10 15:00:05 -080090 jint class_count,
Alex Light3732beb2019-10-04 13:35:34 -070091 const jvmtiClassDefinition* definitions);
Alex Lightd55b8442019-10-15 15:46:07 -070092 static jvmtiError StructurallyRedefineClasses(jvmtiEnv* env,
93 jint class_count,
94 const jvmtiClassDefinition* definitions);
Alex Lighta01de592016-11-15 10:43:06 -080095
Alex Lighte4a88632017-01-10 07:41:24 -080096 static jvmtiError IsModifiableClass(jvmtiEnv* env, jclass klass, jboolean* is_redefinable);
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +000097 static jvmtiError IsStructurallyModifiableClass(jvmtiEnv* env,
98 jclass klass,
99 jboolean* is_redefinable);
Alex Lighte4a88632017-01-10 07:41:24 -0800100
Vladimir Markoc34bebf2018-08-16 16:12:49 +0100101 static art::MemMap MoveDataToMemMap(const std::string& original_location,
102 art::ArrayRef<const unsigned char> data,
103 std::string* error_msg);
Alex Light440b5d92017-01-24 15:32:25 -0800104
Alex Light9e7859c2018-04-05 13:49:43 -0700105 // Helper for checking if redefinition/retransformation is allowed.
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000106 template<RedefinitionType kType = RedefinitionType::kNormal>
Alex Light9e7859c2018-04-05 13:49:43 -0700107 static jvmtiError GetClassRedefinitionError(jclass klass, /*out*/std::string* error_msg)
108 REQUIRES(!art::Locks::mutator_lock_);
109
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000110 static jvmtiError StructurallyRedefineClassDirect(jvmtiEnv* env,
111 jclass klass,
112 const unsigned char* data,
113 jint data_size);
114
Alex Lighta01de592016-11-15 10:43:06 -0800115 private:
Alex Light0e692732017-01-10 15:00:05 -0800116 class ClassRedefinition {
117 public:
118 ClassRedefinition(Redefiner* driver,
119 jclass klass,
120 const art::DexFile* redefined_dex_file,
Alex Lighta7e38d82017-01-19 14:57:28 -0800121 const char* class_sig,
Vladimir Markoe1993c72017-06-14 17:01:38 +0100122 art::ArrayRef<const unsigned char> orig_dex_file)
Alex Light0e692732017-01-10 15:00:05 -0800123 REQUIRES_SHARED(art::Locks::mutator_lock_);
124
125 // NO_THREAD_SAFETY_ANALYSIS so we can unlock the class in the destructor.
126 ~ClassRedefinition() NO_THREAD_SAFETY_ANALYSIS;
127
Alex Lightfb537082019-12-10 14:38:34 -0800128 // Move assignment so we can sort these in a vector.
129 ClassRedefinition& operator=(ClassRedefinition&& other) {
130 driver_ = other.driver_;
131 klass_ = other.klass_;
132 dex_file_ = std::move(other.dex_file_);
133 class_sig_ = std::move(other.class_sig_);
134 original_dex_file_ = other.original_dex_file_;
135 other.driver_ = nullptr;
136 return *this;
137 }
138
Alex Light0e692732017-01-10 15:00:05 -0800139 // Move constructor so we can put these into a vector.
140 ClassRedefinition(ClassRedefinition&& other)
141 : driver_(other.driver_),
142 klass_(other.klass_),
143 dex_file_(std::move(other.dex_file_)),
Alex Lighta7e38d82017-01-19 14:57:28 -0800144 class_sig_(std::move(other.class_sig_)),
145 original_dex_file_(other.original_dex_file_) {
Alex Light0e692732017-01-10 15:00:05 -0800146 other.driver_ = nullptr;
147 }
148
Alex Lightfb537082019-12-10 14:38:34 -0800149 // No copy!
150 ClassRedefinition(ClassRedefinition&) = delete;
151 ClassRedefinition& operator=(ClassRedefinition&) = delete;
152
Vladimir Marko4617d582019-03-28 13:48:31 +0000153 art::ObjPtr<art::mirror::Class> GetMirrorClass() REQUIRES_SHARED(art::Locks::mutator_lock_);
Vladimir Markoc524e9e2019-03-26 10:54:50 +0000154 art::ObjPtr<art::mirror::ClassLoader> GetClassLoader()
155 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800156
Alex Light7916f202017-01-27 09:00:15 -0800157 const art::DexFile& GetDexFile() {
158 return *dex_file_;
159 }
160
Alex Light0e692732017-01-10 15:00:05 -0800161 art::mirror::DexCache* CreateNewDexCache(art::Handle<art::mirror::ClassLoader> loader)
162 REQUIRES_SHARED(art::Locks::mutator_lock_);
163
Alex Lighta7e38d82017-01-19 14:57:28 -0800164 // This may return nullptr with a OOME pending if allocation fails.
Alex Light2f814aa2017-03-24 15:21:34 +0000165 art::mirror::Object* AllocateOrGetOriginalDexFile()
Alex Lighta7e38d82017-01-19 14:57:28 -0800166 REQUIRES_SHARED(art::Locks::mutator_lock_);
167
Alex Light0e692732017-01-10 15:00:05 -0800168 void RecordFailure(jvmtiError e, const std::string& err) {
169 driver_->RecordFailure(e, class_sig_, err);
170 }
171
Alex Lightfb537082019-12-10 14:38:34 -0800172 bool FinishRemainingCommonAllocations(/*out*/RedefinitionDataIter* cur_data)
Alex Light0e692732017-01-10 15:00:05 -0800173 REQUIRES_SHARED(art::Locks::mutator_lock_);
174
Alex Lightfb537082019-12-10 14:38:34 -0800175 bool FinishNewClassAllocations(RedefinitionDataHolder& holder,
176 /*out*/RedefinitionDataIter* cur_data)
177 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light986914b2019-11-19 01:12:25 +0000178 bool CollectAndCreateNewInstances(/*out*/RedefinitionDataIter* cur_data)
179 REQUIRES_SHARED(art::Locks::mutator_lock_);
180
Alex Light1babae02017-02-01 15:35:34 -0800181 bool AllocateAndRememberNewDexFileCookie(
Alex Light1babae02017-02-01 15:35:34 -0800182 art::Handle<art::mirror::ClassLoader> source_class_loader,
183 art::Handle<art::mirror::Object> dex_file_obj,
Alex Lightc5f5a6e2017-03-01 16:57:08 -0800184 /*out*/RedefinitionDataIter* cur_data)
Alex Light1babae02017-02-01 15:35:34 -0800185 REQUIRES_SHARED(art::Locks::mutator_lock_);
186
Vladimir Markod93e3742018-07-18 10:58:13 +0100187 void FindAndAllocateObsoleteMethods(art::ObjPtr<art::mirror::Class> art_klass)
Alex Light0e692732017-01-10 15:00:05 -0800188 REQUIRES(art::Locks::mutator_lock_);
189
Alex Light270db1c2019-12-03 12:20:01 +0000190 art::ObjPtr<art::mirror::Class> AllocateNewClassObject(
191 art::Handle<art::mirror::Class> old_class,
192 art::Handle<art::mirror::Class> super_class,
193 art::Handle<art::mirror::DexCache> cache,
194 uint16_t dex_class_def_index) REQUIRES_SHARED(art::Locks::mutator_lock_);
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000195 art::ObjPtr<art::mirror::Class> AllocateNewClassObject(art::Handle<art::mirror::DexCache> cache)
196 REQUIRES_SHARED(art::Locks::mutator_lock_);
197
Alex Light270db1c2019-12-03 12:20:01 +0000198 uint32_t GetNewClassSize(art::ClassAccessor& accessor)
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000199 REQUIRES_SHARED(art::Locks::mutator_lock_);
200
Alex Light0e692732017-01-10 15:00:05 -0800201 // Checks that the dex file contains only the single expected class and that the top-level class
202 // data has not been modified in an incompatible manner.
203 bool CheckClass() REQUIRES_SHARED(art::Locks::mutator_lock_);
204
Alex Light8c889d22017-02-06 13:58:27 -0800205 // Checks that the contained class can be successfully verified.
Alex Lightc5f5a6e2017-03-01 16:57:08 -0800206 bool CheckVerification(const RedefinitionDataIter& holder)
Alex Light8c889d22017-02-06 13:58:27 -0800207 REQUIRES_SHARED(art::Locks::mutator_lock_);
208
Alex Light0e692732017-01-10 15:00:05 -0800209 // Preallocates all needed allocations in klass so that we can pause execution safely.
Alex Light1e3926a2017-04-07 10:38:06 -0700210 bool EnsureClassAllocationsFinished(/*out*/RedefinitionDataIter* data)
211 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800212
213 // This will check that no constraints are violated (more than 1 class in dex file, any changes
214 // in number/declaration of methods & fields, changes in access flags, etc.)
215 bool CheckRedefinitionIsValid() REQUIRES_SHARED(art::Locks::mutator_lock_);
216
217 // Checks that the class can even be redefined.
218 bool CheckRedefinable() REQUIRES_SHARED(art::Locks::mutator_lock_);
219
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000220 // Checks that the dex file does not add/remove methods, or change their modifiers or types in
221 // illegal ways.
222 bool CheckMethods() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800223
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000224 // Checks that the dex file does not modify fields types or modifiers in illegal ways.
225 bool CheckFields() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800226
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000227 // Temporary check that a class undergoing structural redefinition has no instances. This
228 // requirement will be removed in time.
Alex Light0e692732017-01-10 15:00:05 -0800229 void UpdateJavaDexFile(art::ObjPtr<art::mirror::Object> java_dex_file,
230 art::ObjPtr<art::mirror::LongArray> new_cookie)
231 REQUIRES(art::Locks::mutator_lock_);
232
233 void UpdateFields(art::ObjPtr<art::mirror::Class> mclass)
234 REQUIRES(art::Locks::mutator_lock_);
235
236 void UpdateMethods(art::ObjPtr<art::mirror::Class> mclass,
Andreas Gampe3f1dcd32018-12-28 09:39:56 -0800237 const art::dex::ClassDef& class_def)
Alex Light0e692732017-01-10 15:00:05 -0800238 REQUIRES(art::Locks::mutator_lock_);
239
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000240 void UpdateClass(const RedefinitionDataIter& cur_data)
241 REQUIRES(art::Locks::mutator_lock_);
242
Alex Lightc2d0c962019-10-23 14:14:25 -0700243 void UpdateClassCommon(const RedefinitionDataIter& cur_data)
Alex Lightb1eebde2019-10-22 16:30:47 +0000244 REQUIRES(art::Locks::mutator_lock_);
245
Alex Lightc2d0c962019-10-23 14:14:25 -0700246 void ReverifyClass(const RedefinitionDataIter& cur_data)
247 REQUIRES_SHARED(art::Locks::mutator_lock_);
248
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000249 void CollectNewFieldAndMethodMappings(const RedefinitionDataIter& data,
250 std::map<art::ArtMethod*, art::ArtMethod*>* method_map,
251 std::map<art::ArtField*, art::ArtField*>* field_map)
Alex Light0e692732017-01-10 15:00:05 -0800252 REQUIRES(art::Locks::mutator_lock_);
253
Alex Light1e3926a2017-04-07 10:38:06 -0700254 void RestoreObsoleteMethodMapsIfUnneeded(const RedefinitionDataIter* cur_data)
255 REQUIRES(art::Locks::mutator_lock_);
256
Alex Light0e692732017-01-10 15:00:05 -0800257 void ReleaseDexFile() REQUIRES_SHARED(art::Locks::mutator_lock_);
258
Alex Lighta26e3492017-06-27 17:55:37 -0700259 // This should be done with all threads suspended.
Alex Lighte34fe442018-02-21 17:35:55 -0800260 void UnregisterJvmtiBreakpoints() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light5643caf2017-02-08 11:39:07 -0800261
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000262 void RecordNewMethodAdded();
263 void RecordNewFieldAdded();
Alex Light986914b2019-11-19 01:12:25 +0000264 void RecordHasVirtualMembers() {
265 has_virtuals_ = true;
266 }
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000267
Alex Light986914b2019-11-19 01:12:25 +0000268 bool HasVirtualMembers() const {
269 return has_virtuals_;
270 }
271
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000272 bool IsStructuralRedefinition() const {
273 DCHECK(!(added_fields_ || added_methods_) || driver_->IsStructuralRedefinition())
274 << "added_fields_: " << added_fields_ << " added_methods_: " << added_methods_
275 << " driver_->IsStructuralRedefinition(): " << driver_->IsStructuralRedefinition();
276 return driver_->IsStructuralRedefinition() && (added_fields_ || added_methods_);
277 }
278
Alex Light986914b2019-11-19 01:12:25 +0000279 private:
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000280 void UpdateClassStructurally(const RedefinitionDataIter& cur_data)
281 REQUIRES(art::Locks::mutator_lock_);
282
283 void UpdateClassInPlace(const RedefinitionDataIter& cur_data)
284 REQUIRES(art::Locks::mutator_lock_);
285
Alex Light0e692732017-01-10 15:00:05 -0800286 Redefiner* driver_;
287 jclass klass_;
288 std::unique_ptr<const art::DexFile> dex_file_;
289 std::string class_sig_;
Vladimir Markoe1993c72017-06-14 17:01:38 +0100290 art::ArrayRef<const unsigned char> original_dex_file_;
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000291
292 bool added_fields_ = false;
293 bool added_methods_ = false;
Alex Light986914b2019-11-19 01:12:25 +0000294 bool has_virtuals_ = false;
Alex Lightb1eebde2019-10-22 16:30:47 +0000295
296 // Does the class need to be reverified due to verification soft-fails possibly forcing
297 // interpreter or lock-counting?
298 bool needs_reverify_ = false;
Alex Light0e692732017-01-10 15:00:05 -0800299 };
300
Alex Lighta26e3492017-06-27 17:55:37 -0700301 ArtJvmTiEnv* env_;
Alex Lighta01de592016-11-15 10:43:06 -0800302 jvmtiError result_;
303 art::Runtime* runtime_;
304 art::Thread* self_;
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000305 RedefinitionType type_;
Alex Light0e692732017-01-10 15:00:05 -0800306 std::vector<ClassRedefinition> redefinitions_;
Alex Lighta01de592016-11-15 10:43:06 -0800307 // Kept as a jclass since we have weird run-state changes that make keeping it around as a
308 // mirror::Class difficult and confusing.
Alex Lighta01de592016-11-15 10:43:06 -0800309 std::string* error_msg_;
Alex Lighta01de592016-11-15 10:43:06 -0800310
Alex Lighta26e3492017-06-27 17:55:37 -0700311 Redefiner(ArtJvmTiEnv* env,
312 art::Runtime* runtime,
Alex Lighta01de592016-11-15 10:43:06 -0800313 art::Thread* self,
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000314 RedefinitionType type,
Alex Lighta01de592016-11-15 10:43:06 -0800315 std::string* error_msg)
Alex Lighta26e3492017-06-27 17:55:37 -0700316 : env_(env),
317 result_(ERR(INTERNAL)),
Alex Lighta01de592016-11-15 10:43:06 -0800318 runtime_(runtime),
319 self_(self),
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000320 type_(type),
Alex Light0e692732017-01-10 15:00:05 -0800321 redefinitions_(),
322 error_msg_(error_msg) { }
323
Alex Light6ac57502017-01-19 15:05:06 -0800324 jvmtiError AddRedefinition(ArtJvmTiEnv* env, const ArtClassDefinition& def)
Alex Light0e692732017-01-10 15:00:05 -0800325 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lighta01de592016-11-15 10:43:06 -0800326
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000327 template<RedefinitionType kType = RedefinitionType::kNormal>
Alex Lightd55b8442019-10-15 15:46:07 -0700328 static jvmtiError RedefineClassesGeneric(jvmtiEnv* env,
329 jint class_count,
330 const jvmtiClassDefinition* definitions);
331
332 template<RedefinitionType kType = RedefinitionType::kNormal>
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000333 static jvmtiError IsModifiableClassGeneric(jvmtiEnv* env, jclass klass, jboolean* is_redefinable);
334
335 template<RedefinitionType kType = RedefinitionType::kNormal>
Alex Lighte4a88632017-01-10 07:41:24 -0800336 static jvmtiError GetClassRedefinitionError(art::Handle<art::mirror::Class> klass,
337 /*out*/std::string* error_msg)
338 REQUIRES_SHARED(art::Locks::mutator_lock_);
339
Alex Lighta01de592016-11-15 10:43:06 -0800340 jvmtiError Run() REQUIRES_SHARED(art::Locks::mutator_lock_);
341
Alex Light0e692732017-01-10 15:00:05 -0800342 bool CheckAllRedefinitionAreValid() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lightc5f5a6e2017-03-01 16:57:08 -0800343 bool CheckAllClassesAreVerified(RedefinitionDataHolder& holder)
Alex Light8c889d22017-02-06 13:58:27 -0800344 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lightfb537082019-12-10 14:38:34 -0800345 void MarkStructuralChanges(RedefinitionDataHolder& holder)
346 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light1e3926a2017-04-07 10:38:06 -0700347 bool EnsureAllClassAllocationsFinished(RedefinitionDataHolder& holder)
348 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lightfb537082019-12-10 14:38:34 -0800349 bool FinishAllRemainingCommonAllocations(RedefinitionDataHolder& holder)
350 REQUIRES_SHARED(art::Locks::mutator_lock_);
351 bool FinishAllNewClassAllocations(RedefinitionDataHolder& holder)
Alex Lighta01de592016-11-15 10:43:06 -0800352 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light986914b2019-11-19 01:12:25 +0000353 bool CollectAndCreateNewInstances(RedefinitionDataHolder& holder)
354 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800355 void ReleaseAllDexFiles() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lightc2d0c962019-10-23 14:14:25 -0700356 void ReverifyClasses(RedefinitionDataHolder& holder) REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light5643caf2017-02-08 11:39:07 -0800357 void UnregisterAllBreakpoints() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light1e3926a2017-04-07 10:38:06 -0700358 // Restores the old obsolete methods maps if it turns out they weren't needed (ie there were no
359 // new obsolete methods).
360 void RestoreObsoleteMethodMapsIfUnneeded(RedefinitionDataHolder& holder)
361 REQUIRES(art::Locks::mutator_lock_);
Alex Lighta01de592016-11-15 10:43:06 -0800362
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000363 bool IsStructuralRedefinition() const {
364 return type_ == RedefinitionType::kStructural;
365 }
366
Alex Light0e692732017-01-10 15:00:05 -0800367 void RecordFailure(jvmtiError result, const std::string& class_sig, const std::string& error_msg);
368 void RecordFailure(jvmtiError result, const std::string& error_msg) {
369 RecordFailure(result, "NO CLASS", error_msg);
Alex Lighta01de592016-11-15 10:43:06 -0800370 }
371
Alex Light0e692732017-01-10 15:00:05 -0800372 friend struct CallbackCtx;
Alex Lightc5f5a6e2017-03-01 16:57:08 -0800373 friend class RedefinitionDataHolder;
374 friend class RedefinitionDataIter;
Alex Lighta01de592016-11-15 10:43:06 -0800375};
376
377} // namespace openjdkjvmti
378
Andreas Gampe06c42a52017-07-26 14:17:14 -0700379#endif // ART_OPENJDKJVMTI_TI_REDEFINE_H_