From c884862ad2189654596df27a76ab685dcd7399f6 Mon Sep 17 00:00:00 2001
From: Leo Korinth <lkorinth@openjdk.org>
Date: Tue, 13 Jun 2023 12:31:20 +0000
Subject: [PATCH] 8309468: Remove jvmti Allocate locker test case

Reviewed-by: dholmes, lmesnik, sspitsyn
---
 make/test/JtregNativeHotspot.gmk              |  7 --
 test/hotspot/jtreg/TEST.quick-groups          |  5 +-
 .../alloc/jvmtialloclock01/TEST.properties    | 23 -------
 .../jvmtialloclock01/TestDescription.java     | 38 -----------
 .../nsk/share/gc/lock/LockerUtils.java        |  5 +-
 .../share/gc/lock/jvmti/JVMTIAllocLocker.cpp  | 68 -------------------
 .../share/gc/lock/jvmti/JVMTIAllocLocker.java | 58 ----------------
 .../gc/lock/jvmti/JVMTIAllocLockers.java      | 33 ---------
 .../gc/lock/jvmti/libJVMTIAllocLocker.cpp     | 26 -------
 9 files changed, 3 insertions(+), 260 deletions(-)
 delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TEST.properties
 delete mode 100644 test/hotspot/jtreg/vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TestDescription.java
 delete mode 100644 test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLocker.cpp
 delete mode 100644 test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLocker.java
 delete mode 100644 test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLockers.java
 delete mode 100644 test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/libJVMTIAllocLocker.cpp

diff --git a/make/test/JtregNativeHotspot.gmk b/make/test/JtregNativeHotspot.gmk
index 5d998a4d4b1..a08210fb211 100644
--- a/make/test/JtregNativeHotspot.gmk
+++ b/make/test/JtregNativeHotspot.gmk
@@ -94,11 +94,6 @@ MLVM_STRESS_INCLUDES := \
     -I$(VM_TESTBASE_DIR)/nsk/share/native \
     -I$(VM_TESTBASE_DIR)/nsk/share/jni
 
-NSK_GC_LOCK_JVMTI_INCLUDES := \
-    -I$(VM_TESTBASE_DIR)/nsk/share/gc/lock/jvmti \
-    -I$(VM_TESTBASE_DIR)/nsk/share/native \
-    -I$(VM_TESTBASE_DIR)/nsk/share/jni
-
 NSK_GC_LOCK_JNI_INCLUDES := \
     -I$(VM_TESTBASE_DIR)/nsk/share/gc/lock/jni \
     -I$(VM_TESTBASE_DIR)/nsk/share/native \
@@ -172,8 +167,6 @@ BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libIndyRedefineClass := $(MLVM_JVMTI_INCLUD
 
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libnativeAndMH := $(MLVM_STRESS_INCLUDES)
 
-BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libJVMTIAllocLocker := $(NSK_GC_LOCK_JVMTI_INCLUDES)
-
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libBooleanArrayCriticalLocker := $(NSK_GC_LOCK_JNI_INCLUDES)
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libByteArrayCriticalLocker := $(NSK_GC_LOCK_JNI_INCLUDES)
 BUILD_HOTSPOT_JTREG_LIBRARIES_CFLAGS_libCharArrayCriticalLocker := $(NSK_GC_LOCK_JNI_INCLUDES)
diff --git a/test/hotspot/jtreg/TEST.quick-groups b/test/hotspot/jtreg/TEST.quick-groups
index 7cfb8edd8b4..fa8f22b07a8 100644
--- a/test/hotspot/jtreg/TEST.quick-groups
+++ b/test/hotspot/jtreg/TEST.quick-groups
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2018, 2023, 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
@@ -1491,8 +1491,7 @@ vmTestbase_vm_gc_quick = \
   vmTestbase/gc/gctests/StringInternGC/StringInternGC.java \
   vmTestbase/gc/gctests/ReferencesGC/ReferencesGC.java \
   vmTestbase/gc/lock/jni/jnilock001/TestDescription.java \
-  vmTestbase/gc/lock/jniref/jnireflock01/TestDescription.java \
-  vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TestDescription.java
+  vmTestbase/gc/lock/jniref/jnireflock01/TestDescription.java
 
 vmTestbase_vm_compiler_quick = \
   vmTestbase/vm/compiler/jbe/constprop/constprop01/constprop01.java \
diff --git a/test/hotspot/jtreg/vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TEST.properties b/test/hotspot/jtreg/vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TEST.properties
deleted file mode 100644
index 04b22a107ac..00000000000
--- a/test/hotspot/jtreg/vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TEST.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Copyright (c) 2017, 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.
-#
-exclusiveAccess.dirs=.
diff --git a/test/hotspot/jtreg/vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TestDescription.java b/test/hotspot/jtreg/vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TestDescription.java
deleted file mode 100644
index ec47cd8c8d0..00000000000
--- a/test/hotspot/jtreg/vmTestbase/gc/lock/jvmti/alloc/jvmtialloclock01/TestDescription.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2017, 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.
- */
-
-
-/*
- * @test
- * @key stress randomness
- *
- * @summary converted from VM Testbase gc/lock/jvmti/alloc/jvmtialloclock01.
- * VM Testbase keywords: [gc, stress, stressopt, jvmti, nonconcurrent]
- *
- * @library /vmTestbase
- *          /test/lib
- * @build jdk.test.whitebox.WhiteBox
- * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
- * @run main/othervm/native -Xbootclasspath/a:. -Xlog:gc=debug:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -agentlib:JVMTIAllocLocker gc.lock.LockerTest -lockers jvmtiAlloc -t 1
- */
-
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockerUtils.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockerUtils.java
index 77185e70b5a..28e05fba960 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockerUtils.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/LockerUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2023, 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
@@ -25,7 +25,6 @@ package nsk.share.gc.lock;
 
 import nsk.share.TestBug;
 import nsk.share.gc.lock.jni.JNILockers;
-import nsk.share.gc.lock.jvmti.JVMTIAllocLockers;
 import nsk.share.gc.lock.jniref.*;
 
 /**
@@ -51,8 +50,6 @@ public class LockerUtils {
                         return new JNIRefLockers();
                 else if (id.equals("jniWeakGlobalRef"))
                         return new JNIWeakGlobalRefLockers();
-                else if (id.equals("jvmtiAlloc"))
-                        return new JVMTIAllocLockers();
                 else
                         throw new TestBug("Invalid lockers id: " + id);
         }
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLocker.cpp
deleted file mode 100644
index af69f0660c1..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLocker.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2007, 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 <jni.h>
-#include <jvmti.h>
-#include <time.h>
-#include <stdlib.h>
-#include "jni_tools.h"
-
-extern "C" {
-
-static jvmtiEnv *jvmti = NULL;
-static jvmtiCapabilities caps;
-
-JNIEXPORT jint JNICALL
-Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
-            jint res;
-
-            res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_0);
-            if (res != JNI_OK || jvmti == NULL) {
-                    printf("Wrong result of a valid call to GetEnv!\n");
-                    return JNI_ERR;
-            }
-            return JNI_OK;
-}
-
-/*
- * Class:     nsk_share_gc_lock_jvmti_JVMTIAllocLocker
- * Method:    jVMTIAllocSection
- * Signature: (JJ)V
- */
-JNIEXPORT void JNICALL Java_nsk_share_gc_lock_jvmti_JVMTIAllocLocker_jVMTIAllocSection
-(JNIEnv *env, jobject o, jlong enterTime, jlong sleepTime) {
-        unsigned char *ptr;
-        time_t current_time, old_time;
-        jvmtiError err;
-        old_time = time(NULL);
-        enterTime /= 1000;
-        current_time = 0;
-        while (current_time - old_time < enterTime) {
-                err = jvmti->Allocate(1, &ptr);
-                mssleep((long) sleepTime);
-                err = jvmti->Deallocate(ptr);
-                mssleep((long) sleepTime);
-                current_time = time(NULL);
-        }
-}
-
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLocker.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLocker.java
deleted file mode 100644
index 5af9496941b..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLocker.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2007, 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.share.gc.lock.jvmti;
-
-import nsk.share.TestBug;
-import nsk.share.gc.lock.Locker;
-import nsk.share.gc.lock.CriticalSectionTimedLocker;
-
-/**
- * Malloc locker tries to hold malloc lock (if there is any)
- * by calling malloc() and free() in a loop.
- */
-public class JVMTIAllocLocker extends CriticalSectionTimedLocker {
-        static {
-                System.loadLibrary("JVMTIAllocLocker");
-        }
-
-        public JVMTIAllocLocker() {
-        }
-
-        public JVMTIAllocLocker(long enterTime, long sleepTime) {
-                super(enterTime, sleepTime);
-                setSleepTime(sleepTime);
-        }
-
-        /**
-         * This native method does Allocate() / Deallocate() in a loop
-         * while java field locked is set to true, sleeping
-         * for sleepTime between Allocate() and Deallocate() and after
-         * Deallocate().
-         */
-        private native void jVMTIAllocSection(long enterTime, long sleepTime);
-
-        protected void criticalSection(long enterTime, long sleepTime) {
-                jVMTIAllocSection(enterTime, sleepTime);
-        }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLockers.java b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLockers.java
deleted file mode 100644
index 386b17f859b..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/JVMTIAllocLockers.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2007, 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.share.gc.lock.jvmti;
-
-import nsk.share.gc.lock.Lockers;
-import nsk.share.gc.lock.Locker;
-
-public class JVMTIAllocLockers implements Lockers {
-        public Locker createLocker(Object obj) {
-                return new JVMTIAllocLocker();
-        }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/libJVMTIAllocLocker.cpp b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/libJVMTIAllocLocker.cpp
deleted file mode 100644
index 7ca5b368919..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/lock/jvmti/libJVMTIAllocLocker.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2017, 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 "JVMTIAllocLocker.cpp"
-#include "jni_tools.cpp"
-#include "nsk_tools.cpp"