Skip to content

Commit 4398cce

Browse files
committed
8333013: Update vmTestbase/nsk/share/LocalProcess.java to don't use finalization
Backport-of: bc7d9e3d0bc663bbbeb068889082da4a9f0fa8de
1 parent c2228cc commit 4398cce

File tree

2 files changed

+13
-36
lines changed

2 files changed

+13
-36
lines changed

test/hotspot/jtreg/vmTestbase/nsk/share/jdb/JdbTest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,37 +204,34 @@ protected int runTest(String argv[], PrintStream out) {
204204
}
205205
}
206206

207-
} catch (Exception e) {
208-
failure("Caught unexpected exception: " + e);
209-
e.printStackTrace(out);
210-
207+
} catch (Throwable t) {
208+
failure("Caught unexpected exception: " + t);
209+
t.printStackTrace(out);
210+
} finally {
211211
if (jdb != null) {
212+
log.complain("jdb reference is not null, check for exception in the logs.");
212213
try {
213214
jdb.close();
214215
} catch (Throwable ex) {
215216
failure("Caught exception/error while closing jdb streams:\n\t" + ex);
216217
ex.printStackTrace(log.getOutStream());
217218
}
218-
} else {
219-
log.complain("jdb reference is null, cannot run jdb.close() method");
220219
}
221220

222-
if (debuggee != null) {
221+
if (debuggee != null && !debuggee.terminated()) {
222+
log.complain("debuggee is still running, check for exception in the logs.");
223223
debuggee.killDebuggee();
224-
} else {
225-
log.complain("debuggee reference is null, cannot run debuggee.killDebuggee() method");
226224
}
227-
228225
}
229226

230227
if (!success) {
231228
log.complain("TEST FAILED");
232229
return FAILED;
233230
}
234231

235-
} catch (Exception e) {
236-
out.println("Caught unexpected exception while starting the test: " + e);
237-
e.printStackTrace(out);
232+
} catch (Throwable t) {
233+
out.println("Caught unexpected exception while starting the test: " + t);
234+
t.printStackTrace(out);
238235
out.println("TEST FAILED");
239236
return FAILED;
240237
}

test/hotspot/jtreg/vmTestbase/nsk/share/LocalProcess.java renamed to test/hotspot/jtreg/vmTestbase/nsk/share/jdb/LocalProcess.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 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
@@ -21,9 +21,7 @@
2121
* questions.
2222
*/
2323

24-
package nsk.share;
25-
26-
import nsk.share.*;
24+
package nsk.share.jdb;
2725

2826
import java.io.*;
2927

@@ -33,14 +31,9 @@
3331
* This class provides abilities to launch such process,
3432
* redirect standard output streams, wait for process terminates
3533
* or kill the process, and so on.
36-
* <p>
37-
* This object is finalized with <code>nsk.share.Finalizer</code>.
38-
*
39-
* @see nsk.share.FinalizableObject
40-
* @see nsk.share.Finalizer
4134
*/
4235

43-
public class LocalProcess extends FinalizableObject {
36+
class LocalProcess {
4437

4538
public final static int PROCESS_IS_ALIVE = 222;
4639

@@ -59,16 +52,11 @@ public void launch (String[] args) throws IOException {
5952
}
6053

6154
process = Runtime.getRuntime().exec(args);
62-
63-
registerCleanup();
6455
}
6556

6657
public void launch (String cmdLine) throws IOException {
6758
System.out.println("Launching process by command line: " + cmdLine);
68-
6959
process = Runtime.getRuntime().exec(cmdLine);
70-
71-
registerCleanup();
7260
}
7361

7462
/** Return exit status. */
@@ -163,12 +151,4 @@ protected void kill() {
163151
process.destroy();
164152
}
165153

166-
/**
167-
* This method is called at finalization and calls <code>kill()</code>.
168-
*
169-
*/
170-
@Override
171-
public void cleanup() {
172-
kill();
173-
}
174154
}

0 commit comments

Comments
 (0)