< prev index next >

test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/libHeapMonitor.c

Print this page
rev 49264 : [mq]: event-only
rev 49266 : [mq]: event4
rev 49267 : [mq]: event5
rev 49268 : [mq]: event6
rev 49269 : [mq]: event7

*** 564,573 **** --- 564,574 ---- JNIEXPORT void JNICALL Java_MyPackage_HeapMonitor_setSamplingRate(JNIEnv* env, jclass cls, jint value) { (*jvmti)->SetHeapSamplingRate(jvmti, value); } + // TODO: should be removed, no tests using it. JNIEXPORT void JNICALL Java_MyPackage_HeapMonitor_setGarbageHistory(JNIEnv* env, jclass cls, jint value) { event_storage_set_garbage_history(&global_event_storage, value); }
*** 640,649 **** --- 641,676 ---- return FALSE; } return TRUE; } + JNIEXPORT jboolean JNICALL + Java_MyPackage_HeapMonitorIllegalArgumentTest_testIllegalArgument(JNIEnv *env, + jclass cls) { + if (check_error((*jvmti)->SetHeapSamplingRate(jvmti, 0), + "Sampling rate 0 failed\n")){ + return FALSE; + } + + if (check_error((*jvmti)->SetHeapSamplingRate(jvmti, 1024), + "Sampling rate 1024 failed\n")){ + return FALSE; + } + + if (!check_error((*jvmti)->SetHeapSamplingRate(jvmti, -1), + "Sampling rate -1 passed\n")){ + return FALSE; + } + + if (!check_error((*jvmti)->SetHeapSamplingRate(jvmti, -1024), + "Sampling rate -1024 passed\n")){ + return FALSE; + } + + return TRUE; + } + JNIEXPORT jdouble JNICALL Java_MyPackage_HeapMonitorStatRateTest_getAverageRate(JNIEnv *env, jclass cls) { return event_storage_get_average_rate(&global_event_storage); }
*** 711,726 **** thread_data.threads = malloc(sizeof(jthread) * num_threads); memset(thread_data.threads, 0, sizeof(jthread) * num_threads); find_threads_in_array(&thread_data, global_event_storage.live_objects, global_event_storage.live_object_count); - find_threads_in_array(&thread_data, - global_event_storage.garbage_collected_objects, - global_event_storage.garbage_history_size); free(thread_data.threads); pthread_mutex_unlock(&global_event_storage.storage_mutex); return thread_data.num_threads == num_threads; } #ifdef __cplusplus } --- 738,753 ---- thread_data.threads = malloc(sizeof(jthread) * num_threads); memset(thread_data.threads, 0, sizeof(jthread) * num_threads); find_threads_in_array(&thread_data, global_event_storage.live_objects, global_event_storage.live_object_count); free(thread_data.threads); pthread_mutex_unlock(&global_event_storage.storage_mutex); + fprintf(stderr, "Obtained %d - %d\n", + thread_data.num_threads, + num_threads); return thread_data.num_threads == num_threads; } #ifdef __cplusplus }
< prev index next >