Skip to content

8332641: Update nsk.share.jpda.Jdb to don't use finalization #1688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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