Skip to content

Commit

Permalink
8307824: Clean up Finalizable.java and finalize terminology in vmTest…
Browse files Browse the repository at this point in the history
…base/nsk/share

Reviewed-by: sspitsyn, cjplummer
  • Loading branch information
lmesnik committed Jun 4, 2024
1 parent a706e35 commit 244f6ac
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 290 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -33,22 +33,23 @@
*/
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) {
Expand Down
65 changes: 0 additions & 65 deletions test/hotspot/jtreg/vmTestbase/nsk/share/Finalizable.java

This file was deleted.

40 changes: 0 additions & 40 deletions test/hotspot/jtreg/vmTestbase/nsk/share/FinalizableObject.java

This file was deleted.

133 changes: 0 additions & 133 deletions test/hotspot/jtreg/vmTestbase/nsk/share/Finalizer.java

This file was deleted.

7 changes: 1 addition & 6 deletions test/hotspot/jtreg/vmTestbase/nsk/share/MainWrapper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 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 Down Expand Up @@ -41,11 +41,6 @@ public static void main(String[] args) throws Throwable {
String[] classArgs = new String[args.length - 2];
System.arraycopy(args, 2, classArgs, 0, args.length - 2);

// It is needed to register finalizer thread in default thread group
// So FinalizerThread thread can't be in virtual threads group
FinalizableObject finalizableObject = new FinalizableObject();
finalizableObject.registerCleanup();

// Some tests use this property to understand if virtual threads are used
System.setProperty("test.thread.factory", wrapperName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,23 @@ protected void targetApplicationActions() {
}

public void runTargetApplication() {
pipe = SocketIOPipe.createClientIOPipe(log, argParser.getPort(), 0);
log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);
try {
pipe = SocketIOPipe.createClientIOPipe(log, argParser.getPort(), 0);
log.display("Sending signal '" + AODTestRunner.SIGNAL_READY_FOR_ATTACH + "'");
pipe.println(AODTestRunner.SIGNAL_READY_FOR_ATTACH);

targetApplicationActions();
targetApplicationActions();

String signal = pipe.readln();
log.display("Signal received: '" + signal + "'");
String signal = pipe.readln();
log.display("Signal received: '" + signal + "'");

if ((signal == null) || !signal.equals(AODTestRunner.SIGNAL_FINISH))
throw new TestBug("Unexpected signal: '" + signal + "'");
if ((signal == null) || !signal.equals(AODTestRunner.SIGNAL_FINISH))
throw new TestBug("Unexpected signal: '" + signal + "'");
} finally {
if (pipe != null) {
pipe.close();
}
}
}

public static void main(String[] args) {
Expand Down
12 changes: 1 addition & 11 deletions test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeBinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* @see nsk.share.jdi.Binder
* @see nsk.share.jdwp.Binder
*/
public class DebugeeBinder extends Log.Logger implements Finalizable {
public class DebugeeBinder extends Log.Logger {

private static final boolean IS_WINDOWS = System.getProperty("os.name")
.toLowerCase()
Expand Down Expand Up @@ -118,8 +118,6 @@ public static String getVersion () {
public DebugeeBinder (DebugeeArgumentHandler argumentHandler, Log log) {
super(log, LOG_PREFIX);
this.argumentHandler = argumentHandler;

registerCleanup();
}

/**
Expand Down Expand Up @@ -546,14 +544,6 @@ public void close() {
closePipeServerSocket();
}

/**
* Finalize binder by invoking <code>close()</code>.
*
*/
public void cleanup() {
close();
}

/**
* Separate thread for listening connection from <code>BindServer</code>.
*/
Expand Down
20 changes: 15 additions & 5 deletions test/hotspot/jtreg/vmTestbase/nsk/share/jpda/DebugeeProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,26 @@ public void sendSignal(String signal) {
*/
public int waitFor () {
long timeout = binder.getArgumentHandler().getWaitTime() * 60 * 1000;
int exitCode = 0;
int exitCode;
try {
exitCode = waitForDebugee();
} catch (InterruptedException ie) {
ie.printStackTrace(log.getOutStream());
throw new Failure("Caught exception while waiting for debuggee process: \n\t" + ie);
}
waitForRedirectors(timeout);
if (process != null) {
process.destroy();
} finally {
try {
waitForRedirectors(timeout);
} finally {
if (process != null) {
process.destroy();
}
if (pipe != null) {
pipe.close();
}
if (binder != null) {
binder.close();
}
}
}
return exitCode;
}
Expand Down
Loading

0 comments on commit 244f6ac

Please sign in to comment.