Skip to content

Commit 244f6ac

Browse files
committed
8307824: Clean up Finalizable.java and finalize terminology in vmTestbase/nsk/share
Reviewed-by: sspitsyn, cjplummer
1 parent a706e35 commit 244f6ac

File tree

10 files changed

+43
-290
lines changed

10 files changed

+43
-290
lines changed

test/hotspot/jtreg/vmTestbase/nsk/jdi/VMOutOfMemoryException/VMOutOfMemoryException001/VMOutOfMemoryException001t.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,22 +33,23 @@
3333
*/
3434
public class VMOutOfMemoryException001t extends AbstractJDIDebuggee {
3535

36+
public static int[] reserverdMemory = new int[1024 * 1024];
3637
public static void main(String args[]) {
3738
new VMOutOfMemoryException001t().doTest(args);
3839
}
3940

4041
// Just call normal doTest() function, but hide any OutOfMemoryErrors.
42+
@Override
4143
public void doTest() {
4244
boolean isOutOfMemory = false;
4345

4446
try {
4547
super.doTest();
4648
} catch (OutOfMemoryError e) {
47-
// Don't log anything. We are out of memory.
48-
// A println is likely to genereate a new OutOfMemoryError
4949
isOutOfMemory = true;
50+
reserverdMemory = null;
51+
log.display("Got expected OOME.");
5052
}
51-
5253
// Normally the super class handles the return value.
5354
// If we got here after an OutOfMemoryError, we consider the test passed.
5455
if (isOutOfMemory && callExit) {

test/hotspot/jtreg/vmTestbase/nsk/share/Finalizable.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

test/hotspot/jtreg/vmTestbase/nsk/share/FinalizableObject.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

test/hotspot/jtreg/vmTestbase/nsk/share/Finalizer.java

Lines changed: 0 additions & 133 deletions
This file was deleted.

test/hotspot/jtreg/vmTestbase/nsk/share/MainWrapper.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,11 +41,6 @@ public static void main(String[] args) throws Throwable {
4141
String[] classArgs = new String[args.length - 2];
4242
System.arraycopy(args, 2, classArgs, 0, args.length - 2);
4343

44-
// It is needed to register finalizer thread in default thread group
45-
// So FinalizerThread thread can't be in virtual threads group
46-
FinalizableObject finalizableObject = new FinalizableObject();
47-
finalizableObject.registerCleanup();
48-
4944
// Some tests use this property to understand if virtual threads are used
5045
System.setProperty("test.thread.factory", wrapperName);
5146

test/hotspot/jtreg/vmTestbase/nsk/share/aod/DummyTargetApplication.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,23 @@ protected void targetApplicationActions() {
5454
}
5555

5656
public void runTargetApplication() {
57-
pipe = SocketIOPipe.createClientIOPipe(log, argParser.getPort(), 0);
58-
log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
59-
pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
57+
try {
58+
pipe = SocketIOPipe.createClientIOPipe(log, argParser.getPort(), 0);
59+
log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
60+
pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
6061

61-
targetApplicationActions();
62+
targetApplicationActions();
6263

63-
String signal = pipe.readln();
64-
log.display("Signal received: '" + signal + "'");
64+
String signal = pipe.readln();
65+
log.display("Signal received: '" + signal + "'");
6566

66-
if ((signal == null) || !signal.equals(AODTestRunner.SIGNAL_FINISH))
67-
throw new TestBug("Unexpected signal: '" + signal + "'");
67+
if ((signal == null) || !signal.equals(AODTestRunner.SIGNAL_FINISH))
68+
throw new TestBug("Unexpected signal: '" + signal + "'");
69+
} finally {
70+
if (pipe != null) {
71+
pipe.close();
72+
}
73+
}
6874
}
6975

7076
public static void main(String[] args) {

test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
* @see nsk.share.jdi.Binder
6767
* @see nsk.share.jdwp.Binder
6868
*/
69-
public class DebugeeBinder extends Log.Logger implements Finalizable {
69+
public class DebugeeBinder extends Log.Logger {
7070

7171
private static final boolean IS_WINDOWS = System.getProperty("os.name")
7272
.toLowerCase()
@@ -118,8 +118,6 @@ public static String getVersion () {
118118
public DebugeeBinder (DebugeeArgumentHandler argumentHandler, Log log) {
119119
super(log, LOG_PREFIX);
120120
this.argumentHandler = argumentHandler;
121-
122-
registerCleanup();
123121
}
124122

125123
/**
@@ -546,14 +544,6 @@ public void close() {
546544
closePipeServerSocket();
547545
}
548546

549-
/**
550-
* Finalize binder by invoking <code>close()</code>.
551-
*
552-
*/
553-
public void cleanup() {
554-
close();
555-
}
556-
557547
/**
558548
* Separate thread for listening connection from <code>BindServer</code>.
559549
*/

test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeProcess.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,26 @@ public void sendSignal(String signal) {
196196
*/
197197
public int waitFor () {
198198
long timeout = binder.getArgumentHandler().getWaitTime() * 60 * 1000;
199-
int exitCode = 0;
199+
int exitCode;
200200
try {
201201
exitCode = waitForDebugee();
202202
} catch (InterruptedException ie) {
203203
ie.printStackTrace(log.getOutStream());
204204
throw new Failure("Caught exception while waiting for debuggee process: \n\t" + ie);
205-
}
206-
waitForRedirectors(timeout);
207-
if (process != null) {
208-
process.destroy();
205+
} finally {
206+
try {
207+
waitForRedirectors(timeout);
208+
} finally {
209+
if (process != null) {
210+
process.destroy();
211+
}
212+
if (pipe != null) {
213+
pipe.close();
214+
}
215+
if (binder != null) {
216+
binder.close();
217+
}
218+
}
209219
}
210220
return exitCode;
211221
}

0 commit comments

Comments
 (0)