< prev index next >
test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/ex03t001.cpp
Print this page
@@ -39,22 +39,19 @@
/* ============================================================================= */
static void JNICALL
-ClassUnload(jvmtiEnv* jvmti_env, JNIEnv *jni_env, jthread thread, jclass klass, ...) {
- /*
- * With the CMS GC the event can be posted on
- * a ConcurrentGC thread that is not a JavaThread.
- * In this case the thread argument can be NULL, so that,
- * we should not expect the thread argument to be non-NULL.
- */
- if (klass == NULL) {
+ClassUnload(jvmtiEnv* jvmti_env, JNIEnv* jni_env, const char* name, ...) {
+ // The name argument should never be null
+ if (name == NULL) {
nsk_jvmti_setFailStatus();
- NSK_COMPLAIN0("ClassUnload: 'klass' input parameter is NULL.\n");
-
+ NSK_COMPLAIN0("ClassUnload: 'name' input parameter is NULL.\n");
+ } else {
+ NSK_DISPLAY1("Class unloaded %s\n", name);
}
+
NSK_DISPLAY0("Received ClassUnload event.\n");
if (eventEnabled == JNI_TRUE) {
eventReceived1 = JNI_TRUE;
} else {
eventReceived2 = JNI_TRUE;
@@ -105,10 +102,24 @@
}
return enabled;
}
+jboolean checkParams(jvmtiExtensionEventInfo event) {
+ // Check parameters are:
+ // JNIEnv *jni_env, const char* name
+ if (event.param_count != 2 ||
+ event.params[0].kind != JVMTI_KIND_IN_PTR ||
+ event.params[0].base_type != JVMTI_TYPE_JNIENV ||
+ event.params[1].kind != JVMTI_KIND_IN_PTR ||
+ event.params[1].base_type != JVMTI_TYPE_CCHAR) {
+ return JNI_FALSE;
+ } else {
+ return JNI_TRUE;
+ }
+}
+
jboolean enableClassUnloadEvent (jboolean enable) {
jint extCount, i;
jvmtiExtensionEventInfo* extList;
jboolean found = JNI_FALSE;
@@ -120,10 +131,18 @@
for (i = 0; i < extCount; i++) {
if (strcmp(extList[i].id, (char*)"com.sun.hotspot.events.ClassUnload") == 0) {
found = JNI_TRUE;
+ NSK_DISPLAY1("%s", extList[i].short_description);
+
+ if (!checkParams(extList[i])) {
+ NSK_COMPLAIN0("ClassUnload event has wrong parameters.");
+ nsk_jvmti_setFailStatus();
+ return JNI_FALSE;
+ }
+
if (!NSK_JVMTI_VERIFY(
jvmti->SetExtensionEventCallback(extList[i].extension_event_index,
enable ? (jvmtiExtensionEvent)ClassUnload : NULL))) {
nsk_jvmti_setFailStatus();
return JNI_FALSE;
< prev index next >