blob: 85b10705163f0c6b6266a5fa59147a87536345c0 [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_;
ShuJieWangb087bb22021-11-24 11:46:16 +0800135 lock_acquired_ = other.lock_acquired_;
Alex Lightfb537082019-12-10 14:38:34 -0800136 other.driver_ = nullptr;
137 return *this;
138 }
139
Alex Light0e692732017-01-10 15:00:05 -0800140 // Move constructor so we can put these into a vector.
141 ClassRedefinition(ClassRedefinition&& other)
142 : driver_(other.driver_),
143 klass_(other.klass_),
144 dex_file_(std::move(other.dex_file_)),
Alex Lighta7e38d82017-01-19 14:57:28 -0800145 class_sig_(std::move(other.class_sig_)),
ShuJieWangb087bb22021-11-24 11:46:16 +0800146 original_dex_file_(other.original_dex_file_),
147 lock_acquired_(other.lock_acquired_) {
Alex Light0e692732017-01-10 15:00:05 -0800148 other.driver_ = nullptr;
149 }
150
Alex Lightfb537082019-12-10 14:38:34 -0800151 // No copy!
152 ClassRedefinition(ClassRedefinition&) = delete;
153 ClassRedefinition& operator=(ClassRedefinition&) = delete;
154
Vladimir Marko4617d582019-03-28 13:48:31 +0000155 art::ObjPtr<art::mirror::Class> GetMirrorClass() REQUIRES_SHARED(art::Locks::mutator_lock_);
Vladimir Markoc524e9e2019-03-26 10:54:50 +0000156 art::ObjPtr<art::mirror::ClassLoader> GetClassLoader()
157 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800158
Alex Light7916f202017-01-27 09:00:15 -0800159 const art::DexFile& GetDexFile() {
160 return *dex_file_;
161 }
162
Alex Light0e692732017-01-10 15:00:05 -0800163 art::mirror::DexCache* CreateNewDexCache(art::Handle<art::mirror::ClassLoader> loader)
164 REQUIRES_SHARED(art::Locks::mutator_lock_);
165
Alex Lighta7e38d82017-01-19 14:57:28 -0800166 // This may return nullptr with a OOME pending if allocation fails.
Alex Light2f814aa2017-03-24 15:21:34 +0000167 art::mirror::Object* AllocateOrGetOriginalDexFile()
Alex Lighta7e38d82017-01-19 14:57:28 -0800168 REQUIRES_SHARED(art::Locks::mutator_lock_);
169
Alex Light0e692732017-01-10 15:00:05 -0800170 void RecordFailure(jvmtiError e, const std::string& err) {
171 driver_->RecordFailure(e, class_sig_, err);
172 }
173
Alex Lightfb537082019-12-10 14:38:34 -0800174 bool FinishRemainingCommonAllocations(/*out*/RedefinitionDataIter* cur_data)
Alex Light0e692732017-01-10 15:00:05 -0800175 REQUIRES_SHARED(art::Locks::mutator_lock_);
176
Alex Lightfb537082019-12-10 14:38:34 -0800177 bool FinishNewClassAllocations(RedefinitionDataHolder& holder,
178 /*out*/RedefinitionDataIter* cur_data)
179 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light986914b2019-11-19 01:12:25 +0000180 bool CollectAndCreateNewInstances(/*out*/RedefinitionDataIter* cur_data)
181 REQUIRES_SHARED(art::Locks::mutator_lock_);
182
Alex Light1babae02017-02-01 15:35:34 -0800183 bool AllocateAndRememberNewDexFileCookie(
Alex Light1babae02017-02-01 15:35:34 -0800184 art::Handle<art::mirror::ClassLoader> source_class_loader,
185 art::Handle<art::mirror::Object> dex_file_obj,
Alex Lightc5f5a6e2017-03-01 16:57:08 -0800186 /*out*/RedefinitionDataIter* cur_data)
Alex Light1babae02017-02-01 15:35:34 -0800187 REQUIRES_SHARED(art::Locks::mutator_lock_);
188
Vladimir Markod93e3742018-07-18 10:58:13 +0100189 void FindAndAllocateObsoleteMethods(art::ObjPtr<art::mirror::Class> art_klass)
Alex Light0e692732017-01-10 15:00:05 -0800190 REQUIRES(art::Locks::mutator_lock_);
191
Alex Light270db1c2019-12-03 12:20:01 +0000192 art::ObjPtr<art::mirror::Class> AllocateNewClassObject(
193 art::Handle<art::mirror::Class> old_class,
194 art::Handle<art::mirror::Class> super_class,
195 art::Handle<art::mirror::DexCache> cache,
196 uint16_t dex_class_def_index) REQUIRES_SHARED(art::Locks::mutator_lock_);
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000197 art::ObjPtr<art::mirror::Class> AllocateNewClassObject(art::Handle<art::mirror::DexCache> cache)
198 REQUIRES_SHARED(art::Locks::mutator_lock_);
199
Alex Light270db1c2019-12-03 12:20:01 +0000200 uint32_t GetNewClassSize(art::ClassAccessor& accessor)
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000201 REQUIRES_SHARED(art::Locks::mutator_lock_);
202
Alex Light0e692732017-01-10 15:00:05 -0800203 // Checks that the dex file contains only the single expected class and that the top-level class
204 // data has not been modified in an incompatible manner.
205 bool CheckClass() REQUIRES_SHARED(art::Locks::mutator_lock_);
206
Alex Light8c889d22017-02-06 13:58:27 -0800207 // Checks that the contained class can be successfully verified.
Alex Lightc5f5a6e2017-03-01 16:57:08 -0800208 bool CheckVerification(const RedefinitionDataIter& holder)
Alex Light8c889d22017-02-06 13:58:27 -0800209 REQUIRES_SHARED(art::Locks::mutator_lock_);
210
Alex Light0e692732017-01-10 15:00:05 -0800211 // Preallocates all needed allocations in klass so that we can pause execution safely.
Alex Light1e3926a2017-04-07 10:38:06 -0700212 bool EnsureClassAllocationsFinished(/*out*/RedefinitionDataIter* data)
213 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800214
215 // This will check that no constraints are violated (more than 1 class in dex file, any changes
216 // in number/declaration of methods & fields, changes in access flags, etc.)
217 bool CheckRedefinitionIsValid() REQUIRES_SHARED(art::Locks::mutator_lock_);
218
219 // Checks that the class can even be redefined.
220 bool CheckRedefinable() REQUIRES_SHARED(art::Locks::mutator_lock_);
221
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000222 // Checks that the dex file does not add/remove methods, or change their modifiers or types in
223 // illegal ways.
224 bool CheckMethods() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800225
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000226 // Checks that the dex file does not modify fields types or modifiers in illegal ways.
227 bool CheckFields() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800228
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000229 // Temporary check that a class undergoing structural redefinition has no instances. This
230 // requirement will be removed in time.
Alex Light0e692732017-01-10 15:00:05 -0800231 void UpdateJavaDexFile(art::ObjPtr<art::mirror::Object> java_dex_file,
232 art::ObjPtr<art::mirror::LongArray> new_cookie)
233 REQUIRES(art::Locks::mutator_lock_);
234
235 void UpdateFields(art::ObjPtr<art::mirror::Class> mclass)
236 REQUIRES(art::Locks::mutator_lock_);
237
238 void UpdateMethods(art::ObjPtr<art::mirror::Class> mclass,
Andreas Gampe3f1dcd32018-12-28 09:39:56 -0800239 const art::dex::ClassDef& class_def)
Alex Light0e692732017-01-10 15:00:05 -0800240 REQUIRES(art::Locks::mutator_lock_);
241
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000242 void UpdateClass(const RedefinitionDataIter& cur_data)
243 REQUIRES(art::Locks::mutator_lock_);
244
245 void CollectNewFieldAndMethodMappings(const RedefinitionDataIter& data,
246 std::map<art::ArtMethod*, art::ArtMethod*>* method_map,
247 std::map<art::ArtField*, art::ArtField*>* field_map)
Alex Light0e692732017-01-10 15:00:05 -0800248 REQUIRES(art::Locks::mutator_lock_);
249
Alex Light1e3926a2017-04-07 10:38:06 -0700250 void RestoreObsoleteMethodMapsIfUnneeded(const RedefinitionDataIter* cur_data)
251 REQUIRES(art::Locks::mutator_lock_);
252
Alex Light0e692732017-01-10 15:00:05 -0800253 void ReleaseDexFile() REQUIRES_SHARED(art::Locks::mutator_lock_);
254
Alex Lighta26e3492017-06-27 17:55:37 -0700255 // This should be done with all threads suspended.
Alex Lighte34fe442018-02-21 17:35:55 -0800256 void UnregisterJvmtiBreakpoints() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light5643caf2017-02-08 11:39:07 -0800257
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000258 void RecordNewMethodAdded();
259 void RecordNewFieldAdded();
Alex Light986914b2019-11-19 01:12:25 +0000260 void RecordHasVirtualMembers() {
261 has_virtuals_ = true;
262 }
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000263
Alex Light986914b2019-11-19 01:12:25 +0000264 bool HasVirtualMembers() const {
265 return has_virtuals_;
266 }
267
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000268 bool IsStructuralRedefinition() const {
269 DCHECK(!(added_fields_ || added_methods_) || driver_->IsStructuralRedefinition())
270 << "added_fields_: " << added_fields_ << " added_methods_: " << added_methods_
271 << " driver_->IsStructuralRedefinition(): " << driver_->IsStructuralRedefinition();
272 return driver_->IsStructuralRedefinition() && (added_fields_ || added_methods_);
273 }
274
Alex Light986914b2019-11-19 01:12:25 +0000275 private:
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000276 void UpdateClassStructurally(const RedefinitionDataIter& cur_data)
277 REQUIRES(art::Locks::mutator_lock_);
278
279 void UpdateClassInPlace(const RedefinitionDataIter& cur_data)
280 REQUIRES(art::Locks::mutator_lock_);
281
Alex Light0e692732017-01-10 15:00:05 -0800282 Redefiner* driver_;
283 jclass klass_;
284 std::unique_ptr<const art::DexFile> dex_file_;
285 std::string class_sig_;
Vladimir Markoe1993c72017-06-14 17:01:38 +0100286 art::ArrayRef<const unsigned char> original_dex_file_;
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000287
288 bool added_fields_ = false;
289 bool added_methods_ = false;
Alex Light986914b2019-11-19 01:12:25 +0000290 bool has_virtuals_ = false;
ShuJieWangb087bb22021-11-24 11:46:16 +0800291 bool lock_acquired_ = false;
Alex Light0e692732017-01-10 15:00:05 -0800292 };
293
Alex Lighta26e3492017-06-27 17:55:37 -0700294 ArtJvmTiEnv* env_;
Alex Lighta01de592016-11-15 10:43:06 -0800295 jvmtiError result_;
296 art::Runtime* runtime_;
297 art::Thread* self_;
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000298 RedefinitionType type_;
Alex Light0e692732017-01-10 15:00:05 -0800299 std::vector<ClassRedefinition> redefinitions_;
Alex Lighta01de592016-11-15 10:43:06 -0800300 // Kept as a jclass since we have weird run-state changes that make keeping it around as a
301 // mirror::Class difficult and confusing.
Alex Lighta01de592016-11-15 10:43:06 -0800302 std::string* error_msg_;
Alex Lighta01de592016-11-15 10:43:06 -0800303
Alex Lighta26e3492017-06-27 17:55:37 -0700304 Redefiner(ArtJvmTiEnv* env,
305 art::Runtime* runtime,
Alex Lighta01de592016-11-15 10:43:06 -0800306 art::Thread* self,
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000307 RedefinitionType type,
Alex Lighta01de592016-11-15 10:43:06 -0800308 std::string* error_msg)
Alex Lighta26e3492017-06-27 17:55:37 -0700309 : env_(env),
310 result_(ERR(INTERNAL)),
Alex Lighta01de592016-11-15 10:43:06 -0800311 runtime_(runtime),
312 self_(self),
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000313 type_(type),
Alex Light0e692732017-01-10 15:00:05 -0800314 redefinitions_(),
315 error_msg_(error_msg) { }
316
Alex Light6ac57502017-01-19 15:05:06 -0800317 jvmtiError AddRedefinition(ArtJvmTiEnv* env, const ArtClassDefinition& def)
Alex Light0e692732017-01-10 15:00:05 -0800318 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lighta01de592016-11-15 10:43:06 -0800319
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000320 template<RedefinitionType kType = RedefinitionType::kNormal>
Alex Lightd55b8442019-10-15 15:46:07 -0700321 static jvmtiError RedefineClassesGeneric(jvmtiEnv* env,
322 jint class_count,
323 const jvmtiClassDefinition* definitions);
324
325 template<RedefinitionType kType = RedefinitionType::kNormal>
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000326 static jvmtiError IsModifiableClassGeneric(jvmtiEnv* env, jclass klass, jboolean* is_redefinable);
327
328 template<RedefinitionType kType = RedefinitionType::kNormal>
Alex Lighte4a88632017-01-10 07:41:24 -0800329 static jvmtiError GetClassRedefinitionError(art::Handle<art::mirror::Class> klass,
330 /*out*/std::string* error_msg)
331 REQUIRES_SHARED(art::Locks::mutator_lock_);
332
Alex Lighta01de592016-11-15 10:43:06 -0800333 jvmtiError Run() REQUIRES_SHARED(art::Locks::mutator_lock_);
334
Alex Light0e692732017-01-10 15:00:05 -0800335 bool CheckAllRedefinitionAreValid() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lightc5f5a6e2017-03-01 16:57:08 -0800336 bool CheckAllClassesAreVerified(RedefinitionDataHolder& holder)
Alex Light8c889d22017-02-06 13:58:27 -0800337 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lightfb537082019-12-10 14:38:34 -0800338 void MarkStructuralChanges(RedefinitionDataHolder& holder)
339 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light1e3926a2017-04-07 10:38:06 -0700340 bool EnsureAllClassAllocationsFinished(RedefinitionDataHolder& holder)
341 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lightfb537082019-12-10 14:38:34 -0800342 bool FinishAllRemainingCommonAllocations(RedefinitionDataHolder& holder)
343 REQUIRES_SHARED(art::Locks::mutator_lock_);
344 bool FinishAllNewClassAllocations(RedefinitionDataHolder& holder)
Alex Lighta01de592016-11-15 10:43:06 -0800345 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light986914b2019-11-19 01:12:25 +0000346 bool CollectAndCreateNewInstances(RedefinitionDataHolder& holder)
347 REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light0e692732017-01-10 15:00:05 -0800348 void ReleaseAllDexFiles() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Lightc2d0c962019-10-23 14:14:25 -0700349 void ReverifyClasses(RedefinitionDataHolder& holder) REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light5643caf2017-02-08 11:39:07 -0800350 void UnregisterAllBreakpoints() REQUIRES_SHARED(art::Locks::mutator_lock_);
Alex Light1e3926a2017-04-07 10:38:06 -0700351 // Restores the old obsolete methods maps if it turns out they weren't needed (ie there were no
352 // new obsolete methods).
353 void RestoreObsoleteMethodMapsIfUnneeded(RedefinitionDataHolder& holder)
354 REQUIRES(art::Locks::mutator_lock_);
Alex Lighta01de592016-11-15 10:43:06 -0800355
Nicolas Geoffray4ac0e152019-09-18 06:14:50 +0000356 bool IsStructuralRedefinition() const {
357 return type_ == RedefinitionType::kStructural;
358 }
359
Alex Light0e692732017-01-10 15:00:05 -0800360 void RecordFailure(jvmtiError result, const std::string& class_sig, const std::string& error_msg);
361 void RecordFailure(jvmtiError result, const std::string& error_msg) {
362 RecordFailure(result, "NO CLASS", error_msg);
Alex Lighta01de592016-11-15 10:43:06 -0800363 }
364
Alex Light0e692732017-01-10 15:00:05 -0800365 friend struct CallbackCtx;
Alex Lightc5f5a6e2017-03-01 16:57:08 -0800366 friend class RedefinitionDataHolder;
367 friend class RedefinitionDataIter;
Alex Lighta01de592016-11-15 10:43:06 -0800368};
369
370} // namespace openjdkjvmti
371
Andreas Gampe06c42a52017-07-26 14:17:14 -0700372#endif // ART_OPENJDKJVMTI_TI_REDEFINE_H_