when the JNI RegisterNatives() is called.
- * The test works as follows. The java part invokes the native method
- * nativeMethod() twice. At the first time that method
- * registers another native method anotherNativeMethod() for
- * the dummy class TestedClass. Registration is made through
- * the JNI RegisterNatives() call. Being invoked at the second time, the
- * nativeMethod() just returns.
- * In accordance with the spec, it is expected that the NativeMethodBind
- * will be generated only one time for the nativeMethod(), and only one
- * time for the anotherNativeMethod().
- */
-public class nativemethbind001 {
- static {
- try {
- System.loadLibrary("nativemethbind001");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load \"nativemethbind001\" library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native void nativeMethod(boolean registerNative);
-
- native int check();
-
- public static void main(String[] argv) {
- argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
-
- // produce JCK-like exit status
- System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
- }
-
- public static int run(String argv[], PrintStream out) {
- return new nativemethbind001().runThis(argv, out);
- }
-
- private int runThis(String argv[], PrintStream out) {
- ArgumentHandler argHandler = new ArgumentHandler(argv);
- Log log = new Log(out, argHandler);
-
- log.display("\nCalling native methods ...\n");
-
- // dummy method used to provoke the NativeMethodBind event
- nativeMethod(true);
-
- // call one more time to provoke the wrong NativeMethodBind
- // event
- nativeMethod(false);
-
- return check();
- }
-
- /**
- * Dummy class used only to register native method
- * anotherNativeMethod with it
- */
- class TestedClass {
- native void anotherNativeMethod();
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/TestDescription.java
deleted file mode 100644
index 7c353c92cba..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/TestDescription.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/NativeMethodBind/nativemethbind001.
- * VM Testbase keywords: [quick, jpda, jvmti, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * This test exercises the JVMTI event NativeMethodBind.
- * It verifies that the event will be properly sent:
- * - for the native method called for the first time
- * - when the JNI RegisterNatives() is called.
- * The test works as follows. The java part invokes the native method
- * 'nativeMethod()' twice. At the first time that method registers
- * another native method 'anotherNativeMethod()' for the dummy class
- * 'TestedClass'. Registration is made through the JNI RegisterNatives()
- * call. Being invoked at the second time, the nativeMethod() just returns.
- * In accordance with the spec, it is expected that the NativeMethodBind
- * will be generated only one time for the nativeMethod(), and only one
- * time for the anotherNativeMethod().
- * COMMENTS
- * The test has been fixed due to the bug 4967116.
- * Fixed the 4995867 bug.
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native
- * -agentlib:nativemethbind001=-waittime=5
- * nsk.jvmti.NativeMethodBind.nativemethbind001
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/libnativemethbind001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/libnativemethbind001.cpp
deleted file mode 100644
index 47f913eeeb4..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/libnativemethbind001.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "nativemethbind001.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/nativemethbind001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/nativemethbind001.cpp
deleted file mode 100644
index f18d84e1796..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind001/nativemethbind001.cpp
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include
-#include "agent_common.h"
-
-#include "nsk_tools.h"
-#include "JVMTITools.h"
-#include "jvmti_tools.h"
-#include "jni_tools.h"
-
-extern "C" {
-
-#define STATUS_FAILED 2
-#define PASSED 0
-
-/* tested methods */
-#define METH_NUM 2
-static const char *METHODS[][2] = {
- { "nativeMethod", "(Z)V" },
- { "anotherNativeMethod", "()V" },
-};
-
-/* event counters for the tested methods and expected numbers
- of the events */
-static volatile int bindEv[][2] = {
- { 0, 1 },
- { 0, 1 }
-};
-
-static const char *CLASS_SIG =
- "Lnsk/jvmti/NativeMethodBind/nativemethbind001$TestedClass;";
-
-static volatile jint result = PASSED;
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-static jrawMonitorID countLock;
-
-static void lock(jvmtiEnv *jvmti_env, JNIEnv *jni_env) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(countLock)))
- jni_env->FatalError("failed to enter a raw monitor\n");
-}
-
-static void unlock(jvmtiEnv *jvmti_env, JNIEnv *jni_env) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(countLock)))
- jni_env->FatalError("failed to exit a raw monitor\n");
-}
-
-/** callback functions **/
-void JNICALL
-NativeMethodBind(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
- jmethodID method, void *addr, void **new_addr) {
- jvmtiPhase phase;
- char *methNam, *methSig;
- int i;
-
- lock(jvmti_env, jni_env);
-
- NSK_DISPLAY0(">>>> NativeMethodBind event received\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) {
- result = STATUS_FAILED;
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if (phase != JVMTI_PHASE_START && phase != JVMTI_PHASE_LIVE) {
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to get method name during NativeMethodBind callback\n\n");
- unlock(jvmti_env, jni_env);
- return;
- }
-
- NSK_DISPLAY2("method: \"%s %s\"\n", methNam, methSig);
-
- for (i=0; iDeallocate((unsigned char*) methNam))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n");
- }
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methSig))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n");
- }
-
- NSK_DISPLAY0("<<<<\n\n");
-
- unlock(jvmti_env, jni_env);
-}
-/************************/
-
-/* dummy method used only to provoke NativeMethodBind event */
-static void JNICALL
-anotherNativeMethod(JNIEnv *env, jobject obj) {
- NSK_DISPLAY0("inside the anotherNativeMethod()\n");
-}
-
-/* dummy method used only to provoke NativeMethodBind event */
-JNIEXPORT void JNICALL
-Java_nsk_jvmti_NativeMethodBind_nativemethbind001_nativeMethod(
- JNIEnv *env, jobject obj, jboolean registerNative) {
- jclass testedCls = NULL;
- JNINativeMethod meth;
-
- NSK_DISPLAY0("Inside the nativeMethod()\n");
-
- if (registerNative == JNI_TRUE) {
- NSK_DISPLAY1("Finding class \"%s\" ...\n", CLASS_SIG);
- if (!NSK_JNI_VERIFY(env, (testedCls = env->FindClass(CLASS_SIG)) != NULL)) {
- result = STATUS_FAILED;
- NSK_COMPLAIN1("TEST FAILURE: unable to find class \"%s\"\n\n",
- CLASS_SIG);
- return;
- }
-
- meth.name = (char *) METHODS[1][0];
- meth.signature = (char *) METHODS[1][1];
- meth.fnPtr = (void *) &anotherNativeMethod;
-
- NSK_DISPLAY3("Calling RegisterNatives() with \"%s %s\"\n"
- "\tfor class \"%s\" ...\n",
- METHODS[1][0], METHODS[1][1], CLASS_SIG);
- if (!NSK_JNI_VERIFY_VOID(env, (env->RegisterNatives(testedCls, &meth, 1)) != 0)) {
- result = STATUS_FAILED;
- NSK_COMPLAIN3("TEST FAILURE: unable to RegisterNatives() \"%s %s\" for class \"%s\"\n\n",
- METHODS[1][0], METHODS[1][1], CLASS_SIG);
- }
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_NativeMethodBind_nativemethbind001_check(
- JNIEnv *env, jobject obj) {
- int i;
-
- for (i=0; iCreateRawMonitor("_counter_lock", &countLock)))
- return JNI_ERR;
-
- /* add capability to generate compiled method events */
- memset(&caps, 0, sizeof(jvmtiCapabilities));
- caps.can_generate_native_method_bind_events = 1;
- if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
- return JNI_ERR;
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
- return JNI_ERR;
- if (!caps.can_generate_native_method_bind_events)
- NSK_DISPLAY0("Warning: generation of native method bind events is not implemented\n");
-
- /* set event callback */
- NSK_DISPLAY0("setting event callbacks ...\n");
- (void) memset(&callbacks, 0, sizeof(callbacks));
- callbacks.NativeMethodBind = &NativeMethodBind;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
- return JNI_ERR;
-
- NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_NATIVE_METHOD_BIND,
- NULL)))
- return JNI_ERR;
- NSK_DISPLAY0("enabling the events done\n\n");
-
- return JNI_OK;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002.java
deleted file mode 100644
index 09d9e230483..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.NativeMethodBind;
-
-import java.io.*;
-
-import nsk.share.*;
-import nsk.share.jvmti.*;
-
-/**
- * This test exercises the JVMTI event NativeMethodBind.
- *
It verifies that the events will be sent only during the start
- * and live phase of VM execution.
- * The test works as follows. The NativeMethodBind event is enabled on
- * OnLoad phase. Then the VM phase is checked from the
- * NativeMethodBind callback to be start or live one. The java part calls
- * the dummy native method nativeMethod on exit in order to
- * provoke the NativeMethodBind event near the dead phase.
- */
-public class nativemethbind002 {
- static {
- try {
- System.loadLibrary("nativemethbind002");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load \"nativemethbind002\" library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native int nativeMethod();
-
- public static void main(String[] argv) {
- argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
-
- // produce JCK-like exit status
- System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
- }
-
- public static int run(String argv[], PrintStream out) {
- return new nativemethbind002().runThis(argv, out);
- }
-
- private int runThis(String argv[], PrintStream out) {
- ArgumentHandler argHandler = new ArgumentHandler(argv);
- Log log = new Log(out, argHandler);
-
- log.display("\nCalling a native method ...\n");
-
- // dummy methods used to provoke the NativeMethodBind event
- // near the dead phase
- return nativeMethod();
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/TestDescription.java
deleted file mode 100644
index 56b02501d4a..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/TestDescription.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/NativeMethodBind/nativemethbind002.
- * VM Testbase keywords: [quick, jpda, jvmti, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * This test exercises the JVMTI event NativeMethodBind.
- * It verifies that the events will be sent only during the start
- * and live phase of VM execution.
- * The test works as follows. The NativeMethodBind event is enabled
- * on 'OnLoad' phase. Then the VM phase is checked from the
- * NativeMethodBind callback to be start or live one. The java part
- * calls the dummy native method 'nativeMethod' on exit in order to
- * provoke the NativeMethodBind event near the dead phase.
- * COMMENTS
- * Fixed the 4995867 bug.
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native
- * -agentlib:nativemethbind002=-waittime=5
- * nsk.jvmti.NativeMethodBind.nativemethbind002
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/libnativemethbind002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/libnativemethbind002.cpp
deleted file mode 100644
index 8ae997f233e..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/libnativemethbind002.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "nativemethbind002.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/nativemethbind002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/nativemethbind002.cpp
deleted file mode 100644
index 2629f8c416e..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind002/nativemethbind002.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include "jni_tools.h"
-#include "agent_common.h"
-#include "jvmti_tools.h"
-
-extern "C" {
-
-#define STATUS_FAILED 2
-#define PASSED 0
-
-/* counter for the wrong NativeMethodBind events
- received during non-start or non-live phase */
-static volatile int wrongBindEv = 0;
-
-static volatile jint result = PASSED;
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-static jrawMonitorID countLock;
-
-static void lock(jvmtiEnv *jvmti_env, JNIEnv *jni_env) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(countLock)))
- jni_env->FatalError("failed to enter a raw monitor\n");
-}
-
-static void unlock(jvmtiEnv *jvmti_env, JNIEnv *jni_env) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(countLock)))
- jni_env->FatalError("failed to exit a raw monitor\n");
-}
-
-/** callback functions **/
-void JNICALL
-NativeMethodBind(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
- jmethodID method, void *addr, void **new_addr) {
- jvmtiPhase phase;
- char *methNam = NULL, *methSig = NULL;
-
- lock(jvmti_env, jni_env);
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0(
- "TEST FAILED: unable to obtain phase of the VM execution\n"
- "\tduring NativeMethodBind callback\n\n");
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if (phase != JVMTI_PHASE_LIVE && phase != JVMTI_PHASE_START) {
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to get method name during NativeMethodBind callback\n\n");
- }
- else
- NSK_DISPLAY2("NativeMethodBind received for \"%s %s\"\n",
- methNam, methSig);
-
- if (methNam != NULL)
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methNam)))
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n");
- if (methSig != NULL)
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methSig)))
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n");
-
- unlock(jvmti_env, jni_env);
-}
-
-void JNICALL
-VMDeath(jvmtiEnv *jvmti_env, JNIEnv *env) {
- NSK_DISPLAY0("VMDeath event received\n");
-
- if (wrongBindEv != 0) {
- NSK_COMPLAIN1(
- "TEST FAILED: there are %d NativeMethodBind events\n"
- "sent during non-start or non-live phase of the VM execution\n",
- wrongBindEv);
- }
-
- if (result == STATUS_FAILED)
- exit(95 + STATUS_FAILED);
-}
-/************************/
-
-/* dummy method used only to provoke NativeMethodBind events */
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_NativeMethodBind_nativemethbind002_nativeMethod(
- JNIEnv *env, jobject obj) {
- NSK_DISPLAY0("inside the nativeMethod()\n\n");
-
- return PASSED;
-}
-
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_nativemethbind002(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_nativemethbind002(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_nativemethbind002(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
- jvmtiCapabilities caps;
-
- /* init framework and parse options */
- if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
- return JNI_ERR;
-
- /* create JVMTI environment */
- if (!NSK_VERIFY((jvmti =
- nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
- return JNI_ERR;
-
- /* create a raw monitor */
- if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_counter_lock", &countLock)))
- return JNI_ERR;
-
- /* add capability to generate compiled method events */
- memset(&caps, 0, sizeof(jvmtiCapabilities));
- caps.can_generate_native_method_bind_events = 1;
- if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
- return JNI_ERR;
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
- return JNI_ERR;
- if (!caps.can_generate_native_method_bind_events)
- NSK_DISPLAY0("Warning: generation of native method bind events is not implemented\n");
-
- /* set event callback */
- NSK_DISPLAY0("setting event callbacks ...\n");
- (void) memset(&callbacks, 0, sizeof(callbacks));
- callbacks.NativeMethodBind = &NativeMethodBind;
- callbacks.VMDeath = &VMDeath;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
- return JNI_ERR;
-
- NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_NATIVE_METHOD_BIND,
- NULL)))
- return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_VM_DEATH,
- NULL)))
- return JNI_ERR;
- NSK_DISPLAY0("enabling the events done\n\n");
-
- return JNI_OK;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003.java
deleted file mode 100644
index c22d21ecaa0..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.NativeMethodBind;
-
-import java.io.*;
-
-import nsk.share.*;
-import nsk.share.jvmti.*;
-
-/**
- * This test exercises the JVMTI event NativeMethodBind.
- *
It verifies that the event will not be sent when the native
- * method is unbound.
- * The test works as follows. The java part invokes the native method
- * registerNative() which registers native method
- * nativeMethod() for the dummy class TestedClass
- * and then unregisters it. Registration/unregistration is made through
- * the JNI RegisterNatives()/UnregisterNatives() calls.
- * In accordance with the spec, it is expected that the NativeMethodBind
- * will be generated only one time for the nativeMethod().
- */
-public class nativemethbind003 {
- static {
- try {
- System.loadLibrary("nativemethbind003");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load \"nativemethbind003\" library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native void registerNative();
-
- public static void main(String[] argv) {
- argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
-
- // produce JCK-like exit status
- System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
- }
-
- public static int run(String argv[], PrintStream out) {
- return new nativemethbind003().runThis(argv, out);
- }
-
- private int runThis(String argv[], PrintStream out) {
- // register native method 'nativeMethod' with 'TestedClass'
- registerNative();
-
- return Consts.TEST_PASSED;
- }
-
- /**
- * Dummy class used only to register/unregister native method
- * nativeMethod with it
- */
- class TestedClass {
- native void nativeMethod();
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/TestDescription.java
deleted file mode 100644
index 9005021343a..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/TestDescription.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/NativeMethodBind/nativemethbind003.
- * VM Testbase keywords: [quick, jpda, jvmti, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * This test exercises the JVMTI event NativeMethodBind.
- * It verifies that the event will not be sent when the native
- * method is unbound.
- * The test works as follows. The java part invokes the native method
- * 'registerNative()' which registers native method 'nativeMethod()'
- * for the dummy class 'TestedClass' and then unregisters it.
- * Registration/unregistration is made through the JNI
- * RegisterNatives()/UnregisterNatives() calls.
- * In accordance with the spec, it is expected that the NativeMethodBind
- * will be generated only one time for the nativeMethod().
- * COMMENTS
- * The test has been fixed due to the bug 4967116.
- * Fixed the 4995867 bug.
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native
- * -agentlib:nativemethbind003=-waittime=5
- * nsk.jvmti.NativeMethodBind.nativemethbind003
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/libnativemethbind003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/libnativemethbind003.cpp
deleted file mode 100644
index dfdb6fa6bac..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/libnativemethbind003.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "nativemethbind003.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/nativemethbind003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/nativemethbind003.cpp
deleted file mode 100644
index 2bd4a40a757..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind003/nativemethbind003.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include "jni_tools.h"
-#include "agent_common.h"
-#include "jvmti_tools.h"
-
-extern "C" {
-
-#define STATUS_FAILED 2
-#define PASSED 0
-
-/* tested method */
-static const char *METHODS[] = {
- "nativeMethod", "()V"
-};
-
-/* event counter for the tested method and expected number
- of the events */
-static volatile int bindEv[] = {
- 0, 1
-};
-
-static const char *CLASS_SIG =
- "Lnsk/jvmti/NativeMethodBind/nativemethbind003$TestedClass;";
-
-static volatile jint result = PASSED;
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-static jrawMonitorID countLock;
-
-static void lock(jvmtiEnv *jvmti_env, JNIEnv *jni_env) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(countLock)))
- jni_env->FatalError("failed to enter a raw monitor\n");
-}
-
-static void unlock(jvmtiEnv *jvmti_env, JNIEnv *jni_env) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(countLock)))
- jni_env->FatalError("failed to exit a raw monitor\n");
-}
-
-/** callback functions **/
-void JNICALL
-NativeMethodBind(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
- jmethodID method, void *addr, void **new_addr) {
- jvmtiPhase phase;
- char *methNam, *methSig;
-
- lock(jvmti_env, jni_env);
-
- NSK_DISPLAY0(">>>> NativeMethodBind event received\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) {
- result = STATUS_FAILED;
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if (phase != JVMTI_PHASE_LIVE && phase != JVMTI_PHASE_START) {
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to get method name during NativeMethodBind callback\n\n");
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if ((strcmp(methNam,METHODS[0]) == 0) &&
- (strcmp(methSig,METHODS[1]) == 0)) {
- bindEv[0]++;
-
- NSK_DISPLAY2("\tmethod: \"%s %s\"\n", methNam, methSig);
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methNam))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory storing method name\n\n");
- }
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methSig))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory storing method signature\n\n");
- }
-
- NSK_DISPLAY0("<<<<\n\n");
-
- unlock(jvmti_env, jni_env);
-}
-
-void JNICALL
-VMDeath(jvmtiEnv *jvmti_env, JNIEnv *env) {
- NSK_DISPLAY0("VMDeath event received\n");
-
- if (bindEv[0] != bindEv[1]) {
- result = STATUS_FAILED;
- NSK_COMPLAIN5(
- "TEST FAILED: wrong NativeMethodBind events\n"
- "\tfor tested method \"%s %s\" bound with \"%s\":\n"
- "\tgot: %d\texpected: %d\n\n",
- METHODS[0], METHODS[1], CLASS_SIG, bindEv[0], bindEv[1]);
- } else {
- NSK_DISPLAY4(
- "CHECK PASSED: %d NativeMethodBind event(s)\n"
- "\tfor tested method \"%s %s\" bound with \"%s\"\n"
- "\tas expected\n",
- bindEv[0], METHODS[0], METHODS[1], CLASS_SIG);
- }
-
- if (result == STATUS_FAILED)
- exit(95 + STATUS_FAILED);
-}
-/************************/
-
-/* dummy method used only to provoke NativeMethodBind event */
-static void JNICALL
-nativeMethod(JNIEnv *env, jobject obj) {
- NSK_DISPLAY0("inside the nativeMethod()\n");
-}
-
-/* dummy method used only to provoke NativeMethodBind event */
-JNIEXPORT void JNICALL
-Java_nsk_jvmti_NativeMethodBind_nativemethbind003_registerNative(
- JNIEnv *env, jobject obj) {
- jclass testedCls = NULL;
- JNINativeMethod meth;
-
- NSK_DISPLAY1("Inside the registerNative()\n"
- "Finding class \"%s\" ...\n",
- CLASS_SIG);
- if (!NSK_JNI_VERIFY(env, (testedCls = env->FindClass(CLASS_SIG)) != NULL)) {
- result = STATUS_FAILED;
- NSK_COMPLAIN1("TEST FAILURE: unable to find class \"%s\"\n\n",
- CLASS_SIG);
- return;
- }
-
- meth.name = (char*) METHODS[0];
- meth.signature = (char*) METHODS[1];
- meth.fnPtr = (void*) nativeMethod;
-
- NSK_DISPLAY3(
- "Calling RegisterNatives() with \"%s %s\"\n"
- "\tfor class \"%s\" ...\n",
- METHODS[0], METHODS[1], CLASS_SIG);
- if (!NSK_JNI_VERIFY_VOID(env, (env->RegisterNatives(testedCls, &meth, 1)) != 0)) {
- result = STATUS_FAILED;
- NSK_COMPLAIN3("TEST FAILURE: unable to RegisterNatives() \"%s %s\" for class \"%s\"\n\n",
- METHODS[0], METHODS[1], CLASS_SIG);
- }
-
- NSK_DISPLAY1("Calling UnregisterNatives() for class \"%s\" ...\n",
- CLASS_SIG);
- if (!NSK_JNI_VERIFY_VOID(env, (env->UnregisterNatives(testedCls)) != 0)) {
- result = STATUS_FAILED;
- NSK_COMPLAIN3("TEST FAILURE: unable to UnregisterNatives() \"%s %s\" for class \"%s\"\n\n",
- METHODS[1][0], METHODS[1][1], CLASS_SIG);
- }
-}
-
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_nativemethbind003(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_nativemethbind003(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_nativemethbind003(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
- jvmtiCapabilities caps;
-
- /* init framework and parse options */
- if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
- return JNI_ERR;
-
- /* create JVMTI environment */
- if (!NSK_VERIFY((jvmti =
- nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
- return JNI_ERR;
-
- /* create a raw monitor */
- if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_counter_lock", &countLock)))
- return JNI_ERR;
-
- /* add capability to generate compiled method events */
- memset(&caps, 0, sizeof(jvmtiCapabilities));
- caps.can_generate_native_method_bind_events = 1;
- if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
- return JNI_ERR;
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
- return JNI_ERR;
- if (!caps.can_generate_native_method_bind_events)
- NSK_DISPLAY0("Warning: generation of native method bind events is not implemented\n");
-
- /* set event callback */
- NSK_DISPLAY0("setting event callbacks ...\n");
- (void) memset(&callbacks, 0, sizeof(callbacks));
- callbacks.NativeMethodBind = &NativeMethodBind;
- callbacks.VMDeath = &VMDeath;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
- return JNI_ERR;
-
- NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_NATIVE_METHOD_BIND,
- NULL)))
- return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_VM_DEATH,
- NULL)))
- return JNI_ERR;
- NSK_DISPLAY0("enabling the events done\n\n");
-
- return JNI_OK;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004.java
deleted file mode 100644
index 1a8f8a47ed1..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.NativeMethodBind;
-
-import java.io.*;
-
-import nsk.share.*;
-import nsk.share.jvmti.*;
-
-/**
- * This test exercises the JVMTI event NativeMethodBind.
- *
It verifies that binding native method can be redirected during
- * the event callback.
- * The test works as follows. An agent part enables the NativeMethodBind
- * generation. Then the java part invokes the native method
- * nativeMethod() which leads to the NativeMethodBind generation.
- * In NativeMethodBind callback incoming address of the nativeMethod() is
- * changed to the address of another native method
- * redirNativeMethod().
- * Both functions nativeMethod() and redirNativeMethod() count their calls.
- * In accordance with the spec, the nativeMethod() should not be invoked
- * and the redirNativeMethod() should be invoked once.
- */
-public class nativemethbind004 {
- static {
- try {
- System.loadLibrary("nativemethbind004");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load \"nativemethbind004\" library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native void nativeMethod();
- native int check();
-
- public static void main(String[] argv) {
- argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
-
- // produce JCK-like exit status
- System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
- }
-
- public static int run(String argv[], PrintStream out) {
- return new nativemethbind004().runThis(argv, out);
- }
-
- private int runThis(String argv[], PrintStream out) {
- // invoke native method to be redirected
- nativeMethod();
-
- return check();
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/TestDescription.java
deleted file mode 100644
index 0df748ca36d..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/TestDescription.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/NativeMethodBind/nativemethbind004.
- * VM Testbase keywords: [quick, jpda, jvmti, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * This test exercises the JVMTI event NativeMethodBind.
- * It verifies that binding native method can be redirected during
- * the event callback.
- * The test works as follows. An agent part enables the NativeMethodBind
- * generation. Then the java part invokes the native method 'nativeMethod()'
- * which leads to the NativeMethodBind generation. In NativeMethodBind
- * callback incoming address of the nativeMethod() is changed to the
- * address of another native method 'redirNativeMethod()'. Both functions
- * nativeMethod() and redirNativeMethod() count their calls.
- * In accordance with the spec, the nativeMethod() should not be invoked
- * and the redirNativeMethod() should be invoked once.
- * COMMENTS
- * The test has been fixed due to the bug 4967116.
- * Fixed the 4995867 bug.
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native
- * -agentlib:nativemethbind004=-waittime=5
- * nsk.jvmti.NativeMethodBind.nativemethbind004
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/libnativemethbind004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/libnativemethbind004.cpp
deleted file mode 100644
index 12370c2fc6b..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/libnativemethbind004.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "nativemethbind004.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/nativemethbind004.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/nativemethbind004.cpp
deleted file mode 100644
index a516f4564e4..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/NativeMethodBind/nativemethbind004/nativemethbind004.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include "jni_tools.h"
-#include "agent_common.h"
-#include "jvmti_tools.h"
-
-extern "C" {
-
-#define STATUS_FAILED 2
-#define PASSED 0
-
-/* tested method */
-static const char *METHOD[] = {
- "nativeMethod", "()V"
-};
-
-/* counter for the original method calls */
-static volatile int origCalls = 0;
-/* counter for the redirected method calls */
-static volatile int redirCalls = 0;
-
-static volatile jint result = PASSED;
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-static jrawMonitorID countLock;
-
-/* method to be redirected used to check the native method redirection
- through the NativeMethodBind event */
-JNIEXPORT void JNICALL
-Java_nsk_jvmti_NativeMethodBind_nativemethbind004_nativeMethod(
- JNIEnv *env, jobject obj) {
- origCalls++;
- NSK_DISPLAY1("inside the nativeMethod(): calls=%d\n",
- origCalls);
-}
-
-/* redirected method used to check the native method redirection
- through the NativeMethodBind event */
-static void JNICALL
-redirNativeMethod(JNIEnv *env, jobject obj) {
- redirCalls++;
- NSK_DISPLAY1("inside the redirNativeMethod(): calls=%d\n",
- redirCalls);
-}
-
-static void lock(jvmtiEnv *jvmti_env, JNIEnv *jni_env) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(countLock)))
- jni_env->FatalError("failed to enter a raw monitor\n");
-}
-
-static void unlock(jvmtiEnv *jvmti_env, JNIEnv *jni_env) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(countLock)))
- jni_env->FatalError("failed to exit a raw monitor\n");
-}
-
-/** callback functions **/
-void JNICALL
-NativeMethodBind(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
- jmethodID method, void *addr, void **new_addr) {
- jvmtiPhase phase;
- char *methNam, *methSig;
- lock(jvmti_env, jni_env);
-
- NSK_DISPLAY0(">>>> NativeMethodBind event received\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) {
- result = STATUS_FAILED;
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if (phase != JVMTI_PHASE_LIVE && phase != JVMTI_PHASE_START) {
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to get method name during NativeMethodBind callback\n\n");
- unlock(jvmti_env, jni_env);
- return;
- }
-
- if ((strcmp(methNam,METHOD[0]) == 0) &&
- (strcmp(methSig,METHOD[1]) == 0)) {
- NSK_DISPLAY4("\tmethod: \"%s %s\"\nRedirecting the method address from 0x%p to 0x%p ...\n",
- methNam, methSig, addr, (void*) redirNativeMethod);
-
- *new_addr = (void*) redirNativeMethod;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methNam))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory storing method name\n\n");
- }
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methSig))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory storing method signature\n\n");
- }
-
- NSK_DISPLAY0("<<<<\n\n");
-
- unlock(jvmti_env, jni_env);
-}
-/************************/
-
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_NativeMethodBind_nativemethbind004_check(
- JNIEnv *env, jobject obj) {
-
- if (origCalls == 0) {
- NSK_DISPLAY0(
- "CHECK PASSED: original nativeMethod() to be redirected\n"
- "\thas not been invoked as expected\n");
- } else {
- result = STATUS_FAILED;
- NSK_COMPLAIN1(
- "TEST FAILED: nativeMethod() has not been redirected by the NativeMethodBind:\n"
- "\t%d calls\texpected: 0\n\n",
- origCalls);
- }
-
- if (redirCalls == 1) {
- NSK_DISPLAY1(
- "CHECK PASSED: nativeMethod() has been redirected by the NativeMethodBind:\n"
- "\t%d calls of redirected method as expected\n",
- redirCalls);
- } else {
- result = STATUS_FAILED;
- NSK_COMPLAIN1(
- "TEST FAILED: nativeMethod() has not been redirected by the NativeMethodBind:\n"
- "\t%d calls of redirected method\texpected: 1\n\n",
- redirCalls);
- }
-
- return result;
-}
-
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_nativemethbind004(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_nativemethbind004(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_nativemethbind004(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
- jvmtiCapabilities caps;
-
- /* init framework and parse options */
- if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
- return JNI_ERR;
-
- /* create JVMTI environment */
- if (!NSK_VERIFY((jvmti =
- nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
- return JNI_ERR;
-
- /* create a raw monitor */
- if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_counter_lock", &countLock)))
- return JNI_ERR;
-
- /* add capability to generate compiled method events */
- memset(&caps, 0, sizeof(jvmtiCapabilities));
- caps.can_generate_native_method_bind_events = 1;
- if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
- return JNI_ERR;
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
- return JNI_ERR;
- if (!caps.can_generate_native_method_bind_events)
- NSK_DISPLAY0("Warning: generation of native method bind events is not implemented\n");
-
- /* set event callback */
- NSK_DISPLAY0("setting event callbacks ...\n");
- (void) memset(&callbacks, 0, sizeof(callbacks));
- callbacks.NativeMethodBind = &NativeMethodBind;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
- return JNI_ERR;
-
- NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_NATIVE_METHOD_BIND,
- NULL)))
- return JNI_ERR;
- NSK_DISPLAY0("enabling the events done\n\n");
-
- return JNI_OK;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001.java
deleted file mode 100644
index 862b9fee1c0..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.SingleStep;
-
-import java.io.*;
-
-import nsk.share.*;
-import nsk.share.jvmti.*;
-
-/**
- * This test exercises the JVMTI event SingleStep.
- *
It verifies that this event can be enabled and disabled
- * during program execution.
- * The test works as follows. Breakpoint is set at special method
- * bpMethod(). Upon reaching the breakpoint, agent
- * enables SingleStep event generation. All the received
- * events are counted. When the method bpMethod() is
- * leaved and accordingly, the program returns to the calling method
- * runThis(), the agent disables the event generation.
- * At least one SingleStep event must be received for
- * the each methods mentioned above. Also after disabling the event
- * no more event must be received.
- */
-public class singlestep001 {
- static {
- try {
- System.loadLibrary("singlestep001");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load \"singlestep001\" library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native int check();
-
- public static void main(String[] argv) {
- argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
-
- // produce JCK-like exit status
- System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
- }
-
- public static int run(String argv[], PrintStream out) {
- return new singlestep001().runThis(argv, out);
- }
-
- private int runThis(String argv[], PrintStream out) {
- ArgumentHandler argHandler = new ArgumentHandler(argv);
- Log log = new Log(out, argHandler);
- Thread.currentThread().setName("singlestep001Thr");
-
- log.display("\nReaching a breakpoint method ...\n");
- bpMethod();
- log.display("The breakpoint method leaved ...");
-
- return check();
- }
-
- /**
- * dummy method used only to reach breakpoint set in the agent
- */
- private void bpMethod() {
- int dummyVar = 0;
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001/TestDescription.java
deleted file mode 100644
index 9a5182b0e98..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001/TestDescription.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/SingleStep/singlestep001.
- * VM Testbase keywords: [quick, jpda, jvmti, onload_only_caps, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * This test exercises the JVMTI event SingleStep.
- * It verifies that this event can be enabled and disabled during
- * program execution.
- * The test works as follows. Breakpoint is set at special method
- * 'bpMethod()'. Upon reaching the breakpoint, agent enables SingleStep
- * event generation. All the received events are counted. When the
- * method 'bpMethod()' is leaved and accordingly, the program returns
- * to the calling method 'runThis()', the agent disables the event
- * generation.
- * At least one SingleStep event must be received for the each method
- * mentioned above. Also after disabling the event no more events
- * must be received.
- * COMMENTS
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native -agentlib:singlestep001=-waittime=5 nsk.jvmti.SingleStep.singlestep001
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001/libsinglestep001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001/libsinglestep001.cpp
deleted file mode 100644
index 2922b2ba42d..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001/libsinglestep001.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "singlestep001.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001/singlestep001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001/singlestep001.cpp
deleted file mode 100644
index 7c887ec85d2..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep001/singlestep001.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (c) 2003, 2019, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include
-#include "agent_common.h"
-
-#include "nsk_tools.h"
-#include "JVMTITools.h"
-#include "jvmti_tools.h"
-#include "jni_tools.h"
-
-extern "C" {
-
-#define STATUS_FAILED 2
-#define PASSED 0
-
-#define METH_NUM 2
-
-static const char *METHODS[] = {
- "bpMethod",
- "runThis"
-};
-
-static const char *METHOD_SIGS[] = {
- "()V",
- "([Ljava/lang/String;Ljava/io/PrintStream;)I"
-};
-
-static volatile long stepEv[] = { 0, 0 };
-
-static const char *CLASS_SIG =
- "Lnsk/jvmti/SingleStep/singlestep001;";
-
-static volatile jint result = PASSED;
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-
-static volatile int callbacksEnabled = NSK_FALSE;
-static jrawMonitorID agent_lock;
-
-static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) {
- jmethodID mid;
-
- if (!NSK_JNI_VERIFY(env, (mid = env->GetMethodID(klass, METHODS[0], METHOD_SIGS[0])) != NULL))
- env->FatalError("failed to get ID for the java method\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(mid, 0)))
- env->FatalError("failed to set breakpoint\n");
-}
-
-/** callback functions **/
-void JNICALL
-ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
- char *sig, *generic;
-
- jvmti->RawMonitorEnter(agent_lock);
-
- if (callbacksEnabled) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic)))
- env->FatalError("failed to obtain a class signature\n");
-
- if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) {
- NSK_DISPLAY1(
- "ClassLoad event received for the class \"%s\"\n"
- "\tsetting breakpoint ...\n",
- sig);
- setBP(jvmti_env, env, klass);
- }
- }
-
- jvmti->RawMonitorExit(agent_lock);
-}
-
-void JNICALL
-Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method,
- jlocation loc) {
- jclass klass;
- char *sig, *generic;
-
- jvmti->RawMonitorEnter(agent_lock);
-
- if (!callbacksEnabled) {
- jvmti->RawMonitorExit(agent_lock);
- return;
- }
-
- NSK_DISPLAY0("Breakpoint event received\n");
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass)))
- NSK_COMPLAIN0("TEST FAILURE: unable to get method declaring class\n\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic)))
- env->FatalError("Breakpoint: failed to obtain a class signature\n");
-
- if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) {
- NSK_DISPLAY1("method declaring class \"%s\"\n\tenabling SingleStep events ...\n",
- sig);
- if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILURE: cannot enable SingleStep events\n\n");
- }
- } else {
- result = STATUS_FAILED;
- NSK_COMPLAIN1("TEST FAILURE: unexpected breakpoint event in method of class \"%s\"\n\n",
- sig);
- }
- jvmti->RawMonitorExit(agent_lock);
-}
-
-void JNICALL
-SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
- jmethodID method, jlocation location) {
- jclass klass;
- char *sig, *generic, *methNam, *methSig;
-
- if (result == STATUS_FAILED) {
- return;
- }
-
- NSK_DISPLAY0(">>>> SingleStep event received\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to get method name during SingleStep callback\n\n");
- return;
- }
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during SingleStep callback\n\n");
- return;
- }
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during SingleStep callback\n\n");
- return;
- }
-
- if (sig != NULL) {
- NSK_DISPLAY3(
- "\tmethod name: \"%s\"\n"
- "\tsignature: \"%s\"\n"
- "\tmethod declaring class: \"%s\"\n",
- methNam, methSig, sig);
-
- if (stepEv[1] == 1) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: SingleStep event received after disabling the event generation\n\n");
- }
- else if ((strcmp(methNam,METHODS[0]) == 0) &&
- (strcmp(methSig,METHOD_SIGS[0]) == 0) &&
- (strcmp(sig,CLASS_SIG) == 0)) {
- stepEv[0]++;
- NSK_DISPLAY1("CHECK PASSED: SingleStep event received for the method \"%s\" as expected\n",
- methNam);
- }
- else if ((strcmp(methNam,METHODS[1]) == 0) &&
- (strcmp(methSig,METHOD_SIGS[1]) == 0) &&
- (strcmp(sig,CLASS_SIG) == 0)) {
- stepEv[1]++;
- NSK_DISPLAY1(
- "CHECK PASSED: SingleStep event received for the method \"%s\" as expected\n"
- "\tdisabling the event generation\n",
- methNam);
- if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, thread))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: cannot disable SingleStep events\n\n");
- }
- }
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methNam))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n");
- }
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methSig))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n");
- }
-
- NSK_DISPLAY0("<<<<\n\n");
-}
-
-void JNICALL
-VMStart(jvmtiEnv *jvmti_env, JNIEnv* jni_env) {
- jvmti->RawMonitorEnter(agent_lock);
-
- callbacksEnabled = NSK_TRUE;
-
- jvmti->RawMonitorExit(agent_lock);
-}
-
-void JNICALL
-VMDeath(jvmtiEnv *jvmti_env, JNIEnv* jni_env) {
- jvmti->RawMonitorEnter(agent_lock);
-
- callbacksEnabled = NSK_FALSE;
-
- jvmti->RawMonitorExit(agent_lock);
-}
-/************************/
-
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_SingleStep_singlestep001_check(
- JNIEnv *env, jobject obj) {
- int i;
-
- for (i=0; iAddCapabilities(&caps)))
- return JNI_ERR;
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
- return JNI_ERR;
-
- if (!caps.can_generate_single_step_events)
- NSK_DISPLAY0("Warning: generation of single step events is not implemented\n");
-
- /* set event callback */
- NSK_DISPLAY0("setting event callbacks ...\n");
- (void) memset(&callbacks, 0, sizeof(callbacks));
- callbacks.ClassLoad = &ClassLoad;
- callbacks.Breakpoint = &Breakpoint;
- callbacks.SingleStep = &SingleStep;
- callbacks.VMStart = &VMStart;
- callbacks.VMDeath = &VMDeath;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
- return JNI_ERR;
-
- NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL)))
- return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
- return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL)))
- return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL)))
- return JNI_ERR;
- NSK_DISPLAY0("enabling the events done\n\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("agent lock", &agent_lock)))
- return JNI_ERR;
-
- return JNI_OK;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002.java
deleted file mode 100644
index 3c9ef01361b..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.SingleStep;
-
-import java.io.*;
-
-import nsk.share.*;
-import nsk.share.jvmti.*;
-
-/**
- * This test exercises the JVMTI event SingleStep.
- *
It verifies that this event is sent only during the live
- * phase of VM execution.
- * The test works as follows. The tested event is enabled in the
- * OnLoad phase. Then all received SingleStep
- * events is checked to be sent only during the live phase via
- * the GetPhase() call.
- */
-public class singlestep002 {
- private Log log;
-
- static {
- try {
- System.loadLibrary("singlestep002");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load \"singlestep002\" library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- public static void main(String[] argv) {
- argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
-
- // produce JCK-like exit status
- System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
- }
-
- public static int run(String argv[], PrintStream out) {
- return new singlestep002().runThis(argv, out);
- }
-
- private int runThis(String argv[], PrintStream out) {
- return Consts.TEST_PASSED;
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002/TestDescription.java
deleted file mode 100644
index c074ad77578..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002/TestDescription.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/SingleStep/singlestep002.
- * VM Testbase keywords: [jpda, jvmti, onload_only_caps, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * This test exercises the JVMTI event SingleStep.
- * It verifies that this event s sent only during the live phase
- * of VM execution.
- * The test works as follows. The tested event is enabled in the
- * 'OnLoad' phase. Then all received SingleStep events is checked
- * to be sent only during the live phase via the GetPhase() call.
- * COMMENTS
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native -agentlib:singlestep002=-waittime=5 nsk.jvmti.SingleStep.singlestep002
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002/libsinglestep002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002/libsinglestep002.cpp
deleted file mode 100644
index 322bbf5b69d..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002/libsinglestep002.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "singlestep002.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002/singlestep002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002/singlestep002.cpp
deleted file mode 100644
index 3fd27126db6..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep002/singlestep002.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include
-#include
-#include "agent_common.h"
-
-#include "nsk_tools.h"
-#include "JVMTITools.h"
-#include "jvmti_tools.h"
-#include "jni_tools.h"
-
-extern "C" {
-
-#define STATUS_FAILED 2
-#define PASSED 0
-
-static volatile jint result = PASSED;
-static volatile long wrongStepEv = 0;
-
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-static jvmtiCapabilities caps;
-
-/** callback functions **/
-void JNICALL
-SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
- jmethodID method, jlocation location) {
- jvmtiPhase phase;
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to obtain phase of the VM execution during SingleStep callback\n\n");
- }
- else {
- if (phase != JVMTI_PHASE_LIVE) {
- wrongStepEv++;
- result = STATUS_FAILED;
- NSK_COMPLAIN1("TEST FAILED: SingleStep event received during non-live phase %s\n",
- TranslatePhase(phase));
- }
- }
-}
-
-void JNICALL
-VMDeath(jvmtiEnv *jvmti_env, JNIEnv *env) {
- NSK_DISPLAY0("VMDeath event received\n");
-
- if (wrongStepEv != 0) {
- NSK_COMPLAIN1(
- "TEST FAILED: there are %d SingleStep events\n"
- "sent during non-live phase of the VM execution\n",
- wrongStepEv);
- }
-
- if (result == STATUS_FAILED)
- exit(95 + STATUS_FAILED);
-}
-/************************/
-
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_singlestep002(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_singlestep002(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_singlestep002(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
- /* init framework and parse options */
- if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
- return JNI_ERR;
-
- /* create JVMTI environment */
- if (!NSK_VERIFY((jvmti =
- nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
- return JNI_ERR;
-
- /* add capability to generate compiled method events */
- memset(&caps, 0, sizeof(jvmtiCapabilities));
- caps.can_generate_single_step_events = 1;
- if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))
- return JNI_ERR;
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
- return JNI_ERR;
-
- if (!caps.can_generate_single_step_events)
- NSK_DISPLAY0("Warning: generation of single step events is not implemented\n");
-
- /* set event callback */
- NSK_DISPLAY0("setting event callbacks ...\n");
- (void) memset(&callbacks, 0, sizeof(callbacks));
- callbacks.SingleStep = &SingleStep;
- callbacks.VMDeath = &VMDeath;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
- return JNI_ERR;
-
- NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, NULL)))
- return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
- return JNI_ERR;
- NSK_DISPLAY0("enabling the events done\n\n");
-
- return JNI_OK;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003.java
deleted file mode 100644
index bdbc1cd455b..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.SingleStep;
-
-import java.io.*;
-
-import nsk.share.*;
-import nsk.share.jvmti.*;
-
-/**
- * This test exercises the JVMTI event SingleStep.
- *
It verifies that no single step event will be generated from
- * within native methods.
- * The test works as follows. Breakpoint is set at special method
- * bpMethod(). Upon reaching the breakpoint, agent
- * enables SingleStep event generation and checks the
- * events. The java part calls native method nativeMethod()
- * which calls another native anotherNativeMethod()
- * in order to provoke the SingleStep events from within native
- * methods. When bpMethod() is leaved and accordingly,
- * the program returns to the calling method runThis(),
- * the agent disables the event generation.
- */
-public class singlestep003 {
- static {
- try {
- System.loadLibrary("singlestep003");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load \"singlestep003\" library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native void nativeMethod();
- native void anotherNativeMethod(int i);
-
- native int check();
-
- public static void main(String[] argv) {
- argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
-
- // produce JCK-like exit status
- System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
- }
-
- public static int run(String argv[], PrintStream out) {
- return new singlestep003().runThis(argv, out);
- }
-
- private int runThis(String argv[], PrintStream out) {
- ArgumentHandler argHandler = new ArgumentHandler(argv);
- Log log = new Log(out, argHandler);
-
- log.display("\nReaching a breakpoint method ...\n");
- bpMethod();
- log.display("The breakpoint method leaved ...");
-
- return check();
- }
-
- /**
- * dummy method used to reach breakpoint, enable the SingleStep
- * event in the agent and provoke SingleStep for native method
- */
- private void bpMethod() {
- nativeMethod();
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/TestDescription.java
deleted file mode 100644
index ccd20ab33e4..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/TestDescription.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/SingleStep/singlestep003.
- * VM Testbase keywords: [quick, jpda, jvmti, onload_only_caps, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * This test exercises the JVMTI event SingleStep.
- * It verifies that no single step event will be generated from
- * within native methods.
- * The test works as follows. Breakpoint is set at special method
- * 'bpMethod()'. Upon reaching the breakpoint, agent enables
- * SingleStep event generation and checks the events. The java part
- * calls native method 'nativeMethod()' which calls another native
- * 'anotherNativeMethod()' in order to provoke the SingleStep events
- * from within native methods. When 'bpMethod()' is leaved and
- * accordingly, the program returns to the calling method 'runThis()',
- * the agent disables the event generation.
- * COMMENTS
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native -agentlib:singlestep003=-waittime=5 nsk.jvmti.SingleStep.singlestep003
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/libsinglestep003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/libsinglestep003.cpp
deleted file mode 100644
index 6402de7ce60..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/libsinglestep003.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "singlestep003.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/singlestep003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/singlestep003.cpp
deleted file mode 100644
index e5fced2c839..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SingleStep/singlestep003/singlestep003.cpp
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (c) 2003, 2019, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include
-#include "agent_common.h"
-
-#include "nsk_tools.h"
-#include "JVMTITools.h"
-#include "jvmti_tools.h"
-#include "jni_tools.h"
-
-extern "C" {
-
-#define STATUS_FAILED 2
-#define PASSED 0
-
-/* tested methods */
-#define METH_NUM 4
-static const char *METHODS[][2] = {
- { "bpMethod", "()V" },
- { "nativeMethod", "()V" },
- { "anotherNativeMethod", "(I)V" },
- { "runThis", "([Ljava/lang/String;Ljava/io/PrintStream;)I" }
-};
-
-/* event counters for the tested methods and expected numbers
- of the events */
-static volatile long stepEv[][2] = {
- { 0, 1 },
- { 0, 0 },
- { 0, 0 },
- { 0, 1 }
-};
-
-static const char *CLASS_SIG =
- "Lnsk/jvmti/SingleStep/singlestep003;";
-
-static volatile jint result = PASSED;
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-
-static volatile int callbacksEnabled = NSK_FALSE;
-static jrawMonitorID agent_lock;
-
-static void setBP(jvmtiEnv *jvmti_env, JNIEnv *env, jclass klass) {
- jmethodID mid;
-
- if (!NSK_JNI_VERIFY(env, (mid = env->GetMethodID(klass, METHODS[0][0], METHODS[0][1])) != NULL))
- env->FatalError("failed to get ID for the java method\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->SetBreakpoint(mid, 0)))
- env->FatalError("failed to set breakpoint\n");
-}
-
-/** callback functions **/
-void JNICALL
-ClassLoad(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread, jclass klass) {
- char *sig, *generic;
-
- jvmti->RawMonitorEnter(agent_lock);
-
- if (!callbacksEnabled) {
- jvmti->RawMonitorExit(agent_lock);
- return;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic)))
- env->FatalError("failed to obtain a class signature\n");
-
- if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) {
- NSK_DISPLAY1(
- "ClassLoad event received for the class \"%s\"\n"
- "\tsetting breakpoint ...\n",
- sig);
- setBP(jvmti_env, env, klass);
- }
-
- jvmti->RawMonitorExit(agent_lock);
-}
-
-void JNICALL
-VMStart(jvmtiEnv *jvmti_env, JNIEnv* jni_env) {
- jvmti->RawMonitorEnter(agent_lock);
-
- callbacksEnabled = NSK_TRUE;
-
- jvmti->RawMonitorExit(agent_lock);
-}
-
-
-void JNICALL
-VMDeath(jvmtiEnv *jvmti_env, JNIEnv* jni_env) {
- jvmti->RawMonitorEnter(agent_lock);
-
- callbacksEnabled = NSK_FALSE;
-
- jvmti->RawMonitorExit(agent_lock);
-}
-
-void JNICALL
-Breakpoint(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr, jmethodID method,
- jlocation loc) {
- jclass klass;
- char *sig, *generic;
-
- jvmti->RawMonitorEnter(agent_lock);
-
- if (!callbacksEnabled) {
- jvmti->RawMonitorExit(agent_lock);
- return;
- }
-
- NSK_DISPLAY0("Breakpoint event received\n");
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass)))
- NSK_COMPLAIN0("TEST FAILURE: unable to get method declaring class\n\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic)))
- env->FatalError("Breakpoint: failed to obtain a class signature\n");
-
- if (sig != NULL && (strcmp(sig, CLASS_SIG) == 0)) {
- NSK_DISPLAY1("method declaring class \"%s\"\n\tenabling SingleStep events ...\n",
- sig);
- if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_SINGLE_STEP, thr))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILURE: cannot enable SingleStep events\n\n");
- }
- } else {
- result = STATUS_FAILED;
- NSK_COMPLAIN1("TEST FAILURE: unexpected breakpoint event in method of class \"%s\"\n\n",
- sig);
- }
-
- jvmti->RawMonitorExit(agent_lock);
-}
-
-void JNICALL
-SingleStep(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread,
- jmethodID method, jlocation location) {
- jclass klass;
- char *sig, *generic, *methNam, *methSig;
- int i;
-
- if (result == STATUS_FAILED) {
- return;
- }
-
- NSK_DISPLAY0(">>>> SingleStep event received\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodName(method, &methNam, &methSig, NULL))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to get method name during SingleStep callback\n\n");
- return;
- }
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetMethodDeclaringClass(method, &klass))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to get method declaring class during SingleStep callback\n\n");
- return;
- }
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetClassSignature(klass, &sig, &generic))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to obtain a class signature during SingleStep callback\n\n");
- return;
- }
-
- if (sig != NULL) {
- if (stepEv[METH_NUM-1][0] == 1) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: SingleStep event received after disabling the event generation\n\n");
- return;
- }
-
- for (i=0; iSetEventNotificationMode(JVMTI_DISABLE, JVMTI_EVENT_SINGLE_STEP, thread))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: cannot disable SingleStep events\n\n");
- }
- }
- }
- }
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methNam))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method name\n\n");
- }
- if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) methSig))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: unable to deallocate memory pointed to method signature\n\n");
- }
-
- NSK_DISPLAY0("<<<<\n\n");
-}
-/************************/
-
-/* dummy method used only to provoke SingleStep events */
-JNIEXPORT void JNICALL
-Java_nsk_jvmti_SingleStep_singlestep003_anotherNativeMethod(
- JNIEnv *env, jobject obj, jint i) {
- NSK_DISPLAY0("inside the anotherNativeMethod()\n\n");
-}
-
-/* dummy method used only to provoke SingleStep events */
-JNIEXPORT void JNICALL
-Java_nsk_jvmti_SingleStep_singlestep003_nativeMethod(
- JNIEnv *env, jobject obj) {
- jint i = 0;
-
- NSK_DISPLAY0("inside the nativeMethod()\n\n");
- i++;
-
- Java_nsk_jvmti_SingleStep_singlestep003_anotherNativeMethod(env, obj, i);
-}
-
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_SingleStep_singlestep003_check(
- JNIEnv *env, jobject obj) {
- int i;
-
- for (i=0; iAddCapabilities(&caps)))
- return JNI_ERR;
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))
- return JNI_ERR;
- if (!caps.can_generate_single_step_events)
- NSK_DISPLAY0("Warning: generation of single step events is not implemented\n");
-
- /* set event callback */
- NSK_DISPLAY0("setting event callbacks ...\n");
- (void) memset(&callbacks, 0, sizeof(callbacks));
- callbacks.ClassLoad = &ClassLoad;
- callbacks.Breakpoint = &Breakpoint;
- callbacks.SingleStep = &SingleStep;
- callbacks.VMStart = &VMStart;
- callbacks.VMDeath = &VMDeath;
-
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
- return JNI_ERR;
-
- NSK_DISPLAY0("setting event callbacks done\nenabling JVMTI events ...\n");
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_START, NULL)))
- return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
- return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL)))
- return JNI_ERR;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_BREAKPOINT, NULL)))
- return JNI_ERR;
- NSK_DISPLAY0("enabling the events done\n\n");
-
- if (jvmti->CreateRawMonitor("agent_lock", &agent_lock) != JVMTI_ERROR_NONE) {
- return JNI_ERR;
- }
-
- return JNI_OK;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001.java
deleted file mode 100644
index db8902f9f27..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.ThreadEnd;
-
-import java.io.PrintStream;
-
-public class threadend001 {
-
- final static int JCK_STATUS_BASE = 95;
- final static int THREADS_LIMIT = 100;
- final static String NAME_PREFIX = "threadend001-";
-
- static {
- try {
- System.loadLibrary("threadend001");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load threadend001 library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native static void getReady(int i, String name);
- native static int check();
-
- static volatile int thrCount = THREADS_LIMIT;
-
- public static void main(String args[]) {
- args = nsk.share.jvmti.JVMTITest.commonInit(args);
-
- // produce JCK-like exit status.
- System.exit(run(args, System.out) + JCK_STATUS_BASE);
- }
-
- public static int run(String args[], PrintStream out) {
- TestThread t = new TestThread(NAME_PREFIX + thrCount);
- getReady(THREADS_LIMIT, NAME_PREFIX);
- t.start();
- try {
- t.join();
- } catch (InterruptedException e) {
- throw new Error("Unexpected: " + e);
- }
- return check();
- }
-
- static class TestThread extends Thread {
- public TestThread(String name) {
- super(name);
- }
- public void run() {
- thrCount--;
- if (thrCount > 0) {
- TestThread t = new TestThread(NAME_PREFIX + thrCount);
- t.start();
- try {
- t.join();
- } catch (InterruptedException e) {
- throw new Error("Unexpected: " + e);
- }
- }
- }
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001/TestDescription.java
deleted file mode 100644
index 36d597c1578..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001/TestDescription.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/ThreadEnd/threadend001.
- * VM Testbase keywords: [quick, jpda, jvmti, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * The test exercises JVMTI event callback function ThreadEnd.
- * The test checks if the event is ganerated by a terminating
- * thread after its initial method has finished execution.
- * COMMENTS
- * Ported from JVMDI.
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native -agentlib:threadend001 nsk.jvmti.ThreadEnd.threadend001
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001/libthreadend001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001/libthreadend001.cpp
deleted file mode 100644
index 2b0db0f9a4a..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001/libthreadend001.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "threadend001.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001/threadend001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001/threadend001.cpp
deleted file mode 100644
index ff9eb3753a4..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend001/threadend001.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include "jvmti.h"
-#include "agent_common.h"
-#include "JVMTITools.h"
-
-extern "C" {
-
-
-#define PASSED 0
-#define STATUS_FAILED 2
-
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-static jint result = PASSED;
-static jboolean printdump = JNI_FALSE;
-static int eventsCount = 0;
-static int eventsExpected = 0;
-static const char *prefix = NULL;
-
-void JNICALL ThreadEnd(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
- jvmtiError err;
- jvmtiThreadInfo inf;
- char name[32];
-
- err = jvmti_env->GetThreadInfo(thread, &inf);
- if (err != JVMTI_ERROR_NONE) {
- printf("(GetThreadInfo#%d) unexpected error: %s (%d)\n",
- eventsCount, TranslateError(err), err);
- result = STATUS_FAILED;
- }
- if (printdump == JNI_TRUE) {
- printf(">>> %s\n", inf.name);
- }
- if (inf.name != NULL && strstr(inf.name, prefix) == inf.name) {
- eventsCount++;
- sprintf(name, "%s%d", prefix, eventsCount);
- if (inf.name == NULL || strcmp(name, inf.name) != 0) {
- printf("(#%d) wrong thread name: \"%s\"",
- eventsCount, inf.name);
- printf(", expected: \"%s\"\n", name);
- result = STATUS_FAILED;
- }
- }
-}
-
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_threadend001(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_threadend001(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_threadend001(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
- jvmtiError err;
- jint res;
-
- if (options != NULL && strcmp(options, "printdump") == 0) {
- printdump = JNI_TRUE;
- }
-
- res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
- if (res != JNI_OK || jvmti == NULL) {
- printf("Wrong result of a valid call to GetEnv!\n");
- return JNI_ERR;
- }
-
- callbacks.ThreadEnd = &ThreadEnd;
- err = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
- if (err != JVMTI_ERROR_NONE) {
- printf("(SetEventCallbacks) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- return JNI_ERR;
- }
-
- return JNI_OK;
-}
-
-JNIEXPORT void JNICALL
-Java_nsk_jvmti_ThreadEnd_threadend001_getReady(JNIEnv *env,
- jclass cls, jint i, jstring name) {
- jvmtiError err;
-
- if (jvmti == NULL) {
- printf("JVMTI client was not properly loaded!\n");
- return;
- }
-
- prefix = env->GetStringUTFChars(name, NULL);
- if (prefix == NULL) {
- printf("Failed to copy UTF-8 string!\n");
- result = STATUS_FAILED;
- return;
- }
-
- err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_THREAD_END, NULL);
- if (err == JVMTI_ERROR_NONE) {
- eventsExpected = i;
- } else {
- printf("Failed to enable JVMTI_EVENT_THREAD_END: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_ThreadEnd_threadend001_check(JNIEnv *env, jclass cls) {
- jvmtiError err;
-
- if (jvmti == NULL) {
- printf("JVMTI client was not properly loaded!\n");
- return STATUS_FAILED;
- }
-
- err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,
- JVMTI_EVENT_THREAD_END, NULL);
- if (err != JVMTI_ERROR_NONE) {
- printf("Failed to disable JVMTI_EVENT_THREAD_END: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-
- if (eventsCount != eventsExpected) {
- printf("Wrong number of thread end events: %d, expected: %d\n",
- eventsCount, eventsExpected);
- result = STATUS_FAILED;
- }
- return result;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002.java
deleted file mode 100644
index 3a1f86928d8..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2004, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.ThreadEnd;
-
-import java.io.PrintStream;
-
-import nsk.share.jvmti.*;
-import nsk.share.*;
-
-public class threadend002 extends DebugeeClass {
-
- // run test from command line
- public static void main(String argv[]) {
- argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
-
- // JCK-compatible exit
- System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
- }
-
- // run test from JCK-compatible environment
- public static int run(String argv[], PrintStream out) {
- return new threadend002().runIt(argv, out);
- }
-
- Log.Logger logger;
-
-
- // run debuggee
- public int runIt(String argv[], PrintStream out) {
-
- ArgumentHandler argHandler = new ArgumentHandler(argv);
- logger = new Log.Logger(new Log(out, argHandler), "debuggee> ");
-
- int status = threadend002.checkStatus(Consts.TEST_PASSED);
-
- threadend002Thread thrd = new threadend002Thread();
- thrd.start();
-
- try {
- thrd.join();
- } catch(InterruptedException e) {
- logger.complain("Unexpected exception " + e);
- e.printStackTrace();
- return Consts.TEST_FAILED;
- }
-
- int currStatus = threadend002.checkStatus(Consts.TEST_PASSED);
- if (currStatus != Consts.TEST_PASSED)
- status = currStatus;
-
- return status;
- }
-
- class threadend002Thread extends Thread {
-
- public void run() {
- logger.display("thread finished");
- }
- }
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002/TestDescription.java
deleted file mode 100644
index e6c41ace324..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002/TestDescription.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/ThreadEnd/threadend002.
- * VM Testbase keywords: [quick, jpda, jvmti, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * The test exercises JVMTI event callback function THREAD_END.
- * The test enables this event during OnLoad phase. The test fails
- * if no THREAD_END event is received
- * COMMENTS
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native -agentlib:threadend002=-waittime=5 nsk.jvmti.ThreadEnd.threadend002
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002/libthreadend002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002/libthreadend002.cpp
deleted file mode 100644
index c1b13179216..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002/libthreadend002.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "threadend002.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002/threadend002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002/threadend002.cpp
deleted file mode 100644
index 19625d28037..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadEnd/threadend002/threadend002.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2004, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include "jvmti.h"
-#include "agent_common.h"
-#include "jni_tools.h"
-#include "jvmti_tools.h"
-#include "JVMTITools.h"
-
-extern "C" {
-
-/* ============================================================================= */
-
-/* scaffold objects */
-static jvmtiEnv *jvmti = NULL;
-static jlong timeout = 0;
-
-static int eventCount = 0;
-
-/* ============================================================================= */
-
-JNIEXPORT void JNICALL
-cbThreadEnd(jvmtiEnv* jvmti, JNIEnv* jni_env, jthread thread) {
-
- eventCount++;
-}
-
-/* ============================================================================= */
-
-static int
-enableEvent(jvmtiEventMode enable, jvmtiEvent event) {
-
- if (enable == JVMTI_ENABLE) {
- NSK_DISPLAY1("enabling %s\n", TranslateEvent(event));
- } else {
- NSK_DISPLAY1("disabling %s\n", TranslateEvent(event));
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(enable, event, NULL))) {
- nsk_jvmti_setFailStatus();
- return NSK_FALSE;
- }
-
- return NSK_TRUE;
-}
-
-/* ============================================================================= */
-
-int checkEvents() {
-
- int result = NSK_TRUE;
-
- if (eventCount == 0) {
- nsk_jvmti_setFailStatus();
- NSK_COMPLAIN0("Number of THREAD_END events must be greater than 0\n");
- nsk_jvmti_setFailStatus();
- result = NSK_FALSE;
- }
-
- return result;
-}
-
-/* ============================================================================= */
-
-static int
-setCallBacks() {
- jvmtiEventCallbacks eventCallbacks;
- memset(&eventCallbacks, 0, sizeof(eventCallbacks));
-
- eventCallbacks.ThreadEnd = cbThreadEnd;
-
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks))))
- return NSK_FALSE;
-
- return NSK_TRUE;
-}
-
-/* ============================================================================= */
-
-/** Agent algorithm. */
-static void JNICALL
-agentProc(jvmtiEnv* jvmti, JNIEnv* agentJNI, void* arg) {
-
- NSK_DISPLAY0("Wait for debuggee to become ready\n");
- if (!nsk_jvmti_waitForSync(timeout))
- return;
-
- NSK_DISPLAY0("Let debuggee to continue\n");
- if (!nsk_jvmti_resumeSync())
- return;
-
- if (!nsk_jvmti_waitForSync(timeout))
- return;
-
- if (!checkEvents()) {
- nsk_jvmti_setFailStatus();
- }
-
- NSK_DISPLAY0("Let debuggee to finish\n");
- if (!nsk_jvmti_resumeSync())
- return;
-
-}
-
-/* ============================================================================= */
-
-/** Agent library initialization. */
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_threadend002(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_threadend002(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_threadend002(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
-
- if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
- return JNI_ERR;
-
- timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
-
- jvmti = nsk_jvmti_createJVMTIEnv(jvm, reserved);
- if (!NSK_VERIFY(jvmti != NULL))
- return JNI_ERR;
-
- if (!setCallBacks()) {
- return JNI_ERR;
- }
-
- if (!enableEvent(JVMTI_ENABLE, JVMTI_EVENT_THREAD_END)) {
- NSK_COMPLAIN0("Events could not be enabled");
- nsk_jvmti_setFailStatus();
- return JNI_ERR;
- }
-
- if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
- return JNI_ERR;
-
- return JNI_OK;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001.java
deleted file mode 100644
index c4f3a571d0e..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.ThreadStart;
-
-import java.io.PrintStream;
-
-public class threadstart001 {
-
- final static int JCK_STATUS_BASE = 95;
- final static int THREADS_LIMIT = 100;
- final static String NAME_PREFIX = "threadstart001-";
-
- static {
- try {
- System.loadLibrary("threadstart001");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load threadstart001 library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native static void getReady(int i, String name);
- native static int check();
-
- static volatile int thrCount = 0;
-
- public static void main(String args[]) {
- args = nsk.share.jvmti.JVMTITest.commonInit(args);
-
- // produce JCK-like exit status.
- System.exit(run(args, System.out) + JCK_STATUS_BASE);
- }
-
- public static int run(String args[], PrintStream out) {
- TestThread t = new TestThread(NAME_PREFIX + thrCount);
- getReady(THREADS_LIMIT, NAME_PREFIX);
- t.start();
- try {
- t.join();
- } catch (InterruptedException e) {
- throw new Error("Unexpected: " + e);
- }
- return check();
- }
-
- static class TestThread extends Thread {
- public TestThread(String name) {
- super(name);
- }
- public void run() {
- thrCount++;
- if (thrCount < THREADS_LIMIT) {
- TestThread t = new TestThread(NAME_PREFIX + thrCount);
- t.start();
- try {
- t.join();
- } catch (InterruptedException e) {
- throw new Error("Unexpected: " + e);
- }
- }
- }
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java
deleted file mode 100644
index 19951afa08b..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/ThreadStart/threadstart001.
- * VM Testbase keywords: [quick, jpda, jvmti, noras, quarantine]
- * VM Testbase comments: 8016181
- * VM Testbase readme:
- * DESCRIPTION
- * The test exercises JVMTI event callback function ThreadStart.
- * The test checks if the event is ganerated by a new
- * thread before its initial method executes.
- * COMMENTS
- * Ported from JVMDI.
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native -agentlib:threadstart001 nsk.jvmti.ThreadStart.threadstart001
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001/libthreadstart001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001/libthreadstart001.cpp
deleted file mode 100644
index 50c9c4c969b..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001/libthreadstart001.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "threadstart001.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001/threadstart001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001/threadstart001.cpp
deleted file mode 100644
index 6e892bb2936..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart001/threadstart001.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include "jvmti.h"
-#include "agent_common.h"
-#include "JVMTITools.h"
-
-extern "C" {
-
-
-#define PASSED 0
-#define STATUS_FAILED 2
-
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-static jint result = PASSED;
-static jboolean printdump = JNI_FALSE;
-static int eventsCount = 0;
-static int eventsExpected = 0;
-static const char *prefix = NULL;
-
-void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
- jvmtiError err;
- jvmtiThreadInfo inf;
- char name[32];
-
- err = jvmti_env->GetThreadInfo(thread, &inf);
- if (err != JVMTI_ERROR_NONE) {
- printf("(GetThreadInfo#%d) unexpected error: %s (%d)\n",
- eventsCount, TranslateError(err), err);
- result = STATUS_FAILED;
- }
- if (printdump == JNI_TRUE) {
- printf(">>> %s\n", inf.name);
- }
- if (inf.name != NULL && strstr(inf.name, prefix) == inf.name) {
- sprintf(name, "%s%d", prefix, eventsCount);
- if (strcmp(name, inf.name) != 0) {
- printf("(#%d) wrong thread name: \"%s\"",
- eventsCount, inf.name);
- printf(", expected: \"%s\"\n", name);
- result = STATUS_FAILED;
- }
- eventsCount++;
- }
-}
-
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_threadstart001(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_threadstart001(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_threadstart001(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
- jvmtiError err;
- jint res;
-
- if (options != NULL && strcmp(options, "printdump") == 0) {
- printdump = JNI_TRUE;
- }
-
- res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
- if (res != JNI_OK || jvmti == NULL) {
- printf("Wrong result of a valid call to GetEnv!\n");
- return JNI_ERR;
- }
-
- callbacks.ThreadStart = &ThreadStart;
- err = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
- if (err != JVMTI_ERROR_NONE) {
- printf("(SetEventCallbacks) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- return JNI_ERR;
- }
-
- return JNI_OK;
-}
-
-JNIEXPORT void JNICALL
-Java_nsk_jvmti_ThreadStart_threadstart001_getReady(JNIEnv *env,
- jclass cls, jint i, jstring name) {
- jvmtiError err;
-
- if (jvmti == NULL) {
- printf("JVMTI client was not properly loaded!\n");
- return;
- }
-
- prefix = env->GetStringUTFChars(name, NULL);
- if (prefix == NULL) {
- printf("Failed to copy UTF-8 string!\n");
- result = STATUS_FAILED;
- return;
- }
-
- err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_THREAD_START, NULL);
- if (err == JVMTI_ERROR_NONE) {
- eventsExpected = i;
- } else {
- printf("Failed to enable JVMTI_EVENT_THREAD_START: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_ThreadStart_threadstart001_check(JNIEnv *env, jclass cls) {
- jvmtiError err;
-
- if (jvmti == NULL) {
- printf("JVMTI client was not properly loaded!\n");
- return STATUS_FAILED;
- }
-
- err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,
- JVMTI_EVENT_THREAD_START, NULL);
- if (err != JVMTI_ERROR_NONE) {
- printf("Failed to disable JVMTI_EVENT_THREAD_START: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-
- if (eventsCount != eventsExpected) {
- printf("Wrong number of thread start events: %d, expected: %d\n",
- eventsCount, eventsExpected);
- result = STATUS_FAILED;
- }
- return result;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002.java
deleted file mode 100644
index 99860e3d612..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.ThreadStart;
-
-import java.io.PrintStream;
-
-public class threadstart002 {
-
- final static int JCK_STATUS_BASE = 95;
-
- static {
- try {
- System.loadLibrary("threadstart002");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load threadstart002 library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native static int check();
-
- public static int waitTime = 2;
-
- public static void main(String args[]) {
- args = nsk.share.jvmti.JVMTITest.commonInit(args);
-
- // produce JCK-like exit status.
- System.exit(run(args, System.out) + JCK_STATUS_BASE);
- }
-
- public static int run(String args[], PrintStream out) {
- if (args.length > 0) {
- try {
- int i = Integer.parseInt(args[0]);
- waitTime = i;
- } catch (NumberFormatException ex) {
- out.println("# Wrong argument \"" + args[0]
- + "\", the default value is used");
- }
- }
- out.println("# Waiting time = " + waitTime + " mins");
-
- TestThread t = new TestThread("TestThread_1");
- t.start();
-
- try {
- t.join(waitTime * 60000);
- } catch (InterruptedException e) {
- throw new Error("Unexpected: " + e);
- }
-
- return check();
- }
-
- static class TestThread extends Thread {
-
- TestThread(String name) {
- super(name);
- }
-
- public void run() {
- }
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/TestDescription.java
deleted file mode 100644
index 53ede977dff..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/TestDescription.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/ThreadStart/threadstart002.
- * VM Testbase keywords: [quick, jpda, jvmti, onload_only_logic, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * This is a regression test for the following bug:
- * 4432884 jdbx does not work with jdk 1.3.1 starting with
- * rc1 build 19 onwards
- * The test runs a debugger agent in a separate thread that operates
- * on behalf of other threads, so when it gets a ThreadStart event,
- * the debugger agent suspends the new thread and then
- * calls jni_DeleteGlobalRef with a jnienv * for that new thread.
- * Then the test resumes the new thread and checks the thread
- * suspend status.
- * COMMENTS
- * The test reproduces the bug on Solsparc with JDK 1.3.1-b19
- * with the following output:
- * java version "1.3.1-rc1"
- * Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-rc1-b19)
- * Java HotSpot(TM) Client VM (build 1.3.1-rc1-b19, interpreted mode)
- * >>> debug agent created
- * >>> thread 0: Signal Dispatcher
- * >>> Signal Dispatcher suspended ...
- * >>> ... resumed
- * >>> agent: threadStatus=ffffffff, suspendStatus=1
- * "Signal Dispatcher" did not resume
- * FATAL ERROR in native method: could not recover
- * Exit Code: 1
- * Fixed according to 4668512 bug,
- * Ported from JVMDI.
- * Modified due to fix of the RFE
- * 5001769 TEST_RFE: remove usage of deprecated GetThreadStatus function
- * Fixed according to 6221885 test bug.
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native -agentlib:threadstart002 nsk.jvmti.ThreadStart.threadstart002 5
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/libthreadstart002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/libthreadstart002.cpp
deleted file mode 100644
index e32550ee293..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/libthreadstart002.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "threadstart002.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/threadstart002.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/threadstart002.cpp
deleted file mode 100644
index 9b48ecc67de..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart002/threadstart002.cpp
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- * 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-
-#include "nsk_tools.h"
-#include "JVMTITools.h"
-#include "jvmti_tools.h"
-#include "agent_common.h"
-#include "jni_tools.h"
-
-extern "C" {
-
-#define PASSED 0
-#define STATUS_FAILED 2
-#define WAIT_TIME 20000
-
-static jvmtiEnv *jvmti = NULL;
-static jvmtiCapabilities caps;
-static jvmtiEventCallbacks callbacks;
-/* volatile variables */
-static jrawMonitorID agent_start_lock, thr_start_lock, thr_resume_lock, thr_event_lock;
-static volatile jthread agent_thread = NULL;
-static volatile jboolean terminate_debug_agent = JNI_FALSE;
-static volatile jboolean debug_agent_timed_out = JNI_FALSE;
-static volatile jboolean debug_agent_started = JNI_FALSE;
-static volatile jthread next_thread = NULL;
-static jvmtiThreadInfo inf;
-static volatile int eventsCount = 0;
-static volatile jint result = PASSED;
-
-/*
- The agent runs special debugger agent (debug_agent) in a separate thread
- that operates on behalf of other threads.
- Upon receiving ThreadStart event, the debugger agent:
- - suspends the new thread
- - calls jni_DeleteGlobalRef with a jnienv * for that new thread
- - resumes the new thread
- Then the thread suspend status is checked in ThreadStart callback.
-
- The following monitors are used to synchronize debugger thread with other
- threads:
- 1. agent_start_lock
- used to notify VMInit callback as well as ThreadStart callback
- that agent thread has been started.
- 2. thr_event_lock
- used to guarantee that only one ThreadStart event is proceeded at
- the time.
- 3. thr_start_lock
- used to notify agent thread that new thread has been started.
- 4. thr_resume_lock
- used to notify ThreadStart callback that agent thread finished
- suspending and resuming the thread.
-
- So, the threads behaves as following:
-
-VMInit | debug_agent | ThreadStart
--------------------------------------------------------------------------
- | |
- agent_start_lock.enter | | agent_start_lock.enter
- | |
- ... create debug_agent | ... start | while (!debug_agent)
- agent_start_lock.wait | | agent_start_lock.wait
- | agent_start_lock.enter |
- | agent_start_lock.notifyAll |
- | agent_start_lock.exit |
- agent_start_lock.exit | | agent_start_lock.exit
- | |
- | | thr_event_lock.enter
- | |
- | thr_start_lock.enter | thr_start_lock.enter
- | if (!next_thread) | thr_resume_lock.enter
- | thr_start_lock.wait |
- | | ... next_thread = ...
- | | thr_start_lock.notify
- | | thr_start_lock.exit
- | |
- | ... suspend new thread | thr_resume_lock.wait
- | ... resume new thread |
- | |
- | thr_resume_lock.enter |
- | thr_resume_lock.notify |
- | thr_resume_lock.exit |
- | | ... check next_thread state
- | | thr_resume_lock.exit
- | thr_start_lock.exit |
- | thr_event_lock.exit
-
-
-*/
-
-static void JNICALL
-debug_agent(jvmtiEnv* jvmti, JNIEnv* jni, void *p) {
- JNIEnv *env = jni;
- jint thrStat;
- jobject temp;
-
- /* Notify VMInit callback as well as ThreadStart callback (if any)
- * that agent thread has been started
- */
- if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(agent_start_lock))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("[agent] failed to acquire agent_start_lock\n");
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorNotifyAll(agent_start_lock))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("[agent] failed to notify about agent_start_lock\n");
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(agent_start_lock))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("[agent] failed to release agent_start_lock\n");
- }
-
- NSK_DISPLAY0(">>> [agent] agent created\n");
-
- debug_agent_started = JNI_TRUE;
-
- if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(thr_start_lock))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("[agent] failed to enter thr_start_lock\n");
- }
-
- while (terminate_debug_agent != JNI_TRUE) {
-
- if (next_thread == NULL) {
- /* wait till new thread will be created and started */
- if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorWait(thr_start_lock, (jlong)0))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("[agent] Failed while waiting thr_start_lock\n");
- }
- }
-
- if (next_thread != NULL) {
- /* hmm, why NewGlobalRef is called one more time???
- * next_thread = env->NewGlobalRef(next_thread);
- */
- if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(next_thread))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN1("[agent] Failed to suspend thread#%d\n", eventsCount);
- }
-
- NSK_DISPLAY2(">>> [agent] thread#%d %s suspended ...\n", eventsCount, inf.name);
-
- /* these dummy calls provoke VM to hang */
- temp = env->NewGlobalRef(next_thread);
- env->DeleteGlobalRef(temp);
-
- if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(next_thread))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN1("[agent] Failed to resume thread#%d\n", eventsCount);
- }
-
- NSK_DISPLAY2(">>> [agent] thread#%d %s resumed ...\n", eventsCount, inf.name);
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(next_thread, &thrStat))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN1("[agent] Failed to get thread state for thread#%d\n", eventsCount);
- }
-
- NSK_DISPLAY3(">>> [agent] %s threadState=%s (%x)\n",
- inf.name, TranslateState(thrStat), thrStat);
-
- if (thrStat & JVMTI_THREAD_STATE_SUSPENDED) {
- NSK_COMPLAIN1("[agent] \"%s\" was not resumed\n", inf.name);
- env->FatalError("[agent] could not recover");
- }
-
- env->DeleteGlobalRef(next_thread);
- next_thread = NULL;
-
- /* Notify ThreadStart callback that thread has been resumed */
- if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(thr_resume_lock))) {
- NSK_COMPLAIN0("[agent] Failed to acquire thr_resume_lock\n");
- result = STATUS_FAILED;
- }
-
- debug_agent_timed_out = JNI_FALSE;
-
- if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorNotify(thr_resume_lock))) {
- NSK_COMPLAIN0("[agent] Failed to notifing about thr_resume_lock\n");
- result = STATUS_FAILED;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(thr_resume_lock))) {
- NSK_COMPLAIN0("[agent] Failed to release thr_resume_lock\n");
- result = STATUS_FAILED;
- }
- }
- }
-
- /*
- * We don't call RawMonitorExit(thr_start_lock) in the loop so we don't
- * lose any notify calls.
- */
- if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(thr_start_lock))) {
- NSK_COMPLAIN0("[agent] Failed to release thr_start_lock\n");
- result = STATUS_FAILED;
- }
-
- NSK_DISPLAY0(">>> [agent] done.\n");
-}
-
-void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
- jint thrStat;
- jvmtiPhase phase;
-
- NSK_DISPLAY0(">>> [ThreadStart hook] start\n");
-
- /* skip if thread is 'agent thread' */
- if (env->IsSameObject(agent_thread, thread) == JNI_TRUE) {
- NSK_DISPLAY0(">>> [ThreadStart hook] skip agent thread\n");
- NSK_DISPLAY0(">>> [ThreadStart hook] end\n");
- return;
- }
-
- /* wait till agent thread is started
- * (otherwise can fail while waiting on thr_resume_thread due to timeout)
- */
- if (debug_agent_started != JNI_TRUE) {
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(agent_start_lock))) {
- NSK_COMPLAIN0("[ThreadStart hook] Failed to acquire agent_start_lock\n");
- result = STATUS_FAILED;
- }
-
- while (debug_agent_started != JNI_TRUE) {
- NSK_DISPLAY1(">>> [ThreadStart hook] waiting %dms for agent thread to start\n", WAIT_TIME);
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorWait(agent_start_lock, (jlong)WAIT_TIME))) {
- NSK_COMPLAIN0("[ThreadStart hook] Failed to wait for agent_start_lock\n");
- result = STATUS_FAILED;
- }
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(agent_start_lock))) {
- NSK_COMPLAIN0("[ThreadStart hook] Failed to release agent_start_lock\n");
- result = STATUS_FAILED;
- }
- }
-
-
- /* Acquire event lock,
- * so only one StartThread callback could be proceeded at the time
- */
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(thr_event_lock))) {
- NSK_COMPLAIN0("[ThreadStart hook] Failed to acquire thr_event_lock\n");
- result = STATUS_FAILED;
- }
-
- {
- /* get JVMTI phase */
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetPhase(&phase))) {
- NSK_COMPLAIN0("[ThreadStart hook] Failed to get JVMTI phase\n");
- result = STATUS_FAILED;
- }
-
- /* Get thread name */
- inf.name = (char*) "UNKNOWN";
- if (phase == JVMTI_PHASE_LIVE) {
- /* GetThreadInfo may only be called during the live phase */
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadInfo(thread, &inf))) {
- NSK_COMPLAIN1("[ThreadStart hook] Failed to get thread infor for thread#%d\n", eventsCount);
- result = STATUS_FAILED;
- }
- }
-
- NSK_DISPLAY2(">>> [ThreadStart hook] thread#%d: %s\n", eventsCount, inf.name);
-
- /* Acquire thr_start_lock */
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(thr_start_lock))) {
- NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to acquire thr_start_lock\n", eventsCount);
- result = STATUS_FAILED;
- }
-
- /* Acquire thr_resume_lock before we release thr_start_lock to prevent
- * debug agent from notifying us before we are ready.
- */
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(thr_resume_lock))) {
- NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to acquire thr_resume_lock\n", eventsCount);
- result = STATUS_FAILED;
- }
-
- /* Store thread */
- next_thread = env->NewGlobalRef(thread);
- debug_agent_timed_out = JNI_TRUE;
-
- /* Notify agent thread about new started thread and let agent thread to work with it */
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorNotify(thr_start_lock))) {
- NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to notify about thr_start_lock\n", eventsCount);
- result = STATUS_FAILED;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(thr_start_lock))) {
- NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_start_lock\n", eventsCount);
- result = STATUS_FAILED;
- }
-
- /* Wait till this started thread will be resumed by agent thread */
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorWait(thr_resume_lock, (jlong)WAIT_TIME))) {
- NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed while waiting for thr_resume_lock\n", eventsCount);
- result = STATUS_FAILED;
- }
-
- if (debug_agent_timed_out == JNI_TRUE) {
- NSK_COMPLAIN1("[ThreadStart hook] \"%s\": debug agent timed out\n", inf.name);
- env->FatalError("[ThreadStart hook] could not recover");
- }
-
- /* Release thr_resume_lock lock */
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(thr_resume_lock))) {
- NSK_COMPLAIN1("[ThreadStart hook] thread#%d failed to release thr_resume_lock\n", eventsCount);
- result = STATUS_FAILED;
- }
-
- /* check that thread is not in SUSPENDED state */
- if (phase == JVMTI_PHASE_LIVE) {
- /* GetThreadState may only be called during the live phase */
- if (!NSK_JVMTI_VERIFY(jvmti_env->GetThreadState(thread, &thrStat))) {
- NSK_COMPLAIN1("[ThreadStart hook] Failed to get thread state for thread#%d\n", eventsCount);
- result = STATUS_FAILED;
- }
-
- NSK_DISPLAY2(">>> [ThreadStart hook] threadState=%s (%x)\n",
- TranslateState(thrStat), thrStat);
-
- if (thrStat & JVMTI_THREAD_STATE_SUSPENDED) {
- NSK_COMPLAIN1("[ThreadStart hook] \"%s\" was self-suspended\n", inf.name);
- env->FatalError("[ThreadStart hook] could not recover");
- }
- }
-
- eventsCount++;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(thr_event_lock))) {
- NSK_COMPLAIN0("[ThreadStart hook] Failed to release thr_event_lock\n");
- result = STATUS_FAILED;
- }
-
- NSK_DISPLAY0(">>> [ThreadStart hook] end\n");
-}
-
-void JNICALL VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) {
- jclass cls = NULL;
- jmethodID mid = NULL;
-
- NSK_DISPLAY0(">>> VMInit event: start\n");
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_THREAD_START, NULL))) {
- NSK_COMPLAIN0("TEST FAILED: failed to enable JVMTI_EVENT_THREAD_START\n");
- return;
- }
-
- /* Start agent thread */
- if (!NSK_VERIFY((cls = env->FindClass("java/lang/Thread")) != NULL)) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: Cannot start agent thread: FindClass() failed\n");
- return;
- }
-
-
- if (!NSK_VERIFY((mid = env->GetMethodID(cls, "", "()V")) != NULL)) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: Cannot start agent thread: GetMethodID() failed\n");
- return;
- }
-
-
- if (!NSK_VERIFY((agent_thread = env->NewObject(cls, mid)) != NULL)) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("Cannot start agent thread: NewObject() failed\n");
- return;
- }
-
- agent_thread = (jthread) env->NewGlobalRef(agent_thread);
- if (agent_thread == NULL) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("Cannot create global reference for agent_thread\n");
- return;
- }
-
- /*
- * Grab agent_start_lock before launching debug_agent to prevent
- * debug_agent from notifying us before we are ready.
- */
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(agent_start_lock))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: failed to enter agent_start_lock\n");
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->RunAgentThread(agent_thread, debug_agent, NULL, JVMTI_THREAD_NORM_PRIORITY))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: failed to create agent thread\n");
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorWait(agent_start_lock, (jlong)0))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: failed to wait agent_start_lock\n");
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(agent_start_lock))) {
- result = STATUS_FAILED;
- NSK_COMPLAIN0("TEST FAILED: failed to exit agent_start_lock\n");
- }
-
- NSK_DISPLAY0(">>> VMInit event: end\n");
-}
-
-void JNICALL VMDeath(jvmtiEnv *jvmti_env, JNIEnv *env) {
- NSK_DISPLAY0(">>> VMDeath event\n");
-
- // Sync to prevent WRONG_PHASE error code in the middle of events.
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorEnter(thr_event_lock))) {
- NSK_COMPLAIN0("[VMDeath hook] Failed to acquire thr_event_lock\n");
- result = STATUS_FAILED;
- }
- terminate_debug_agent = JNI_TRUE;
-
- if (!NSK_JVMTI_VERIFY(jvmti_env->RawMonitorExit(thr_event_lock))) {
- NSK_COMPLAIN0("[VMDeath hook] Failed to release thr_event_lock\n");
- result = STATUS_FAILED;
- }
-}
-
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_threadstart002(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_threadstart002(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_threadstart002(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
-
- /* init framework and parse options */
- if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
- return JNI_ERR;
-
- /* create JVMTI environment */
- if (!NSK_VERIFY((jvmti =
- nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL)) {
- NSK_COMPLAIN0("TEST FAILED: failed to create JVMTIEnv\n");
- return JNI_ERR;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetPotentialCapabilities(&caps))) {
- NSK_COMPLAIN0("TEST FAILED: failed to get potential capabilities\n");
- return JNI_ERR;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
- NSK_COMPLAIN0("TEST FAILED: failed to add capabilities during agent load\n");
- return JNI_ERR;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps))) {
- NSK_COMPLAIN0("TEST FAILED: failed to get capabilities\n");
- return JNI_ERR;
- }
-
- if (!caps.can_suspend) {
- NSK_DISPLAY0("WARNING: suspend/resume is not implemented\n");
- }
-
- /* create raw monitors */
- if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_agent_start_lock", &agent_start_lock))) {
- NSK_COMPLAIN0("TEST FAILED: failed to create agent_start_lock\n");
- return JNI_ERR;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_thr_event_lock", &thr_event_lock))) {
- NSK_COMPLAIN0("TEST FAILED: failed to create thr_event_lock\n");
- return JNI_ERR;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_thr_start_lock", &thr_start_lock))) {
- NSK_COMPLAIN0("TEST FAILED: failed to create thr_start_lock\n");
- return JNI_ERR;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("_thr_resume_lock", &thr_resume_lock))) {
- NSK_COMPLAIN0("TEST FAILED: failed to create thr_resume_lock\n");
- return JNI_ERR;
- }
-
- callbacks.VMInit = &VMInit;
- callbacks.VMDeath = &VMDeath;
- callbacks.ThreadStart = &ThreadStart;
-
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks)))) {
- NSK_COMPLAIN0("TEST FAILED: failed to set event callbacks\n");
- return JNI_ERR;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL))) {
- NSK_COMPLAIN0("TEST FAILED: failed to enable JVMTI_EVENT_VM_INIT\n");
- return JNI_ERR;
- }
-
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL))) {
- NSK_COMPLAIN0("TEST FAILED: failed to enable JVMTI_EVENT_VM_DEATH\n");
- return JNI_ERR;
- }
-
- return JNI_OK;
-}
-
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_ThreadStart_threadstart002_check(JNIEnv *env, jclass cls) {
- if (eventsCount == 0) {
- NSK_COMPLAIN0("None of thread start events!\n");
- result = STATUS_FAILED;
- }
-
- NSK_DISPLAY1(">>> total of thread start events: %d\n", eventsCount);
-
- return result;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003.java
deleted file mode 100644
index 8afb49d5f64..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.ThreadStart;
-
-import java.io.PrintStream;
-
-public class threadstart003 {
-
- final static int JCK_STATUS_BASE = 95;
- final static String ThreadName = "testedThread";
-
- static {
- try {
- System.loadLibrary("threadstart003");
- } catch (UnsatisfiedLinkError ule) {
- System.err.println("Could not load threadstart003 library");
- System.err.println("java.library.path:"
- + System.getProperty("java.library.path"));
- throw ule;
- }
- }
-
- native static int check(Thread thr, String name);
-
- public static void main(String args[]) {
- args = nsk.share.jvmti.JVMTITest.commonInit(args);
-
- // produce JCK-like exit status.
- System.exit(run(args, System.out) + JCK_STATUS_BASE);
- }
-
- public static int run(String args[], PrintStream out) {
- return check(new Thread(ThreadName), ThreadName);
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003/TestDescription.java
deleted file mode 100644
index 5f69f00932c..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003/TestDescription.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/ThreadStart/threadstart003.
- * VM Testbase keywords: [quick, jpda, jvmti, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * Regression test for bug
- * 4266590 Thread start events are sent from the wrong thread
- * Release summary: kestrel
- * Hardware version: generic
- * O/S version (unbundled products): generic
- * COMMENTS
- * The test reproduced the bug on winNT 1.3.0-E build.
- * Ported from JVMDI.
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native -agentlib:threadstart003 nsk.jvmti.ThreadStart.threadstart003
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003/libthreadstart003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003/libthreadstart003.cpp
deleted file mode 100644
index f6b5054cd4a..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003/libthreadstart003.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "threadstart003.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003/threadstart003.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003/threadstart003.cpp
deleted file mode 100644
index 8d5c42dee54..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/ThreadStart/threadstart003/threadstart003.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright (c) 2003, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-#include "jvmti.h"
-#include "agent_common.h"
-#include "JVMTITools.h"
-
-extern "C" {
-
-
-#define PASSED 0
-#define STATUS_FAILED 2
-#define WAIT_TIME 1000
-
-static jvmtiEnv *jvmti = NULL;
-static jvmtiEventCallbacks callbacks;
-static jint result = PASSED;
-static jboolean printdump = JNI_FALSE;
-static jrawMonitorID wait_lock;
-static const char *threadName = NULL;
-static int startsCount = 0;
-static int startsExpected = 0;
-static int endsCount = 0;
-static int endsExpected = 0;
-
-void JNICALL ThreadStart(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
- jvmtiError err;
- jvmtiThreadInfo inf;
-
- err = jvmti_env->GetThreadInfo(thread, &inf);
- if (err != JVMTI_ERROR_NONE) {
- printf("(GetThreadInfo, start) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
- if (printdump == JNI_TRUE) {
- printf(">>> start: %s\n", inf.name);
- }
- if (inf.name != NULL && strcmp(inf.name, threadName) == 0) {
- startsCount++;
- }
-}
-
-void JNICALL ThreadEnd(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
- jvmtiError err;
- jvmtiThreadInfo inf;
-
- err = jvmti_env->GetThreadInfo(thread, &inf);
- if (err != JVMTI_ERROR_NONE) {
- printf("(GetThreadInfo, end) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
- if (printdump == JNI_TRUE) {
- printf(">>> end: %s\n", inf.name);
- }
- if (inf.name != NULL && strcmp(inf.name, threadName) == 0) {
- endsCount++;
- }
-}
-
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_threadstart003(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_threadstart003(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_threadstart003(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
- jvmtiError err;
- jint res;
-
- if (options != NULL && strcmp(options, "printdump") == 0) {
- printdump = JNI_TRUE;
- }
-
- res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
- if (res != JNI_OK || jvmti == NULL) {
- printf("Wrong result of a valid call to GetEnv!\n");
- return JNI_ERR;
- }
-
- callbacks.ThreadStart = &ThreadStart;
- callbacks.ThreadEnd = &ThreadEnd;
- err = jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks));
- if (err != JVMTI_ERROR_NONE) {
- printf("(SetEventCallbacks) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- return JNI_ERR;
- }
-
- return JNI_OK;
-}
-
-static void JNICALL
-threadProc(jvmtiEnv* jvmti, JNIEnv* jni, void *unused) {
- jvmtiError err;
-
- err = jvmti->RawMonitorEnter(wait_lock);
- if (err != JVMTI_ERROR_NONE) {
- printf("(RawMonitorEnter) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
- err = jvmti->RawMonitorNotify(wait_lock);
- if (err != JVMTI_ERROR_NONE) {
- printf("(RawMonitorNotify) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
- err = jvmti->RawMonitorExit(wait_lock);
- if (err != JVMTI_ERROR_NONE) {
- printf("(RawMonitorExit) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-}
-
-JNIEXPORT jint JNICALL
-Java_nsk_jvmti_ThreadStart_threadstart003_check(JNIEnv *env,
- jclass cls, jthread thr, jstring name) {
- jvmtiError err;
-
- if (jvmti == NULL) {
- printf("JVMTI client was not properly loaded!\n");
- return STATUS_FAILED;
- }
-
- threadName = env->GetStringUTFChars(name, NULL);
- if (threadName == NULL) {
- printf("Failed to copy UTF-8 string!\n");
- return STATUS_FAILED;
- }
-
- err = jvmti->CreateRawMonitor("_wait_lock", &wait_lock);
- if (err != JVMTI_ERROR_NONE) {
- printf("(CreateRawMonitor) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- return STATUS_FAILED;
- }
-
- err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_THREAD_START, NULL);
- if (err == JVMTI_ERROR_NONE) {
- startsExpected = 1;
- } else {
- printf("Failed to enable JVMTI_EVENT_THREAD_START: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-
- err = jvmti->SetEventNotificationMode(JVMTI_ENABLE,
- JVMTI_EVENT_THREAD_END, NULL);
- if (err == JVMTI_ERROR_NONE) {
- endsExpected = 1;
- } else {
- printf("Failed to enable JVMTI_EVENT_THREAD_END: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-
- if (printdump == JNI_TRUE) {
- printf(">>> starting agent thread ...\n");
- }
- err = jvmti->RawMonitorEnter(wait_lock);
- if (err != JVMTI_ERROR_NONE) {
- printf("(RawMonitorEnter) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
- err = jvmti->RunAgentThread(thr, threadProc,
- NULL, JVMTI_THREAD_MAX_PRIORITY);
- if (err != JVMTI_ERROR_NONE) {
- printf("(RunAgentThread) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
- err = jvmti->RawMonitorWait(wait_lock, 0);
- if (err != JVMTI_ERROR_NONE) {
- printf("(RawMonitorWait) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
- err = jvmti->RawMonitorExit(wait_lock);
- if (err != JVMTI_ERROR_NONE) {
- printf("(RawMonitorExit) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-
- err = jvmti->RawMonitorEnter(wait_lock);
- if (err != JVMTI_ERROR_NONE) {
- printf("(RawMonitorEnter) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
- // Wait for up to 3 seconds for the thread end event
- {
- int i;
- for (i = 0; i < 3 ; i++) {
- err = jvmti->RawMonitorWait(wait_lock, (jlong)WAIT_TIME);
- if (endsCount == endsExpected || err != JVMTI_ERROR_NONE) {
- break;
- }
- }
- }
- if (err != JVMTI_ERROR_NONE) {
- printf("(RawMonitorWait) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
- err = jvmti->RawMonitorExit(wait_lock);
- if (err != JVMTI_ERROR_NONE) {
- printf("(RawMonitorExit) unexpected error: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-
- err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,
- JVMTI_EVENT_THREAD_START, NULL);
- if (err != JVMTI_ERROR_NONE) {
- printf("Failed to disable JVMTI_EVENT_THREAD_START: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-
- err = jvmti->SetEventNotificationMode(JVMTI_DISABLE,
- JVMTI_EVENT_THREAD_END, NULL);
- if (err != JVMTI_ERROR_NONE) {
- printf("Failed to disable JVMTI_EVENT_THREAD_END: %s (%d)\n",
- TranslateError(err), err);
- result = STATUS_FAILED;
- }
-
- if (startsCount != startsExpected) {
- printf("Wrong number of thread start events: %d, expected: %d\n",
- startsCount, startsExpected);
- result = STATUS_FAILED;
- }
-
- if (endsCount != endsExpected) {
- printf("Wrong number of thread end events: %d, expected: %d\n",
- endsCount, endsExpected);
- result = STATUS_FAILED;
- }
-
- return result;
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001.java
deleted file mode 100644
index b822405de0a..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2004, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package nsk.jvmti.VMObjectAlloc;
-
-import java.io.PrintStream;
-
-import nsk.share.*;
-import nsk.share.jvmti.*;
-
-public class vmobjalloc001 extends DebugeeClass {
-
- // run test from command line
- public static void main(String argv[]) {
- argv = nsk.share.jvmti.JVMTITest.commonInit(argv);
-
- // JCK-compatible exit
- System.exit(run(argv, System.out) + Consts.JCK_STATUS_BASE);
- }
-
- // run test from JCK-compatible environment
- public static int run(String argv[], PrintStream out) {
- return new vmobjalloc001().runIt(argv, out);
- }
-
- /* =================================================================== */
-
- // scaffold objects
- ArgumentHandler argHandler = null;
- Log log = null;
- int status = Consts.TEST_PASSED;
-
- // run debuggee
- public int runIt(String argv[], PrintStream out) {
- argHandler = new ArgumentHandler(argv);
- log = new Log(out, argHandler);
-
- log.display("Sync: debuggee started");
-
- return checkStatus(status);
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/TestDescription.java
deleted file mode 100644
index 7ddab6b21af..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/TestDescription.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2018, 2020, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- * @test
- *
- * @summary converted from VM Testbase nsk/jvmti/VMObjectAlloc/vmobjalloc001.
- * VM Testbase keywords: [quick, jpda, jvmti, noras]
- * VM Testbase readme:
- * DESCRIPTION
- * The test exercises JVMTI event callback function VMObjectAlloc.
- * The test enables the event and counts a number of received events.
- * There is no guarantee that VM allocates any special objects, so if
- * no JVMTI_EVENT_VM_OBJECT_ALLOC has been received then the test
- * just prints warning message and passes anyway.
- * COMMENTS
- * Fixed the 5001806 bug.
- * Modified due to fix of the bug
- * 5010571 TEST_BUG: jvmti tests with VMObjectAlloc callbacks should
- * be adjusted to new spec
- *
- * @library /vmTestbase
- * /test/lib
- * @run main/othervm/native
- * -agentlib:vmobjalloc001=-waittime=5
- * nsk.jvmti.VMObjectAlloc.vmobjalloc001
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/libvmobjalloc001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/libvmobjalloc001.cpp
deleted file mode 100644
index b1660c50b3e..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/libvmobjalloc001.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "native_thread.cpp"
-#include "nsk_tools.cpp"
-#include "jni_tools.cpp"
-#include "jvmti_tools.cpp"
-#include "agent_tools.cpp"
-#include "jvmti_FollowRefObjects.cpp"
-#include "Injector.cpp"
-#include "JVMTITools.cpp"
-#include "agent_common.cpp"
-#include "vmobjalloc001.cpp"
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/vmobjalloc001.cpp b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/vmobjalloc001.cpp
deleted file mode 100644
index 0b88c68aeef..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/VMObjectAlloc/vmobjalloc001/vmobjalloc001.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2004, 2018, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include "jvmti.h"
-#include "agent_common.h"
-#include "jni_tools.h"
-#include "jvmti_tools.h"
-
-extern "C" {
-
-/* ========================================================================== */
-
-/* scaffold objects */
-static jlong timeout = 0;
-
-/* test objects */
-static int eventsCount = 0;
-
-/* ========================================================================== */
-
-/* check if any VMObjectAlloc events received */
-static int checkVMObjectAllocEvents() {
-
- NSK_DISPLAY1("VMObjectAlloc events received: %d\n", eventsCount);
-
- if (eventsCount == 0) {
- NSK_DISPLAY0("# WARNING: no VMObjectAlloc events\n");
- NSK_DISPLAY0("# (VM might not allocate such objects at all)\n");
- }
-
- return NSK_TRUE;
-}
-
-/* ========================================================================== */
-
-JNIEXPORT void JNICALL
-VMObjectAlloc(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jobject object,
- jclass object_klass, jlong size) {
- char *signature, *generic;
-
- eventsCount++;
-
- if (!NSK_JVMTI_VERIFY(jvmti->GetClassSignature(object_klass, &signature, &generic))) {
- nsk_jvmti_setFailStatus();
- return;
- }
-
- NSK_DISPLAY2("VMObjectAlloc: \"%s\", size=%d\n", signature, size);
-
- if (signature != NULL)
- jvmti->Deallocate((unsigned char*)signature);
-
- if (generic != NULL)
- jvmti->Deallocate((unsigned char*)generic);
-
-}
-
-/* ========================================================================== */
-
-/* agent algorithm */
-static void JNICALL
-agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
-
- /* wait for debuggee start */
- if (!nsk_jvmti_waitForSync(timeout))
- return;
-
- /* testcase #1: check if any VMObjectAlloc events received*/
- NSK_DISPLAY0("Testcase #1: check if any VMObjectAlloc events received\n");
- if (!checkVMObjectAllocEvents())
- nsk_jvmti_setFailStatus();
-
- /* resume debugee after last sync */
- if (!nsk_jvmti_resumeSync())
- return;
-}
-
-/* ========================================================================== */
-
-/* agent library initialization */
-#ifdef STATIC_BUILD
-JNIEXPORT jint JNICALL Agent_OnLoad_vmobjalloc001(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNICALL Agent_OnAttach_vmobjalloc001(JavaVM *jvm, char *options, void *reserved) {
- return Agent_Initialize(jvm, options, reserved);
-}
-JNIEXPORT jint JNI_OnLoad_vmobjalloc001(JavaVM *jvm, char *options, void *reserved) {
- return JNI_VERSION_1_8;
-}
-#endif
-jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
- jvmtiEnv* jvmti = NULL;
- jvmtiCapabilities caps;
- jvmtiEventCallbacks callbacks;
-
- /* init framework and parse options */
- if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
- return JNI_ERR;
-
- timeout = nsk_jvmti_getWaitTime() * 60000;
- NSK_DISPLAY1("Timeout: %d msc\n", (int)timeout);
-
- /* create JVMTI environment */
- if (!NSK_VERIFY((jvmti =
- nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
- return JNI_ERR;
-
- memset(&caps, 0, sizeof(caps));
- caps.can_generate_vm_object_alloc_events = 1;
- if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps))) {
- return JNI_ERR;
- }
-
- memset(&callbacks, 0, sizeof(callbacks));
- callbacks.VMObjectAlloc= &VMObjectAlloc;
- if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))
- return JNI_ERR;
-
- /* enable VMObjectAlloc event */
- if (!NSK_JVMTI_VERIFY(
- jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_OBJECT_ALLOC, NULL)))
- return JNI_ERR;
-
- /* register agent proc and arg */
- if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
- return JNI_ERR;
-
- return JNI_OK;
-}
-
-/* ========================================================================== */
-
-}