/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4164696
* @summary The local garbage collector needs to inspect a client VM's heap
* often enough (even if the VM is idle) to detect unreachable live remote
* references, so that their server VMs can be informed that the client VM
* is no longer holding a reference; this facilitates the server VM invoking
* the remote object's unreferenced() method (if present), garbage collecting
* the remote object, and allowing the server VM to exit. This test focuses
* on the unreferenced() method being invoked: it tests that the callback
* method will be invoked within a reasonable time after the remote object is
* no longer remotely reachable.
* @author Peter Jones
*
* @library ../../../testlibrary
* @build TestLibrary FiniteGCLatency_Stub
*/
private boolean unreferencedInvoked = false;
public void unreferenced() {
synchronized (lock) {
unreferencedInvoked = true;
}
}
/*
* Set the interval that RMI will request for GC latency (before RMI
* gets initialized and this property is read) to an unrealistically
* small value, so that this test shouldn't have to wait too long.
*/
try {
"waiting for unreferenced() callback...");
if (obj.unreferencedInvoked) {
} else {
throw new RuntimeException(
"TEST FAILED: unrefereced() not invoked after " +
}
}
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(
"TEST FAILED: unexpected exception: " + e.toString());
}
} finally {
/*
* When all is said and done, try to unexport the remote object
* so that the VM has a chance to exit.
*/
try {
} catch (RemoteException e) {
}
}
}
}