diff options
Diffstat (limited to 'openjdkjvmti')
-rw-r--r-- | openjdkjvmti/OpenjdkJvmTi.cc | 179 | ||||
-rw-r--r-- | openjdkjvmti/art_jvmti.h | 68 | ||||
-rw-r--r-- | openjdkjvmti/deopt_manager.cc | 31 | ||||
-rw-r--r-- | openjdkjvmti/deopt_manager.h | 7 | ||||
-rw-r--r-- | openjdkjvmti/fixed_up_dex_file.cc | 6 | ||||
-rw-r--r-- | openjdkjvmti/ti_class.cc | 14 | ||||
-rw-r--r-- | openjdkjvmti/ti_redefine.cc | 14 | ||||
-rw-r--r-- | openjdkjvmti/ti_search.cc | 4 |
8 files changed, 212 insertions, 111 deletions
diff --git a/openjdkjvmti/OpenjdkJvmTi.cc b/openjdkjvmti/OpenjdkJvmTi.cc index aae805569f..027635bbb5 100644 --- a/openjdkjvmti/OpenjdkJvmTi.cc +++ b/openjdkjvmti/OpenjdkJvmTi.cc @@ -83,6 +83,12 @@ DeoptManager gDeoptManager; } \ } while (false) +// Returns whether we are able to use all jvmti features. +static bool IsFullJvmtiAvailable() { + art::Runtime* runtime = art::Runtime::Current(); + return runtime->GetInstrumentation()->IsForcedInterpretOnly() || runtime->IsJavaDebuggable(); +} + class JvmtiFunctions { private: static jvmtiError getEnvironmentError(jvmtiEnv* env) { @@ -1092,10 +1098,64 @@ class JvmtiFunctions { &gEventHandler); } +#define FOR_ALL_CAPABILITIES(FUN) \ + FUN(can_tag_objects) \ + FUN(can_generate_field_modification_events) \ + FUN(can_generate_field_access_events) \ + FUN(can_get_bytecodes) \ + FUN(can_get_synthetic_attribute) \ + FUN(can_get_owned_monitor_info) \ + FUN(can_get_current_contended_monitor) \ + FUN(can_get_monitor_info) \ + FUN(can_pop_frame) \ + FUN(can_redefine_classes) \ + FUN(can_signal_thread) \ + FUN(can_get_source_file_name) \ + FUN(can_get_line_numbers) \ + FUN(can_get_source_debug_extension) \ + FUN(can_access_local_variables) \ + FUN(can_maintain_original_method_order) \ + FUN(can_generate_single_step_events) \ + FUN(can_generate_exception_events) \ + FUN(can_generate_frame_pop_events) \ + FUN(can_generate_breakpoint_events) \ + FUN(can_suspend) \ + FUN(can_redefine_any_class) \ + FUN(can_get_current_thread_cpu_time) \ + FUN(can_get_thread_cpu_time) \ + FUN(can_generate_method_entry_events) \ + FUN(can_generate_method_exit_events) \ + FUN(can_generate_all_class_hook_events) \ + FUN(can_generate_compiled_method_load_events) \ + FUN(can_generate_monitor_events) \ + FUN(can_generate_vm_object_alloc_events) \ + FUN(can_generate_native_method_bind_events) \ + FUN(can_generate_garbage_collection_events) \ + FUN(can_generate_object_free_events) \ + FUN(can_force_early_return) \ + FUN(can_get_owned_monitor_stack_depth_info) \ + FUN(can_get_constant_pool) \ + FUN(can_set_native_method_prefix) \ + FUN(can_retransform_classes) \ + FUN(can_retransform_any_class) \ + FUN(can_generate_resource_exhaustion_heap_events) \ + FUN(can_generate_resource_exhaustion_threads_events) + static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) { ENSURE_VALID_ENV(env); ENSURE_NON_NULL(capabilities_ptr); *capabilities_ptr = kPotentialCapabilities; + if (UNLIKELY(!IsFullJvmtiAvailable())) { +#define REMOVE_NONDEBUGGABLE_UNSUPPORTED(e) \ + do { \ + if (kNonDebuggableUnsupportedCapabilities.e == 1) { \ + capabilities_ptr->e = 0; \ + } \ + } while (false); + + FOR_ALL_CAPABILITIES(REMOVE_NONDEBUGGABLE_UNSUPPORTED); +#undef REMOVE_NONDEBUGGABLE_UNSUPPORTED + } return OK; } @@ -1122,49 +1182,9 @@ class JvmtiFunctions { ret = ERR(NOT_AVAILABLE); \ } \ } \ - } while (false) - - ADD_CAPABILITY(can_tag_objects); - ADD_CAPABILITY(can_generate_field_modification_events); - ADD_CAPABILITY(can_generate_field_access_events); - ADD_CAPABILITY(can_get_bytecodes); - ADD_CAPABILITY(can_get_synthetic_attribute); - ADD_CAPABILITY(can_get_owned_monitor_info); - ADD_CAPABILITY(can_get_current_contended_monitor); - ADD_CAPABILITY(can_get_monitor_info); - ADD_CAPABILITY(can_pop_frame); - ADD_CAPABILITY(can_redefine_classes); - ADD_CAPABILITY(can_signal_thread); - ADD_CAPABILITY(can_get_source_file_name); - ADD_CAPABILITY(can_get_line_numbers); - ADD_CAPABILITY(can_get_source_debug_extension); - ADD_CAPABILITY(can_access_local_variables); - ADD_CAPABILITY(can_maintain_original_method_order); - ADD_CAPABILITY(can_generate_single_step_events); - ADD_CAPABILITY(can_generate_exception_events); - ADD_CAPABILITY(can_generate_frame_pop_events); - ADD_CAPABILITY(can_generate_breakpoint_events); - ADD_CAPABILITY(can_suspend); - ADD_CAPABILITY(can_redefine_any_class); - ADD_CAPABILITY(can_get_current_thread_cpu_time); - ADD_CAPABILITY(can_get_thread_cpu_time); - ADD_CAPABILITY(can_generate_method_entry_events); - ADD_CAPABILITY(can_generate_method_exit_events); - ADD_CAPABILITY(can_generate_all_class_hook_events); - ADD_CAPABILITY(can_generate_compiled_method_load_events); - ADD_CAPABILITY(can_generate_monitor_events); - ADD_CAPABILITY(can_generate_vm_object_alloc_events); - ADD_CAPABILITY(can_generate_native_method_bind_events); - ADD_CAPABILITY(can_generate_garbage_collection_events); - ADD_CAPABILITY(can_generate_object_free_events); - ADD_CAPABILITY(can_force_early_return); - ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info); - ADD_CAPABILITY(can_get_constant_pool); - ADD_CAPABILITY(can_set_native_method_prefix); - ADD_CAPABILITY(can_retransform_classes); - ADD_CAPABILITY(can_retransform_any_class); - ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events); - ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events); + } while (false); + + FOR_ALL_CAPABILITIES(ADD_CAPABILITY); #undef ADD_CAPABILITY gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env), changed, @@ -1186,49 +1206,9 @@ class JvmtiFunctions { changed.e = 1; \ } \ } \ - } while (false) - - DEL_CAPABILITY(can_tag_objects); - DEL_CAPABILITY(can_generate_field_modification_events); - DEL_CAPABILITY(can_generate_field_access_events); - DEL_CAPABILITY(can_get_bytecodes); - DEL_CAPABILITY(can_get_synthetic_attribute); - DEL_CAPABILITY(can_get_owned_monitor_info); - DEL_CAPABILITY(can_get_current_contended_monitor); - DEL_CAPABILITY(can_get_monitor_info); - DEL_CAPABILITY(can_pop_frame); - DEL_CAPABILITY(can_redefine_classes); - DEL_CAPABILITY(can_signal_thread); - DEL_CAPABILITY(can_get_source_file_name); - DEL_CAPABILITY(can_get_line_numbers); - DEL_CAPABILITY(can_get_source_debug_extension); - DEL_CAPABILITY(can_access_local_variables); - DEL_CAPABILITY(can_maintain_original_method_order); - DEL_CAPABILITY(can_generate_single_step_events); - DEL_CAPABILITY(can_generate_exception_events); - DEL_CAPABILITY(can_generate_frame_pop_events); - DEL_CAPABILITY(can_generate_breakpoint_events); - DEL_CAPABILITY(can_suspend); - DEL_CAPABILITY(can_redefine_any_class); - DEL_CAPABILITY(can_get_current_thread_cpu_time); - DEL_CAPABILITY(can_get_thread_cpu_time); - DEL_CAPABILITY(can_generate_method_entry_events); - DEL_CAPABILITY(can_generate_method_exit_events); - DEL_CAPABILITY(can_generate_all_class_hook_events); - DEL_CAPABILITY(can_generate_compiled_method_load_events); - DEL_CAPABILITY(can_generate_monitor_events); - DEL_CAPABILITY(can_generate_vm_object_alloc_events); - DEL_CAPABILITY(can_generate_native_method_bind_events); - DEL_CAPABILITY(can_generate_garbage_collection_events); - DEL_CAPABILITY(can_generate_object_free_events); - DEL_CAPABILITY(can_force_early_return); - DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info); - DEL_CAPABILITY(can_get_constant_pool); - DEL_CAPABILITY(can_set_native_method_prefix); - DEL_CAPABILITY(can_retransform_classes); - DEL_CAPABILITY(can_retransform_any_class); - DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events); - DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events); + } while (false); + + FOR_ALL_CAPABILITIES(DEL_CAPABILITY); #undef DEL_CAPABILITY gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env), changed, @@ -1236,6 +1216,8 @@ class JvmtiFunctions { return OK; } +#undef FOR_ALL_CAPABILITIES + static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) { ENSURE_VALID_ENV(env); ENSURE_NON_NULL(capabilities_ptr); @@ -1341,7 +1323,7 @@ class JvmtiFunctions { static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) { ENSURE_VALID_ENV(env); - *version_ptr = JVMTI_VERSION; + *version_ptr = ArtJvmTiEnv::AsArtJvmTiEnv(env)->ti_version; return OK; } @@ -1495,9 +1477,10 @@ static bool IsJvmtiVersion(jint version) { extern const jvmtiInterface_1 gJvmtiInterface; -ArtJvmTiEnv::ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler) +ArtJvmTiEnv::ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler, jint version) : art_vm(runtime), local_data(nullptr), + ti_version(version), capabilities(), event_info_mutex_("jvmtiEnv_EventInfoMutex") { object_tag_table = std::unique_ptr<ObjectTagTable>(new ObjectTagTable(event_handler, this)); @@ -1506,8 +1489,8 @@ ArtJvmTiEnv::ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler) // Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti // is a pointer to the uninitialized memory for an art::ti::Env. -static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) { - struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm, &gEventHandler); +static void CreateArtJvmTiEnv(art::JavaVMExt* vm, jint version, /*out*/void** new_jvmtiEnv) { + struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm, &gEventHandler, version); *new_jvmtiEnv = env; gEventHandler.RegisterArtJvmTiEnv(env); @@ -1520,8 +1503,14 @@ static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) { // places the return value in 'env' if this library can handle the GetEnv request. Otherwise // returns false and does not modify the 'env' pointer. static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) { - if (IsJvmtiVersion(version)) { - CreateArtJvmTiEnv(vm, env); + // JavaDebuggable will either be set by the runtime as it is starting up or the plugin if it's + // loaded early enough. If this is false we cannot guarantee conformance to all JVMTI behaviors + // due to optimizations. We will only allow agents to get ArtTiEnvs using the kArtTiVersion. + if (IsFullJvmtiAvailable() && IsJvmtiVersion(version)) { + CreateArtJvmTiEnv(vm, JVMTI_VERSION, env); + return JNI_OK; + } else if (version == kArtTiVersion) { + CreateArtJvmTiEnv(vm, kArtTiVersion, env); return JNI_OK; } else { printf("version 0x%x is not valid!", version); @@ -1547,6 +1536,12 @@ extern "C" bool ArtPlugin_Initialize() { SearchUtil::Register(); HeapUtil::Register(); + { + // Make sure we can deopt anything we need to. + art::ScopedObjectAccess soa(art::Thread::Current()); + gDeoptManager.FinishSetup(); + } + runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler); return true; diff --git a/openjdkjvmti/art_jvmti.h b/openjdkjvmti/art_jvmti.h index 2a8c2e91df..73cc601e3e 100644 --- a/openjdkjvmti/art_jvmti.h +++ b/openjdkjvmti/art_jvmti.h @@ -62,10 +62,22 @@ namespace openjdkjvmti { class ObjectTagTable; +// A special version that we use to identify special tooling interface versions which mostly matches +// the jvmti spec but everything is best effort. This is used to implement the userdebug +// 'debug-anything' behavior. +// +// This is the value 0x70010200. +static constexpr jint kArtTiVersion = JVMTI_VERSION_1_2 | 0x40000000; + // A structure that is a jvmtiEnv with additional information for the runtime. struct ArtJvmTiEnv : public jvmtiEnv { art::JavaVMExt* art_vm; void* local_data; + + // The ti_version we are compatible with. This is only for giving the correct value for GetVersion + // when running on a userdebug/eng device. + jint ti_version; + jvmtiCapabilities capabilities; EventMasks event_masks; @@ -90,7 +102,7 @@ struct ArtJvmTiEnv : public jvmtiEnv { // RW lock to protect access to all of the event data. art::ReaderWriterMutex event_info_mutex_ DEFAULT_MUTEX_ACQUIRED_AFTER; - ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler); + ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler, jint ti_version); static ArtJvmTiEnv* AsArtJvmTiEnv(jvmtiEnv* env) { return art::down_cast<ArtJvmTiEnv*>(env); @@ -272,6 +284,60 @@ const jvmtiCapabilities kPotentialCapabilities = { .can_generate_resource_exhaustion_threads_events = 0, }; +// These are capabilities that are disabled if we were loaded without being debuggable. +// +// This includes the following capabilities: +// can_retransform_any_class: +// can_retransform_classes: +// can_redefine_any_class: +// can_redefine_classes: +// We need to ensure that inlined code is either not present or can always be deoptimized. This +// is not guaranteed for non-debuggable processes since we might have inlined bootclasspath code +// on a threads stack. +const jvmtiCapabilities kNonDebuggableUnsupportedCapabilities = { + .can_tag_objects = 0, + .can_generate_field_modification_events = 0, + .can_generate_field_access_events = 0, + .can_get_bytecodes = 0, + .can_get_synthetic_attribute = 0, + .can_get_owned_monitor_info = 0, + .can_get_current_contended_monitor = 0, + .can_get_monitor_info = 0, + .can_pop_frame = 0, + .can_redefine_classes = 1, + .can_signal_thread = 0, + .can_get_source_file_name = 0, + .can_get_line_numbers = 0, + .can_get_source_debug_extension = 0, + .can_access_local_variables = 0, + .can_maintain_original_method_order = 0, + .can_generate_single_step_events = 0, + .can_generate_exception_events = 0, + .can_generate_frame_pop_events = 0, + .can_generate_breakpoint_events = 0, + .can_suspend = 0, + .can_redefine_any_class = 1, + .can_get_current_thread_cpu_time = 0, + .can_get_thread_cpu_time = 0, + .can_generate_method_entry_events = 0, + .can_generate_method_exit_events = 0, + .can_generate_all_class_hook_events = 0, + .can_generate_compiled_method_load_events = 0, + .can_generate_monitor_events = 0, + .can_generate_vm_object_alloc_events = 0, + .can_generate_native_method_bind_events = 0, + .can_generate_garbage_collection_events = 0, + .can_generate_object_free_events = 0, + .can_force_early_return = 0, + .can_get_owned_monitor_stack_depth_info = 0, + .can_get_constant_pool = 0, + .can_set_native_method_prefix = 0, + .can_retransform_classes = 1, + .can_retransform_any_class = 1, + .can_generate_resource_exhaustion_heap_events = 0, + .can_generate_resource_exhaustion_threads_events = 0, +}; + } // namespace openjdkjvmti #endif // ART_OPENJDKJVMTI_ART_JVMTI_H_ diff --git a/openjdkjvmti/deopt_manager.cc b/openjdkjvmti/deopt_manager.cc index aced769cb5..53d84836fc 100644 --- a/openjdkjvmti/deopt_manager.cc +++ b/openjdkjvmti/deopt_manager.cc @@ -68,7 +68,9 @@ bool JvmtiMethodInspectionCallback::IsMethodSafeToJit(art::ArtMethod* method) { } DeoptManager::DeoptManager() - : deoptimization_status_lock_("JVMTI_DeoptimizationStatusLock"), + : deoptimization_status_lock_("JVMTI_DeoptimizationStatusLock", + static_cast<art::LockLevel>( + art::LockLevel::kClassLinkerClassesLock + 1)), deoptimization_condition_("JVMTI_DeoptimizationCondition", deoptimization_status_lock_), performing_deoptimization_(false), global_deopt_count_(0), @@ -91,6 +93,33 @@ void DeoptManager::Shutdown() { callbacks->RemoveMethodInspectionCallback(&inspection_callback_); } +void DeoptManager::FinishSetup() { + art::Thread* self = art::Thread::Current(); + art::MutexLock mu(self, deoptimization_status_lock_); + + art::Runtime* runtime = art::Runtime::Current(); + // See if we need to do anything. + if (!runtime->IsJavaDebuggable()) { + // See if we can enable all JVMTI functions. If this is false, only kArtTiVersion agents can be + // retrieved and they will all be best-effort. + if (PhaseUtil::GetPhaseUnchecked() == JVMTI_PHASE_ONLOAD) { + // We are still early enough to change the compiler options and get full JVMTI support. + LOG(INFO) << "Openjdkjvmti plugin loaded on a non-debuggable runtime. Changing runtime to " + << "debuggable state. Please pass '--debuggable' to dex2oat and " + << "'-Xcompiler-option --debuggable' to dalvikvm in the future."; + DCHECK(runtime->GetJit() == nullptr) << "Jit should not be running yet!"; + runtime->AddCompilerOption("--debuggable"); + runtime->SetJavaDebuggable(true); + } else { + LOG(WARNING) << "Openjdkjvmti plugin was loaded on a non-debuggable Runtime. Plugin was " + << "loaded too late to change runtime state to DEBUGGABLE. Only kArtTiVersion " + << "(0x" << std::hex << kArtTiVersion << ") environments are available. Some " + << "functionality might not work properly."; + } + runtime->DeoptimizeBootImage(); + } +} + bool DeoptManager::MethodHasBreakpoints(art::ArtMethod* method) { art::MutexLock lk(art::Thread::Current(), deoptimization_status_lock_); return MethodHasBreakpointsLocked(method); diff --git a/openjdkjvmti/deopt_manager.h b/openjdkjvmti/deopt_manager.h index b265fa8ec2..a495b6835c 100644 --- a/openjdkjvmti/deopt_manager.h +++ b/openjdkjvmti/deopt_manager.h @@ -101,6 +101,10 @@ class DeoptManager { void DeoptimizeThread(art::Thread* target) REQUIRES_SHARED(art::Locks::mutator_lock_); void DeoptimizeAllThreads() REQUIRES_SHARED(art::Locks::mutator_lock_); + void FinishSetup() + REQUIRES(!deoptimization_status_lock_, !art::Roles::uninterruptible_) + REQUIRES_SHARED(art::Locks::mutator_lock_); + static DeoptManager* Get(); private: @@ -141,9 +145,8 @@ class DeoptManager { REQUIRES(!art::Roles::uninterruptible_, !art::Locks::mutator_lock_); static constexpr const char* kDeoptManagerInstrumentationKey = "JVMTI_DeoptManager"; - // static constexpr const char* kDeoptManagerThreadName = "JVMTI_DeoptManagerWorkerThread"; - art::Mutex deoptimization_status_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; + art::Mutex deoptimization_status_lock_ ACQUIRED_BEFORE(art::Locks::classlinker_classes_lock_); art::ConditionVariable deoptimization_condition_ GUARDED_BY(deoptimization_status_lock_); bool performing_deoptimization_ GUARDED_BY(deoptimization_status_lock_); diff --git a/openjdkjvmti/fixed_up_dex_file.cc b/openjdkjvmti/fixed_up_dex_file.cc index da7d60ac2f..963c6f8444 100644 --- a/openjdkjvmti/fixed_up_dex_file.cc +++ b/openjdkjvmti/fixed_up_dex_file.cc @@ -30,6 +30,7 @@ */ #include "fixed_up_dex_file.h" +#include "dex/art_dex_file_loader.h" #include "dex/dex_file-inl.h" #include "dex/dex_file_loader.h" @@ -72,7 +73,8 @@ std::unique_ptr<FixedUpDexFile> FixedUpDexFile::Create(const art::DexFile& origi data.resize(original.Size()); memcpy(data.data(), original.Begin(), original.Size()); std::string error; - std::unique_ptr<const art::DexFile> new_dex_file(art::DexFileLoader::Open( + const art::ArtDexFileLoader dex_file_loader; + std::unique_ptr<const art::DexFile> new_dex_file(dex_file_loader.Open( data.data(), data.size(), /*location*/"Unquickening_dexfile.dex", @@ -103,7 +105,7 @@ std::unique_ptr<FixedUpDexFile> FixedUpDexFile::Create(const art::DexFile& origi // Overwrite the dex file stored in data with the new result. data.clear(); data.insert(data.end(), mem_map->Begin(), mem_map->Begin() + dex_file_size); - new_dex_file = art::DexFileLoader::Open( + new_dex_file = dex_file_loader.Open( data.data(), data.size(), /*location*/"Unquickening_dexfile.dex", diff --git a/openjdkjvmti/ti_class.cc b/openjdkjvmti/ti_class.cc index f9eb008af2..b3f5c1886e 100644 --- a/openjdkjvmti/ti_class.cc +++ b/openjdkjvmti/ti_class.cc @@ -42,6 +42,7 @@ #include "class_linker.h" #include "class_table-inl.h" #include "common_throws.h" +#include "dex/art_dex_file_loader.h" #include "dex/dex_file_annotations.h" #include "dex/dex_file_loader.h" #include "events-inl.h" @@ -107,12 +108,13 @@ static std::unique_ptr<const art::DexFile> MakeSingleDexFile(art::Thread* self, } uint32_t checksum = reinterpret_cast<const art::DexFile::Header*>(map->Begin())->checksum_; std::string map_name = map->GetName(); - std::unique_ptr<const art::DexFile> dex_file(art::DexFileLoader::Open(map_name, - checksum, - std::move(map), - /*verify*/true, - /*verify_checksum*/true, - &error_msg)); + const art::ArtDexFileLoader dex_file_loader; + std::unique_ptr<const art::DexFile> dex_file(dex_file_loader.Open(map_name, + checksum, + std::move(map), + /*verify*/true, + /*verify_checksum*/true, + &error_msg)); if (dex_file.get() == nullptr) { LOG(WARNING) << "Unable to load modified dex file for " << descriptor << ": " << error_msg; art::ThrowClassFormatError(nullptr, diff --git a/openjdkjvmti/ti_redefine.cc b/openjdkjvmti/ti_redefine.cc index 6194d1e42c..717b2ba669 100644 --- a/openjdkjvmti/ti_redefine.cc +++ b/openjdkjvmti/ti_redefine.cc @@ -43,6 +43,7 @@ #include "base/stringpiece.h" #include "class_linker-inl.h" #include "debugger.h" +#include "dex/art_dex_file_loader.h" #include "dex/dex_file.h" #include "dex/dex_file_loader.h" #include "dex/dex_file_types.h" @@ -426,12 +427,13 @@ jvmtiError Redefiner::AddRedefinition(ArtJvmTiEnv* env, const ArtClassDefinition return ERR(INVALID_CLASS_FORMAT); } uint32_t checksum = reinterpret_cast<const art::DexFile::Header*>(map->Begin())->checksum_; - std::unique_ptr<const art::DexFile> dex_file(art::DexFileLoader::Open(map->GetName(), - checksum, - std::move(map), - /*verify*/true, - /*verify_checksum*/true, - error_msg_)); + const art::ArtDexFileLoader dex_file_loader; + std::unique_ptr<const art::DexFile> dex_file(dex_file_loader.Open(map->GetName(), + checksum, + std::move(map), + /*verify*/true, + /*verify_checksum*/true, + error_msg_)); if (dex_file.get() == nullptr) { os << "Unable to load modified dex file for " << def.GetName() << ": " << *error_msg_; *error_msg_ = os.str(); diff --git a/openjdkjvmti/ti_search.cc b/openjdkjvmti/ti_search.cc index 9d5f4ea3f9..cbb7b53bff 100644 --- a/openjdkjvmti/ti_search.cc +++ b/openjdkjvmti/ti_search.cc @@ -38,6 +38,7 @@ #include "base/enums.h" #include "base/macros.h" #include "class_linker.h" +#include "dex/art_dex_file_loader.h" #include "dex/dex_file.h" #include "dex/dex_file_loader.h" #include "jni_internal.h" @@ -227,7 +228,8 @@ jvmtiError SearchUtil::AddToBootstrapClassLoaderSearch(jvmtiEnv* env ATTRIBUTE_U std::string error_msg; std::vector<std::unique_ptr<const art::DexFile>> dex_files; - if (!art::DexFileLoader::Open( + const art::ArtDexFileLoader dex_file_loader; + if (!dex_file_loader.Open( segment, segment, /* verify */ true, /* verify_checksum */ true, &error_msg, &dex_files)) { LOG(WARNING) << "Could not open " << segment << " for boot classpath extension: " << error_msg; return ERR(ILLEGAL_ARGUMENT); |