On Fri, 18 Nov 2022 05:21:02 GMT, Chris Plummer <[email protected]> wrote:
> What I believe to be the flaw here is that you call
> `set_notify_jvmti_events(true)`
> even if you don't call `init_static_notify_jvmti_events()`.
This only happen in a detached thread case which can be only at startup.
It was implemented this way before my fix.
The javaClasses has to be partially initialized before any call to
`init_static_notify_jvmti_events()`:
void javaClasses_init() {
JavaClasses::compute_offsets(); <== This is needed
JavaClasses::check_offsets();
java_lang_VirtualThread::init_static_notify_jvmti_events();
FilteredFieldsMap::initialize(); // must be done after computing offsets.
}
For detached thread case (which is at starup) it is guaranteed that the
`init_static_notify_jvmti_events()` is unconditionally called later at
initialization stage. Please, see the chain of calls:
`create_vm() => init_globals() => javaClasses_init() =>
java_lang_VirtualThread::init_static_notify_jvmti_events()`.
-------------
PR: https://git.openjdk.org/jdk/pull/11204