*/
System.setProperty("sun.rmi.dgc.client.gcInterval",
String.valueOf(GC_INTERVAL));
MarshalledObjectGet obj = new MarshalledObjectGet();
Exporter exporter = null;
try {
exporter = new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
new BasicILFactory(), true, true);
Remote stub = exporter.export(obj);
System.err.println("exported remote object");
MarshalledObject mobj = new MarshalledObject(stub);
Remote unmarshalledStub = (Remote) mobj.get();
System.err.println("unmarshalled stub from marshalled object");
synchronized (obj.lock) {
obj.unreferencedInvoked = false;
unmarshalledStub = null;
System.gc();
System.err.println("cleared unmarshalled stub");
System.err.println("waiting for unreferenced() callback " +
"(SHOULD happen)...");
obj.lock.wait(TIMEOUT);
if (obj.unreferencedInvoked) {
// TEST PASSED
} else {
throw new RuntimeException(
"TEST FAILED: unrefereced() not invoked after " +
((double) TIMEOUT / 1000.0) + " seconds");
}
}
System.err.println("TEST PASSED");
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw new RuntimeException(
"TEST FAILED: unexpected exception: " + e.toString());
}
} finally {
if (exporter != null) {
exporter.unexport(true);
}
}
}