diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001t.java
index 6b41e8f790e..5f402a5540c 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001t.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001t.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2024, 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
@@ -33,22 +33,23 @@ import nsk.share.jdi.AbstractJDIDebuggee;
*/
public class VMOutOfMemoryException001t extends AbstractJDIDebuggee {
+ public static int[] reserverdMemory = new int[1024 * 1024];
public static void main(String args[]) {
new VMOutOfMemoryException001t().doTest(args);
}
// Just call normal doTest() function, but hide any OutOfMemoryErrors.
+ @Override
public void doTest() {
boolean isOutOfMemory = false;
try {
super.doTest();
} catch (OutOfMemoryError e) {
- // Don't log anything. We are out of memory.
- // A println is likely to genereate a new OutOfMemoryError
isOutOfMemory = true;
+ reserverdMemory = null;
+ log.display("Got expected OOME.");
}
-
// Normally the super class handles the return value.
// If we got here after an OutOfMemoryError, we consider the test passed.
if (isOutOfMemory && callExit) {
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/Finalizable.java b/test/hotspot/jtreg/vmTestbase/nsk/share/Finalizable.java
deleted file mode 100644
index b515721e925..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/Finalizable.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2001, 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
- * 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;
-import java.lang.ref.Cleaner;
-
-/**
- * Finalizable interface allows Finalizer to perform finalization of an object.
- * Each object that requires finalization at VM shutdown time should implement this
- * interface and call the registerCleanup to activate a Finalizer hook.
- *
- * @see Finalizer
- */
-public interface Finalizable {
-
- /**
- * This method will be implemented by FinalizableObject and is called in finalizeAtExit.
- *
- * @see Finalizer
- */
- public void cleanup();
-
- /**
- * This method will be invoked by Finalizer when virtual machine
- * shuts down.
- *
- * @throws Throwable if any throwable exception thrown during finalization
- */
- default public void finalizeAtExit() throws Throwable {
- cleanup();
- }
-
- /**
- * This method will register a cleanup method and create an instance of Finalizer
- * to register the object for finalization at VM exit.
- *
- * @see Finalizer
- */
- default public void registerCleanup() {
- Finalizer finalizer = new Finalizer(this);
- finalizer.activate();
-
- Cleaner.create().register(this, () -> cleanup());
- }
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/FinalizableObject.java b/test/hotspot/jtreg/vmTestbase/nsk/share/FinalizableObject.java
deleted file mode 100644
index 7ffee4a43fe..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/FinalizableObject.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2001, 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
- * 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;
-
-
-/**
- * This class is a simple example of finalizable object, that
- * implements interface Finalizable.
- *
- * @see Finalizable
- * @see Finalizer
- */
-public class FinalizableObject implements Finalizable {
- /**
- * Subclasses should override this method to provide the specific
- * cleanup actions that they need.
- */
- public void cleanup() {}
-}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/Finalizer.java b/test/hotspot/jtreg/vmTestbase/nsk/share/Finalizer.java
deleted file mode 100644
index 1d274c54b2a..00000000000
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/Finalizer.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2001, 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;
-
-import java.util.Stack;
-
-/**
- * Finalizer performs object finalization when virtual mashine shuts down.
- * Finalizer is a thread that acts as a VM shutdown hook.
- * This thread will be activated as VM shuts down because of
- * invocation of exit() or termination. After activation
- * Finalizer just calls finalizeAtExit() method of the specified object.
- * The finalizable object should implement interface Finalizable.
- *
- * @see Finalizable
- */
-public class Finalizer {
-
- /** Finalizer thread to register as a VM shutdown hook. */
- private static FinalizerThread finalizerThread = null;
-
- /** An object to finalize. */
- private Finalizable object;
-
- /**
- * Create finalizer for the specified object.
- */
- public Finalizer(Finalizable object) {
- this.object = object;
- }
-
- /**
- * Register finalizer for finalization at VM shutdown.
- */
- public void activate() {
- if (finalizerThread == null) {
- finalizerThread = new FinalizerThread("FinalizerThread for Finalizable objects");
- finalizerThread.activate();
- }
- finalizerThread.add(object);
- }
-
- /**
- * Unregister finalizer for finalization at VM shutdown.
- */
- public void deactivate() {
- if (finalizerThread == null)
- return;
- finalizerThread.remove(object);
- }
-
- /**
- * Static inner thread that is registered as a VM shutdown hook
- * and performs finalization of all registered finalizable objects.
- */
- private static class FinalizerThread extends Thread {
-
- /** Stack of objects registered for finalization. */
- private Stack