Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8291456: com/sun/jdi/ClassUnloadEventTest.java failed with: Wrong number of class unload events: expected 10 got 4 #832

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/hotspot/share/prims/jvmtiEventController.cpp
Expand Up @@ -830,10 +830,6 @@ JvmtiEventControllerPrivate::set_user_enabled(JvmtiEnvBase *env, JavaThread *thr
thread==NULL? "ALL": JvmtiTrace::safe_get_thread_name(thread),
enabled? "enabled" : "disabled", JvmtiTrace::event_name(event_type)));

if (event_type == JVMTI_EVENT_OBJECT_FREE) {
flush_object_free_events(env);
}

if (thread == NULL) {
env->env_event_enable()->set_user_enabled(event_type, enabled);
} else {
Expand Down Expand Up @@ -982,6 +978,10 @@ JvmtiEventController::is_global_event(jvmtiEvent event_type) {

void
JvmtiEventController::set_user_enabled(JvmtiEnvBase *env, JavaThread *thread, jvmtiEvent event_type, bool enabled) {
if (event_type == JVMTI_EVENT_OBJECT_FREE) {
JvmtiEventControllerPrivate::flush_object_free_events(env);
}

if (Threads::number_of_threads() == 0) {
// during early VM start-up locks don't exist, but we are safely single threaded,
// call the functionality without holding the JvmtiThreadState_lock.
Expand Down
14 changes: 11 additions & 3 deletions src/hotspot/share/prims/jvmtiExport.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -730,6 +730,8 @@ void JvmtiExport::post_vm_initialized() {
void JvmtiExport::post_vm_death() {
EVT_TRIG_TRACE(JVMTI_EVENT_VM_DEATH, ("Trg VM death event triggered" ));

JvmtiTagMap::flush_all_object_free_events();

JvmtiEnvIterator it;
for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
if (env->is_enabled(JVMTI_EVENT_VM_DEATH)) {
Expand Down Expand Up @@ -1490,15 +1492,21 @@ void JvmtiExport::post_thread_end(JavaThread *thread) {
}
}

void JvmtiExport::post_object_free(JvmtiEnv* env, jlong tag) {
void JvmtiExport::post_object_free(JvmtiEnv* env, GrowableArray<jlong>* objects) {
assert(objects != NULL, "Nothing to post");
assert(env->is_enabled(JVMTI_EVENT_OBJECT_FREE), "checking");

EVT_TRIG_TRACE(JVMTI_EVENT_OBJECT_FREE, ("[?] Trg Object Free triggered" ));
EVT_TRACE(JVMTI_EVENT_OBJECT_FREE, ("[?] Evt Object Free sent"));

JavaThread* javaThread = JavaThread::current();
JvmtiThreadEventMark jem(javaThread);
JvmtiJavaThreadEventTransition jet(javaThread);
jvmtiEventObjectFree callback = env->callbacks()->ObjectFree;
if (callback != NULL) {
(*callback)(env->jvmti_external(), tag);
for (int index = 0; index < objects->length(); index++) {
(*callback)(env->jvmti_external(), objects->at(index));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/prims/jvmtiExport.hpp
Expand Up @@ -370,7 +370,7 @@ class JvmtiExport : public AllStatic {
static void post_monitor_contended_entered(JavaThread *thread, ObjectMonitor *obj_mntr) NOT_JVMTI_RETURN;
static void post_monitor_wait(JavaThread *thread, oop obj, jlong timeout) NOT_JVMTI_RETURN;
static void post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mntr, jboolean timed_out) NOT_JVMTI_RETURN;
static void post_object_free(JvmtiEnv* env, jlong tag) NOT_JVMTI_RETURN;
static void post_object_free(JvmtiEnv* env, GrowableArray<jlong>* objects) NOT_JVMTI_RETURN;
static void post_resource_exhausted(jint resource_exhausted_flags, const char* detail) NOT_JVMTI_RETURN;
static void record_vm_internal_object_allocation(oop object) NOT_JVMTI_RETURN;
// Post objects collected by vm_object_alloc_event_collector.
Expand Down