--- old/src/hotspot/share/prims/jvmtiImpl.cpp 2019-11-22 14:30:46.057696313 -0500 +++ new/src/hotspot/share/prims/jvmtiImpl.cpp 2019-11-22 14:30:45.797689497 -0500 @@ -943,6 +943,16 @@ return event; } +JvmtiDeferredEvent JvmtiDeferredEvent::class_unload_event(const char* name) { + JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_CLASS_UNLOADED); + // Need to make a copy of the name since we don't know how long + // the event poster will keep it around after we enqueue the + // deferred event and return. strdup() failure is handled in + // the post() routine below. + event._event_data.class_unloaded.name = os::strdup(name); + return event; +} + void JvmtiDeferredEvent::post() { assert(ServiceThread::is_service_thread(Thread::current()), "Service thread must post enqueued events"); @@ -976,6 +986,17 @@ } break; } + case TYPE_CLASS_UNLOADED: { + JvmtiExport::post_class_unload_internal( + // if strdup failed give the event a default name + (_event_data.class_unloaded.name == NULL) + ? "unknown_class" : _event_data.class_unloaded.name); + if (_event_data.class_unloaded.name != NULL) { + // release our copy + os::free((void *)_event_data.class_unloaded.name); + } + break; + } default: ShouldNotReachHere(); }