Skip to content

Commit

Permalink
8332641: Update nsk.share.jpda.Jdb to don't use finalization
Browse files Browse the repository at this point in the history
Reviewed-by: cjplummer, kevinw
  • Loading branch information
lmesnik committed May 24, 2024
1 parent cd3e4c0 commit f66a586
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
15 changes: 5 additions & 10 deletions test/hotspot/jtreg/vmTestbase/nsk/share/jdb/Jdb.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
Expand All @@ -24,7 +24,6 @@
package nsk.share.jdb;

import nsk.share.*;
import nsk.share.jpda.*;

import java.util.*;
import java.io.*;
Expand All @@ -36,7 +35,7 @@
* This class provides abilities to launch it, to send command,
* to read reply on the command, to set breakpoint on entry in debugggee's method.
*/
public class Jdb extends LocalProcess implements Finalizable {
public class Jdb extends LocalProcess {
/** File to log <i>stdout</i> stream */
static final String JDB_STDOUT_FILE = "jdb.stdout";
/** File to log <i>stderr</i> stream */
Expand Down Expand Up @@ -95,11 +94,8 @@ public static Launcher getLauncher() {
return launcher;
}

public void finalizeAtExit() throws Throwable {
finalize();
}

public void finalize() throws Throwable {
public void close() {
if (fout != null) {
// fout.flush();
fout.close();
Expand All @@ -116,7 +112,6 @@ public void finalize() throws Throwable {
if (jdbStderrReader != null) {
jdbStderrReader.close();
}
super.finalize();
}

/** Create <i>Jdb</i> object. */
Expand Down Expand Up @@ -961,10 +956,10 @@ public static Jdb startAttachingJdb (Launcher launcher, String[] jdbCmdArgs, Str

System.out.println("Unsuccessful launch of attaching jdb. Next try...");
try {
jdb.finalize();
jdb.close();
} catch (Throwable t) {
t.printStackTrace(getLauncher().getLog().getOutStream());
throw new Failure("Caught unexpected error while finalizing jdb: " + t);
throw new Failure("Caught unexpected error while closing jdb streams: " + t);
}
break;

Expand Down
20 changes: 13 additions & 7 deletions test/hotspot/jtreg/vmTestbase/nsk/share/jdb/JdbTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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
Expand All @@ -24,10 +24,8 @@
package nsk.share.jdb;

import nsk.share.*;
import nsk.share.jpda.*;

import java.io.*;
import java.util.*;

public abstract class JdbTest {
public static final int PASSED = 0; // Exit code for passed test
Expand Down Expand Up @@ -174,6 +172,14 @@ protected int runTest(String argv[], PrintStream out) {
} else {
failure("jdb abnormally exited with code: " + code);
}

try {
jdb.close();
} catch (Throwable ex) {
failure("Caught exception/error while closing jdb streams:\n\t" + ex);
ex.printStackTrace(log.getOutStream());
}

jdb = null;

if (debuggee != null
Expand Down Expand Up @@ -204,19 +210,19 @@ protected int runTest(String argv[], PrintStream out) {

if (jdb != null) {
try {
jdb.finalize();
jdb.close();
} catch (Throwable ex) {
failure("Caught exception/error while finalization of jdb:\n\t" + ex);
failure("Caught exception/error while closing jdb streams:\n\t" + ex);
ex.printStackTrace(log.getOutStream());
}
} else {
log.complain("jdb reference is null, cannot run jdb.finalize() method");
log.complain("jdb reference is null, cannot run jdb.close() method");
}

if (debuggee != null) {
debuggee.killDebuggee();
} else {
log.complain("debuggee reference is null, cannot run debuggee.finalize() method");
log.complain("debuggee reference is null, cannot run debuggee.killDebuggee() method");
}

}
Expand Down

1 comment on commit f66a586

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.