Skip to content

Commit

Permalink
8294486: Remove vmTestbase/nsk/jvmti/ tests ported to serviceability/…
Browse files Browse the repository at this point in the history
…jvmti.

Reviewed-by: sspitsyn
  • Loading branch information
lmesnik authored and pull[bot] committed Aug 29, 2023
1 parent 700b0df commit 8298169
Show file tree
Hide file tree
Showing 227 changed files with 67 additions and 23,310 deletions.
51 changes: 0 additions & 51 deletions test/hotspot/jtreg/TEST.quick-groups
Expand Up @@ -866,7 +866,6 @@ vmTestbase_nsk_jvmti_quick = \
vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload002/TestDescription.java \
vmTestbase/nsk/jvmti/Agent_OnLoad/agentonload003/TestDriver.java \
vmTestbase/nsk/jvmti/Agent_OnUnload/agentonunload001/TestDriver.java \
vmTestbase/nsk/jvmti/Breakpoint/breakpoint001/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk001/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk002/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk003/TestDescription.java \
Expand All @@ -876,8 +875,6 @@ vmTestbase_nsk_jvmti_quick = \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk007/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk008/TestDescription.java \
vmTestbase/nsk/jvmti/ClassFileLoadHook/classfloadhk009/TestDescription.java \
vmTestbase/nsk/jvmti/ClassLoad/classload001/TestDescription.java \
vmTestbase/nsk/jvmti/ClassPrepare/classprep001/TestDescription.java \
vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk001/TestDescription.java \
vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk002/TestDescription.java \
vmTestbase/nsk/jvmti/ClearBreakpoint/clrbrk005/TestDescription.java \
Expand All @@ -895,18 +892,8 @@ vmTestbase_nsk_jvmti_quick = \
vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon003/TestDescription.java \
vmTestbase/nsk/jvmti/DestroyRawMonitor/drrawmon004/TestDescription.java \
vmTestbase/nsk/jvmti/DynamicCodeGenerated/dyncodgen001/TestDescription.java \
vmTestbase/nsk/jvmti/Exception/exception001/TestDescription.java \
vmTestbase/nsk/jvmti/ExceptionCatch/excatch001/TestDescription.java \
vmTestbase/nsk/jvmti/FieldAccess/fieldacc001/TestDescription.java \
vmTestbase/nsk/jvmti/FieldAccess/fieldacc002/TestDescription.java \
vmTestbase/nsk/jvmti/FieldAccess/fieldacc003/TestDescription.java \
vmTestbase/nsk/jvmti/FieldAccess/fieldacc004/TestDescription.java \
vmTestbase/nsk/jvmti/FieldModification/fieldmod001/TestDescription.java \
vmTestbase/nsk/jvmti/FieldModification/fieldmod002/TestDescription.java \
vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc001/TestDescription.java \
vmTestbase/nsk/jvmti/ForceGarbageCollection/forcegc002/TestDescription.java \
vmTestbase/nsk/jvmti/FramePop/framepop001/TestDescription.java \
vmTestbase/nsk/jvmti/FramePop/framepop002/TestDescription.java \
vmTestbase/nsk/jvmti/GenerateEvents/genevents001/TestDescription.java \
vmTestbase/nsk/jvmti/GetAllThreads/allthr001/TestDescription.java \
vmTestbase/nsk/jvmti/GetAllThreads/allthr002/TestDescription.java \
Expand Down Expand Up @@ -939,9 +926,6 @@ vmTestbase_nsk_jvmti_quick = \
vmTestbase/nsk/jvmti/GetClassStatus/getclstat005/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassStatus/getclstat006/TestDescription.java \
vmTestbase/nsk/jvmti/GetClassStatus/getclstat007/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon001/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon002/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentContendedMonitor/contmon003/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentThreadCpuTime/curthrcputime001/TestDescription.java \
vmTestbase/nsk/jvmti/GetCurrentThreadCpuTimerInfo/curthrtimerinfo001/TestDescription.java \
vmTestbase/nsk/jvmti/GetEnvironmentLocalStorage/getenvstor001/TestDescription.java \
Expand All @@ -957,11 +941,6 @@ vmTestbase_nsk_jvmti_quick = \
vmTestbase/nsk/jvmti/GetFieldName/getfldnm003/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldName/getfldnm004/TestDescription.java \
vmTestbase/nsk/jvmti/GetFieldName/getfldnm005/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameCount/framecnt001/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameCount/framecnt002/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameCount/framecnt003/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameLocation/frameloc002/TestDescription.java \
vmTestbase/nsk/jvmti/GetFrameLocation/frameloc003/TestDescription.java \
vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf005/TestDescription.java \
vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf006/TestDescription.java \
vmTestbase/nsk/jvmti/GetImplementedInterfaces/getintrf007/TestDescription.java \
Expand Down Expand Up @@ -1017,24 +996,13 @@ vmTestbase_nsk_jvmti_quick = \
vmTestbase/nsk/jvmti/GetSystemProperties/getsysprops002/TestDescription.java \
vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop001/TestDescription.java \
vmTestbase/nsk/jvmti/GetSystemProperty/getsysprop002/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr001/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr002/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr003/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr004/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr005/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr006/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr007/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr008/TestDescription.java \
vmTestbase/nsk/jvmti/GetStackTrace/getstacktr009/TestDescription.java \
vmTestbase/nsk/jvmti/GetTag/gettag001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadCpuTime/thrcputime002/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadCpuTimerInfo/thrtimerinfo001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadGroupInfo/thrgrpinfo002/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo001/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadInfo/thrinfo002/TestDescription.java \
vmTestbase/nsk/jvmti/GetThreadLocalStorage/getthrdstor001/TestDescription.java \
vmTestbase/nsk/jvmti/GetTime/gettime001/TestDescription.java \
vmTestbase/nsk/jvmti/GetTimerInfo/timerinfo001/TestDescription.java \
Expand Down Expand Up @@ -1087,17 +1055,6 @@ vmTestbase_nsk_jvmti_quick = \
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-class-tagged/TestDescription.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/filter-class-untagged/TestDescription.java \
vmTestbase/nsk/jvmti/IterateThroughHeap/abort/Abort.java \
vmTestbase/nsk/jvmti/MethodEntry/mentry001/TestDescription.java \
vmTestbase/nsk/jvmti/MethodEntry/mentry002/TestDescription.java \
vmTestbase/nsk/jvmti/MethodExit/mexit002/TestDescription.java \
vmTestbase/nsk/jvmti/MonitorContendedEnter/mcontenter001/TestDescription.java \
vmTestbase/nsk/jvmti/MonitorContendedEntered/mcontentered001/TestDescription.java \
vmTestbase/nsk/jvmti/MonitorWait/monitorwait001/TestDescription.java \
vmTestbase/nsk/jvmti/MonitorWaited/monitorwaited001/TestDescription.java \
vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/TestDescription.java \
vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/TestDescription.java \
vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/TestDescription.java \
vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/TestDescription.java \
vmTestbase/nsk/jvmti/NotifyFramePop/nframepop001/TestDescription.java \
vmTestbase/nsk/jvmti/NotifyFramePop/nframepop002/TestDescription.java \
vmTestbase/nsk/jvmti/NotifyFramePop/nframepop003/TestDescription.java \
Expand Down Expand Up @@ -1212,20 +1169,12 @@ vmTestbase_nsk_jvmti_quick = \
vmTestbase/nsk/jvmti/SetThreadLocalStorage/setthrdstor003/TestDescription.java \
vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag001/TestDescription.java \
vmTestbase/nsk/jvmti/SetVerboseFlag/setvrbflag002/TestDescription.java \
vmTestbase/nsk/jvmti/SingleStep/singlestep001/TestDescription.java \
vmTestbase/nsk/jvmti/SingleStep/singlestep003/TestDescription.java \
vmTestbase/nsk/jvmti/SuspendThread/suspendthrd001/TestDescription.java \
vmTestbase/nsk/jvmti/SuspendThreadList/suspendthrdlst001/TestDescription.java \
vmTestbase/nsk/jvmti/StopThread/stopthrd006/TestDescription.java \
vmTestbase/nsk/jvmti/StopThread/stopthrd007/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadEnd/threadend001/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadEnd/threadend002/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadStart/threadstart002/TestDescription.java \
vmTestbase/nsk/jvmti/ThreadStart/threadstart003/TestDescription.java \
vmTestbase/nsk/jvmti/VMDeath/vmdeath001/TestDescription.java \
vmTestbase/nsk/jvmti/VMInit/vminit001/TestDescription.java \
vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP01/ap01t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP02/ap02t001/TestDescription.java \
vmTestbase/nsk/jvmti/scenarios/allocation/AP03/ap03t001/TestDescription.java \
Expand Down
Expand Up @@ -49,8 +49,8 @@ public class classprep01 {
System.loadLibrary("classprep01");
}

native static void getReady();
native static int check();
native static void getReady(Thread thread);
native static int check(Thread thread);

static volatile int result;
public static void main(String args[]) {
Expand All @@ -59,9 +59,9 @@ public static void main(String args[]) {
}
public static void testVirtualThread() {
Thread thread = Thread.startVirtualThread(() -> {
getReady();
getReady(Thread.currentThread());
new TestClassVirtual().run();
result = check();
result = check(Thread.currentThread());
});
try {
thread.join();
Expand All @@ -74,9 +74,22 @@ public static void testVirtualThread() {
}
}
public static void testPlatformThread() {
getReady();
Thread otherThread = new Thread(() -> {
new TestClass2().run();
});

getReady(Thread.currentThread());

// should generate the events
new TestClass().run();
result = check();

// loading classes on other thread should not generate the events
otherThread.start();
try {
otherThread.join();
} catch (InterruptedException e) {
}
result = check(Thread.currentThread());
if (result != 0) {
throw new RuntimeException("check failed with result " + result);
}
Expand All @@ -88,7 +101,7 @@ interface TestInterface {
void run();
}

static class TestClass implements TestInterface {
static class TestClass implements TestInterface {
static int i = 0;
int count = 0;
static {
Expand Down Expand Up @@ -116,5 +129,12 @@ public void run() {
}
}

interface TestInterface2 {
void run();
}

static class TestClass2 implements TestInterface2 {
public void run() {
}
}
}
Expand Up @@ -63,6 +63,13 @@ static class_info virtual_classes[] = {
{ (char *)"Lclassprep01$TestClassVirtual;", EXP_STATUS, 3, 2, 1 }
};

// These classes are loaded on a different thread.
// We should not get ClassPrepare events for them.
static const class_info unexpectedClasses[] = {
{ (char *)"Lclassprep01$TestInterface2;", 0, 0, 0, 0 },
{ (char *)"Lclassprep01$TestClass2;", 0, 0, 0, 0}
};

void printStatus(jint status) {
int flags = 0;
if ((status & JVMTI_CLASS_STATUS_VERIFIED) != 0) {
Expand All @@ -87,6 +94,17 @@ void printStatus(jint status) {
LOG(" (0x%x)\n", status);
}

const size_t NOT_FOUND = (size_t)(-1);

size_t findClass(const char *classSig, const class_info *arr, int size) {
for (int i = 0; i < size; i++) {
if (strcmp(classSig, arr[i].sig) == 0) {
return i;
}
}
return NOT_FOUND;
}

void JNICALL ClassPrepare(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jclass cls) {
jvmtiError err;
class_info inf;
Expand Down Expand Up @@ -183,9 +201,21 @@ void JNICALL ClassPrepare(jvmtiEnv *jvmti, JNIEnv *jni, jthread thr, jclass cls)
}
LOG("\n");

if (eventsCount >= eventsExpected) {
LOG("(#%" PRIuPTR ") too many events: %" PRIuPTR ", expected: %" PRIuPTR "\n",
eventsCount, eventsCount + 1, eventsExpected);
size_t expectedClassIdx = findClass(inf.sig, classes, 2);
// Test classes loading may cause system classes loading - skip them.
if (expectedClassIdx == NOT_FOUND) {
size_t unexpectedClassIdx = findClass(inf.sig, unexpectedClasses,
sizeof(unexpectedClasses)/sizeof(class_info));
if (unexpectedClassIdx != NOT_FOUND) {
printf("# wrong class: \"%s\"\n", inf.sig);
result = STATUS_FAILED;
}
return;
}

if (eventsCount != expectedClassIdx) {
printf("(#%" PRIuPTR ") unexpected order: %" PRIuPTR ", expected: %" PRIuPTR "\n",
eventsCount, expectedClassIdx, eventsCount);
result = STATUS_FAILED;
return;
}
Expand Down Expand Up @@ -266,60 +296,46 @@ jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
}

JNIEXPORT void JNICALL
Java_classprep01_getReady(JNIEnv *jni, jclass cls) {
Java_classprep01_getReady(JNIEnv *jni, jclass cls, jthread thread) {
jvmtiError err;
jthread prep_thread;

if (jvmti == NULL) {
LOG("JVMTI client was not properly loaded!\n");
return;
}

err = jvmti->GetCurrentThread(&prep_thread);
if (err != JVMTI_ERROR_NONE) {
LOG("Failed to get current thread: %s (%d)\n", TranslateError(err), err);
result = STATUS_FAILED;
return;
}

eventsCount = 0;
if (jni->IsVirtualThread(prep_thread)) {
if (jni->IsVirtualThread(thread)) {
classes = virtual_classes;
eventsExpected = sizeof(virtual_classes)/sizeof(class_info);
} else {
classes = kernel_classes;
eventsExpected = sizeof(kernel_classes)/sizeof(class_info);
}
LOG("Requesting enabling JVMTI_EVENT_CLASS_PREPARE in thread.\n");
print_thread_info(jvmti, jni, prep_thread);
print_thread_info(jvmti, jni, thread);

err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, prep_thread);
err = jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_PREPARE, thread);
if (err != JVMTI_ERROR_NONE) {
LOG("Failed to enable JVMTI_EVENT_CLASS_PREPARE: %s (%d)\n", TranslateError(err), err);
result = STATUS_FAILED;
}
}

JNIEXPORT jint JNICALL
Java_classprep01_check(JNIEnv *jni, jclass cls) {
Java_classprep01_check(JNIEnv *jni, jclass cls, jthread thread) {
jvmtiError err;
jthread prep_thread;

if (jvmti == NULL) {
LOG("JVMTI client was not properly loaded!\n");
return STATUS_FAILED;
}

err = jvmti->GetCurrentThread(&prep_thread);
if (err != JVMTI_ERROR_NONE) {
LOG("Failed to get current thread: %s (%d)\n", TranslateError(err), err);
return STATUS_FAILED;
}

LOG("Requesting disabling JVMTI_EVENT_CLASS_PREPARE in thread.\n");
print_thread_info(jvmti, jni, prep_thread);
print_thread_info(jvmti, jni, thread);

err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_PREPARE, prep_thread);
err = jvmti->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_CLASS_PREPARE, thread);
if (err != JVMTI_ERROR_NONE) {
LOG("Failed to disable JVMTI_EVENT_CLASS_PREPARE: %s (%d)\n", TranslateError(err), err);
result = STATUS_FAILED;
Expand Down

0 comments on commit 8298169

Please sign in to comment.