diff options
author | 2019-10-15 15:46:07 -0700 | |
---|---|---|
committer | 2019-10-30 16:53:25 -0700 | |
commit | d55b844e39c4d5eb1a56de6cb95c891659f8a27f (patch) | |
tree | ed2f7809528e8b44985edc12d75fb0965806045f /openjdkjvmti/events.h | |
parent | 436c6f5fae95aae332361060778599d0ef24a167 (diff) |
Add more standard structural redefinition entrypoints
Add structural redefinition extension function and event that mirror
the 'RedefineClasses' function and 'ClassFileLoadHook' event. The new
extension function is called
'com.android.art.class.structurally_redefine_classes' and the new
extension event is called
'com.android.art.class.structural_dex_file_load_hook'.
These extensions are the preferred way to use structural redefinition.
Like the standard 'RedefineClasses' multiple classes may be redefined
at a time.
The structural_dex_file_load_hook is triggered prior to the
can_retransform_classes ClassFileLoadHook. It is triggered on all
classes, even ones that cannot be structurally changed by
class-loading, class redefinition or by calling the RetransformClasses
function.
Calling 'structurally_redefine_classes' with new definitions that do
not require structural changes will fall back to non-structural
redefinition.
Test: ./test.py --host
Bug: 134162467
Change-Id: If4810930470c5c6509cf6db779910006e114b39f
Diffstat (limited to 'openjdkjvmti/events.h')
-rw-r--r-- | openjdkjvmti/events.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/openjdkjvmti/events.h b/openjdkjvmti/events.h index d5ab4fbc98..c9d587af94 100644 --- a/openjdkjvmti/events.h +++ b/openjdkjvmti/events.h @@ -81,7 +81,8 @@ enum class ArtJvmtiEvent : jint { kClassFileLoadHookRetransformable = JVMTI_MAX_EVENT_TYPE_VAL + 1, kDdmPublishChunk = JVMTI_MAX_EVENT_TYPE_VAL + 2, kObsoleteObjectCreated = JVMTI_MAX_EVENT_TYPE_VAL + 3, - kMaxNormalEventTypeVal = kObsoleteObjectCreated, + kStructuralDexFileLoadHook = JVMTI_MAX_EVENT_TYPE_VAL + 4, + kMaxNormalEventTypeVal = kStructuralDexFileLoadHook, // All that follow are events used to implement internal JVMTI functions. They are not settable // directly by agents. @@ -107,6 +108,17 @@ using ArtJvmtiEventObsoleteObjectCreated = void (*)(jvmtiEnv *jvmti_env, jlong* obsolete_tag, jlong* new_tag); +using ArtJvmtiEventStructuralDexFileLoadHook = void (*)(jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jclass class_being_redefined, + jobject loader, + const char* name, + jobject protection_domain, + jint dex_data_len, + const unsigned char* dex_data, + jint* new_dex_data_len, + unsigned char** new_dex_data); + // It is not enough to store a Thread pointer, as these may be reused. Use the pointer and the // thread id. // Note: We could just use the tid like tracing does. @@ -119,7 +131,10 @@ struct UniqueThreadHasher { }; struct ArtJvmtiEventCallbacks : jvmtiEventCallbacks { - ArtJvmtiEventCallbacks() : DdmPublishChunk(nullptr), ObsoleteObjectCreated(nullptr) { + ArtJvmtiEventCallbacks() + : DdmPublishChunk(nullptr), + ObsoleteObjectCreated(nullptr), + StructuralDexFileLoadHook(nullptr) { memset(this, 0, sizeof(jvmtiEventCallbacks)); } @@ -131,6 +146,7 @@ struct ArtJvmtiEventCallbacks : jvmtiEventCallbacks { ArtJvmtiEventDdmPublishChunk DdmPublishChunk; ArtJvmtiEventObsoleteObjectCreated ObsoleteObjectCreated; + ArtJvmtiEventStructuralDexFileLoadHook StructuralDexFileLoadHook; }; bool IsExtensionEvent(jint e); |