diff --git a/hotspot/src/share/vm/prims/jvmti.xml b/hotspot/src/share/vm/prims/jvmti.xml
index 067a8aceb97..54af0643f3b 100644
--- a/hotspot/src/share/vm/prims/jvmti.xml
+++ b/hotspot/src/share/vm/prims/jvmti.xml
@@ -9995,6 +9995,17 @@ myInit() {
See .
+
+
+ Can generate the events
+ in the primordial phase. If this capability and
+
+ can_generate_all_class_hook_events
+ are enabled then the events
+ can be posted for classes loaded in the primordial phase.
+ See .
+
+
@@ -12405,7 +12416,7 @@ myInit() {
-
This event is sent when the VM obtains class file data,
@@ -12421,7 +12432,13 @@ myInit() {
bytecode instrumentation
for usage information.
- This event may be sent before the VM is initialized (the start
+ When the capabilities
+
+ can_generate_early_class_hook_events
and
+
+ can_generate_all_class_hook_events
+ are enabled then this event may be sent in the primordial phase.
+ Otherwise, this event may be sent before the VM is initialized (the start
phase).
Some classes might not be compatible
with the function (eg. ROMized classes) and this event will not be
@@ -12471,6 +12488,7 @@ myInit() {
jvmpi
+
@@ -12543,7 +12561,7 @@ myInit() {
- The VM initialization event signals the start of the VM.
+ The VM start event signals the start of the VM.
At this time JNI is live but the VM is not yet fully initialized.
Once this event is generated, the agent is free to call any JNI function.
This event signals the beginning of the start phase,
@@ -14420,6 +14438,10 @@ typedef void (JNICALL *jvmtiEventVMInit)
- Add new capability can_generate_early_vmstart
- Allow CompiledMethodLoad events at start phase
+
+ Support for modules:
+ - Add new capability can_generate_early_class_hook_events
+
diff --git a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp
index 1c199bd18ba..04e68694459 100644
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp
@@ -162,6 +162,11 @@ class JvmtiEnvBase : public CHeapObj {
jvmtiCapabilities *get_prohibited_capabilities() { return &_prohibited_capabilities; }
+ bool early_class_hook_env() {
+ return get_capabilities()->can_generate_early_class_hook_events != 0
+ && get_capabilities()->can_generate_all_class_hook_events != 0;
+ }
+
bool early_vmstart_env() {
return get_capabilities()->can_generate_early_vmstart != 0;
}
diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp
index 1be139cbcff..a388f29dc9e 100644
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp
@@ -667,7 +667,7 @@ class JvmtiClassFileLoadHookPoster : public StackObj {
}
void post_to_env(JvmtiEnv* env, bool caching_needed) {
- if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
+ if (env->phase() == JVMTI_PHASE_PRIMORDIAL && !env->early_class_hook_env()) {
return;
}
unsigned char *new_data = NULL;
diff --git a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp
index 1166ed6f004..e0c3cb5c34b 100644
--- a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp
@@ -136,6 +136,7 @@ jvmtiCapabilities JvmtiManageCapabilities::init_onload_capabilities() {
jc.can_get_owned_monitor_stack_depth_info = 1;
jc.can_get_current_contended_monitor = 1;
jc.can_generate_early_vmstart = 1;
+ jc.can_generate_early_class_hook_events = 1;
return jc;
}
@@ -456,6 +457,8 @@ void JvmtiManageCapabilities:: print(const jvmtiCapabilities* cap) {
log_trace(jvmti)("can_generate_resource_exhaustion_threads_events");
if (cap->can_generate_early_vmstart)
log_trace(jvmti)("can_generate_early_vmstart");
+ if (cap->can_generate_early_class_hook_events)
+ log_trace(jvmti)("can_generate_early_class_hook_events");
}
#endif