提交 839b102b 编写于 作者: O ohair

6627823: Missed whitespace normalization files: jdk/test/java/rmi

Summary: Just missed a few files being normalized in rev 0.
Reviewed-by: xdono
上级 b11e49b0
/*
/*
* Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -49,116 +49,116 @@ import java.util.Properties;
public class CreatePrivateActivatable
{
private static class PrivateActivatable extends Activatable
implements ActivateMe, Runnable
implements ActivateMe, Runnable
{
private PrivateActivatable(ActivationID id, MarshalledObject obj)
throws ActivationException, RemoteException
{
super(id, 0);
}
public void ping()
{}
/**
* Spawns a thread to deactivate the object.
*/
public void shutdown() throws Exception
{
(new Thread(this, "CreatePrivateActivatable$PrivateActivatable")).start();
}
/**
* Thread to deactivate object. First attempts to make object
* inactive (via the inactive method). If that fails (the
* object may still have pending/executing calls), then
* unexport the object forcibly.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
}
private PrivateActivatable(ActivationID id, MarshalledObject obj)
throws ActivationException, RemoteException
{
super(id, 0);
}
public void ping()
{}
/**
* Spawns a thread to deactivate the object.
*/
public void shutdown() throws Exception
{
(new Thread(this, "CreatePrivateActivatable$PrivateActivatable")).start();
}
/**
* Thread to deactivate object. First attempts to make object
* inactive (via the inactive method). If that fails (the
* object may still have pending/executing calls), then
* unexport the object forcibly.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
}
}
public static void main(String[] args) {
/*
* The following line is required with the JDK 1.2 VM so that the
* VM can exit gracefully when this test completes. Otherwise, the
* conservative garbage collector will find a handle to the server
* object on the native stack and not clear the weak reference to
* it in the RMI runtime's object table.
*/
Object dummy = new Object();
RMID rmid = null;
ActivateMe obj;
System.err.println("\nRegression test for bug 4164971\n");
System.err.println("java.security.policy = " +
System.getProperty("java.security.policy", "no policy"));
CreatePrivateActivatable server;
try {
TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager);
// start an rmid.
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
/*
* Activate an object by registering its object
* descriptor and invoking a method on the
* stub returned from the register call.
*/
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(groupDesc);
System.err.println("Creating descriptor");
ActivationDesc desc =
new ActivationDesc(groupID,
"CreatePrivateActivatable$PrivateActivatable",
null, null);
System.err.println("Registering descriptor");
obj = (ActivateMe) Activatable.register(desc);
/*
* Loop a bunch of times to force activator to
* spawn VMs (groups)
*/
System.err.println("Activate object via method call");
obj.ping();
/*
* Clean up object too.
*/
System.err.println("Deactivate object via method call");
obj.shutdown();
System.err.println("\nsuccess: CreatePrivateActivatable test passed ");
} catch (Exception e) {
if (e instanceof java.security.PrivilegedActionException) {
e = ((java.security.PrivilegedActionException)e).getException();
}
TestLibrary.bomb("\nfailure: unexpected exception " +
e.getClass().getName(), e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
obj = null;
}
/*
* The following line is required with the JDK 1.2 VM so that the
* VM can exit gracefully when this test completes. Otherwise, the
* conservative garbage collector will find a handle to the server
* object on the native stack and not clear the weak reference to
* it in the RMI runtime's object table.
*/
Object dummy = new Object();
RMID rmid = null;
ActivateMe obj;
System.err.println("\nRegression test for bug 4164971\n");
System.err.println("java.security.policy = " +
System.getProperty("java.security.policy", "no policy"));
CreatePrivateActivatable server;
try {
TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager);
// start an rmid.
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
/*
* Activate an object by registering its object
* descriptor and invoking a method on the
* stub returned from the register call.
*/
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(groupDesc);
System.err.println("Creating descriptor");
ActivationDesc desc =
new ActivationDesc(groupID,
"CreatePrivateActivatable$PrivateActivatable",
null, null);
System.err.println("Registering descriptor");
obj = (ActivateMe) Activatable.register(desc);
/*
* Loop a bunch of times to force activator to
* spawn VMs (groups)
*/
System.err.println("Activate object via method call");
obj.ping();
/*
* Clean up object too.
*/
System.err.println("Deactivate object via method call");
obj.shutdown();
System.err.println("\nsuccess: CreatePrivateActivatable test passed ");
} catch (Exception e) {
if (e instanceof java.security.PrivilegedActionException) {
e = ((java.security.PrivilegedActionException)e).getException();
}
TestLibrary.bomb("\nfailure: unexpected exception " +
e.getClass().getName(), e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
obj = null;
}
}
}
/*
/*
* Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -24,10 +24,10 @@
/* @test
* @bug 4097135
* @summary Need a specific subtype of RemoteException for activation failure.
* If activation fails to happen during a call to a remote object,
* then the call should end in an ActivateFailedException. In this
* test, the actual "activatable" remote object fails to activate
* since its * "activation" constructor throws an exception.
* If activation fails to happen during a call to a remote object,
* then the call should end in an ActivateFailedException. In this
* test, the actual "activatable" remote object fails to activate
* since its * "activation" constructor throws an exception.
* @author Ann Wollrath
*
* @library ../../../testlibrary
......@@ -46,128 +46,127 @@ import java.io.*;
import java.util.Properties;
public class ActivateFails
extends Activatable
implements ActivateMe
extends Activatable
implements ActivateMe
{
public ActivateFails(ActivationID id, MarshalledObject obj)
throws ActivationException, RemoteException
throws ActivationException, RemoteException
{
super(id, 0);
boolean refuseToActivate = false;
try {
refuseToActivate = ((Boolean)obj.get()).booleanValue();
} catch (Exception impossible) {
}
if (refuseToActivate)
throw new RemoteException("object refuses to activate");
super(id, 0);
boolean refuseToActivate = false;
try {
refuseToActivate = ((Boolean)obj.get()).booleanValue();
} catch (Exception impossible) {
}
if (refuseToActivate)
throw new RemoteException("object refuses to activate");
}
public void ping()
{}
/**
* Spawns a thread to deactivate the object.
*/
public ShutdownThread shutdown() throws Exception
{
ShutdownThread shutdownThread = new ShutdownThread(this, getID());
shutdownThread.start();
return(shutdownThread);
ShutdownThread shutdownThread = new ShutdownThread(this, getID());
shutdownThread.start();
return(shutdownThread);
}
public static void main(String[] args)
public static void main(String[] args)
{
RMID rmid = null;
ActivateMe obj1, obj2;
ShutdownThread shutdownThread;
System.err.println("\nRegression test for bug 4097135\n");
try {
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
/*
* First run "rmid" and wait for it to start up.
*/
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
/*
* Create activation descriptor...
*/
System.err.println("creating activation descriptor...");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
ActivationDesc desc1 =
new ActivationDesc(groupID, "ActivateFails",
null,
new MarshalledObject(new Boolean(true)));
ActivationDesc desc2 =
new ActivationDesc(groupID, "ActivateFails",
null,
new MarshalledObject(new Boolean(false)));
/*
* Register activation descriptor and make a call on
* the stub. Activation should fail with an
* ActivateFailedException. If not, report an
* error as a RuntimeException
*/
System.err.println("registering activation descriptor...");
obj1 = (ActivateMe)Activatable.register(desc1);
obj2 = (ActivateMe)Activatable.register(desc2);
System.err.println("invoking method on activatable object...");
try {
obj1.ping();
} catch (ActivateFailedException e) {
/*
* This is what is expected so exit with status 0
*/
System.err.println("\nsuccess: ActivateFailedException " +
"generated");
e.getMessage();
}
obj2.ping();
shutdownThread = obj2.shutdown();
// wait for shutdown to work
Thread.sleep(2000);
shutdownThread = null;
} catch (Exception e) {
/*
* Test failed; unexpected exception generated.
*/
TestLibrary.bomb("\nfailure: unexpected exception " +
e.getClass().getName() + ": " + e.getMessage(), e);
} finally {
obj1 = obj2 = null;
ActivationLibrary.rmidCleanup(rmid);
}
RMID rmid = null;
ActivateMe obj1, obj2;
ShutdownThread shutdownThread;
System.err.println("\nRegression test for bug 4097135\n");
try {
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
/*
* First run "rmid" and wait for it to start up.
*/
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
/*
* Create activation descriptor...
*/
System.err.println("creating activation descriptor...");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
ActivationDesc desc1 =
new ActivationDesc(groupID, "ActivateFails",
null,
new MarshalledObject(new Boolean(true)));
ActivationDesc desc2 =
new ActivationDesc(groupID, "ActivateFails",
null,
new MarshalledObject(new Boolean(false)));
/*
* Register activation descriptor and make a call on
* the stub. Activation should fail with an
* ActivateFailedException. If not, report an
* error as a RuntimeException
*/
System.err.println("registering activation descriptor...");
obj1 = (ActivateMe)Activatable.register(desc1);
obj2 = (ActivateMe)Activatable.register(desc2);
System.err.println("invoking method on activatable object...");
try {
obj1.ping();
} catch (ActivateFailedException e) {
/*
* This is what is expected so exit with status 0
*/
System.err.println("\nsuccess: ActivateFailedException " +
"generated");
e.getMessage();
}
obj2.ping();
shutdownThread = obj2.shutdown();
// wait for shutdown to work
Thread.sleep(2000);
shutdownThread = null;
} catch (Exception e) {
/*
* Test failed; unexpected exception generated.
*/
TestLibrary.bomb("\nfailure: unexpected exception " +
e.getClass().getName() + ": " + e.getMessage(), e);
} finally {
obj1 = obj2 = null;
ActivationLibrary.rmidCleanup(rmid);
}
}
}
/*
/*
* Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -29,88 +29,88 @@ public final class ActivateFails_Stub
implements ActivateMe, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("void ping()"),
new java.rmi.server.Operation("ShutdownThread shutdown()")
new java.rmi.server.Operation("void ping()"),
new java.rmi.server.Operation("ShutdownThread shutdown()")
};
private static final long interfaceHash = -6632667923281093978L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_ping_0;
private static java.lang.reflect.Method $method_shutdown_1;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_ping_0 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_1 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_ping_0 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_1 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public ActivateFails_Stub() {
super();
super();
}
public ActivateFails_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of ping()
public void ping()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
ref.invoke(this, $method_ping_0, null, 5866401369815527589L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
ref.invoke(this, $method_ping_0, null, 5866401369815527589L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public ShutdownThread shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_shutdown_1, null, -3616843253114182719L);
return ((ShutdownThread) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ShutdownThread $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (ShutdownThread) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_shutdown_1, null, -3616843253114182719L);
return ((ShutdownThread) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ShutdownThread $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (ShutdownThread) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
}
}
/*
/*
* Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -31,21 +31,20 @@ public class ShutdownThread extends Thread implements Serializable {
ActivationID activationID = null;
public ShutdownThread(Remote remoteObject, ActivationID activationID) {
remoteObject = remoteObject;
activationID = activationID;
remoteObject = remoteObject;
activationID = activationID;
}
public void run() {
try {
try {
Activatable.unexportObject(remoteObject, true);
Activatable.inactive(activationID);
Activatable.unexportObject(remoteObject, true);
Activatable.inactive(activationID);
} catch (Exception e) {
}
} catch (Exception e) {
}
}
}
/*
/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -23,7 +23,7 @@
/*
* @test
* @bug 4510355
* @bug 4510355
* @summary ActivationGroup implementations cannot be downloaded by default;
* Creates a custom activation group without setting a security manager
* in activation group's descriptor. The custom activation group
......@@ -49,28 +49,28 @@ import java.util.Vector;
import java.util.Properties;
public class DownloadActivationGroup
implements Ping, Runnable
implements Ping, Runnable
{
private ActivationID id;
public DownloadActivationGroup(ActivationID id, MarshalledObject mobj)
throws ActivationException, RemoteException
throws ActivationException, RemoteException
{
this.id = id;
Activatable.exportObject(this, id, 0);
System.err.println("object activated in group");
this.id = id;
Activatable.exportObject(this, id, 0);
System.err.println("object activated in group");
}
public DownloadActivationGroup() throws RemoteException {
UnicastRemoteObject.exportObject(this, 0);
UnicastRemoteObject.exportObject(this, 0);
}
/**
* Used to activate object.
*/
public void ping() {
System.err.println("received ping");
System.err.println("received ping");
}
/**
......@@ -79,87 +79,87 @@ public class DownloadActivationGroup
*/
public void shutdown() throws Exception
{
(new Thread(this,"DownloadActivationGroup")).start();
(new Thread(this,"DownloadActivationGroup")).start();
}
/**
* Thread to deactivate object.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
ActivationLibrary.deactivate(this, getID());
}
public ActivationID getID() {
return id;
return id;
}
public static void main(String[] args) {
RMID rmid = null;
System.out.println("\nRegression test for bug 4510355\n");
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
/*
* Install group class file in codebase.
*/
System.err.println("install class file in codebase");
URL groupURL = TestLibrary.installClassInCodebase(
"MyActivationGroupImpl", "group");
System.err.println("class file installed");
/*
* Start rmid.
*/
RMID.removeLog();
rmid = RMID.createRMID();
String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
rmid.addOptions(new String[] { execPolicyOption });
rmid.start();
/*
* Create and register descriptors for custom group and an
* activatable object in that group.
*/
System.err.println("register group");
Properties p = new Properties();
p.put("java.security.policy", TestParams.defaultGroupPolicy);
ActivationGroupDesc groupDesc =
new ActivationGroupDesc("MyActivationGroupImpl",
groupURL.toExternalForm(),
null, p, null);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
System.err.println("register activatable object");
ActivationDesc desc =
new ActivationDesc(groupID, "DownloadActivationGroup",
null, null);
Ping obj = (Ping) Activatable.register(desc);
/*
* Start group (by calling ping).
*/
System.err.println(
"ping object (forces download of group's class)");
obj.ping();
System.err.println(
"TEST PASSED: group's class downloaded successfully");
System.err.println("shutdown object");
obj.shutdown();
System.err.println("TEST PASSED");
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
}
RMID rmid = null;
System.out.println("\nRegression test for bug 4510355\n");
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
/*
* Install group class file in codebase.
*/
System.err.println("install class file in codebase");
URL groupURL = TestLibrary.installClassInCodebase(
"MyActivationGroupImpl", "group");
System.err.println("class file installed");
/*
* Start rmid.
*/
RMID.removeLog();
rmid = RMID.createRMID();
String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
rmid.addOptions(new String[] { execPolicyOption });
rmid.start();
/*
* Create and register descriptors for custom group and an
* activatable object in that group.
*/
System.err.println("register group");
Properties p = new Properties();
p.put("java.security.policy", TestParams.defaultGroupPolicy);
ActivationGroupDesc groupDesc =
new ActivationGroupDesc("MyActivationGroupImpl",
groupURL.toExternalForm(),
null, p, null);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
System.err.println("register activatable object");
ActivationDesc desc =
new ActivationDesc(groupID, "DownloadActivationGroup",
null, null);
Ping obj = (Ping) Activatable.register(desc);
/*
* Start group (by calling ping).
*/
System.err.println(
"ping object (forces download of group's class)");
obj.ping();
System.err.println(
"TEST PASSED: group's class downloaded successfully");
System.err.println("shutdown object");
obj.shutdown();
System.err.println("TEST PASSED");
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
}
}
}
......
/*
/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -29,46 +29,46 @@ public final class DownloadActivationGroup_Stub
implements Ping
{
private static final long serialVersionUID = 2;
private static java.lang.reflect.Method $method_ping_0;
private static java.lang.reflect.Method $method_shutdown_1;
static {
try {
$method_ping_0 = Ping.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_1 = Ping.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
try {
$method_ping_0 = Ping.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_1 = Ping.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
}
// constructors
public DownloadActivationGroup_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of ping()
public void ping()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
ref.invoke(this, $method_ping_0, null, 5866401369815527589L);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
ref.invoke(this, $method_ping_0, null, 5866401369815527589L);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public void shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
ref.invoke(this, $method_shutdown_1, null, -7207851917985848402L);
ref.invoke(this, $method_shutdown_1, null, -7207851917985848402L);
}
}
/*
/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -27,11 +27,11 @@ import java.rmi.activation.*;
public class MyActivationGroupImpl extends ActivationGroupImpl {
public MyActivationGroupImpl(ActivationGroupID id, MarshalledObject mobj)
throws RemoteException, ActivationException
throws RemoteException, ActivationException
{
super(id, mobj);
System.err.println("custom group implementation created");
super(id, mobj);
System.err.println("custom group implementation created");
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -42,19 +42,19 @@ import java.rmi.activation.*;
*/
public class CheckDefaultGroupName {
public static void main(String[] args) {
System.out.println("\n\nRegression test for, 4252236\n\n");
System.out.println("\n\nRegression test for, 4252236\n\n");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(null, null);
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(null, null);
String className = groupDesc.getClassName();
if (className != null) {
TestLibrary.bomb("ActivationGroupDesc had incorrect default" +
" group implementation class name: " + className);
} else {
System.err.println("test passed, had correct default group" +
" implementation class name: " + className +
"\n\n");
}
String className = groupDesc.getClassName();
if (className != null) {
TestLibrary.bomb("ActivationGroupDesc had incorrect default" +
" group implementation class name: " + className);
} else {
System.err.println("test passed, had correct default group" +
" implementation class name: " + className +
"\n\n");
}
}
}
/*
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -49,81 +49,81 @@ import java.rmi.activation.ActivationSystem;
import java.rmi.server.UnicastRemoteObject;
public class IdempotentActiveGroup {
public static void main(String[] args) {
System.err.println("\nRegression test for bug 4720528\n");
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
RMID rmid = null;
ActivationInstantiator inst1 = null;
ActivationInstantiator inst2 = null;
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
System.err.println("\nRegression test for bug 4720528\n");
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
RMID rmid = null;
ActivationInstantiator inst1 = null;
ActivationInstantiator inst2 = null;
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
System.err.println("Create group descriptor");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(null, null);
ActivationSystem system = ActivationGroup.getSystem();
System.err.println("Register group descriptor");
ActivationGroupID groupID = system.registerGroup(groupDesc);
inst1 = new FakeInstantiator();
inst2 = new FakeInstantiator();
System.err.println("Invoke activeGroup with inst1");
system.activeGroup(groupID, inst1, 0);
System.err.println("Create group descriptor");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(null, null);
ActivationSystem system = ActivationGroup.getSystem();
System.err.println("Register group descriptor");
ActivationGroupID groupID = system.registerGroup(groupDesc);
inst1 = new FakeInstantiator();
inst2 = new FakeInstantiator();
System.err.println("Invoke activeGroup with inst1");
system.activeGroup(groupID, inst1, 0);
try {
System.err.println("Invoke activeGroup with inst2");
system.activeGroup(groupID, inst2, 0);
throw new RuntimeException(
"TEST FAILED: activeGroup with unequal groups succeeded!");
} catch (ActivationException expected) {
System.err.println("Caught expected ActivationException");
System.err.println("Test 1 (of 2) passed");
}
try {
System.err.println("Invoke activeGroup with inst2");
system.activeGroup(groupID, inst2, 0);
throw new RuntimeException(
"TEST FAILED: activeGroup with unequal groups succeeded!");
} catch (ActivationException expected) {
System.err.println("Caught expected ActivationException");
System.err.println("Test 1 (of 2) passed");
}
try {
System.err.println("Invoke activeGroup with inst1");
system.activeGroup(groupID, inst1, 0);
System.err.println("activeGroup call succeeded");
System.err.println("Test 2 (of 2) passed");
} catch (ActivationException unexpected) {
throw new RuntimeException(
"TEST FAILED: activeGroup with equal groups failed!",
unexpected);
}
try {
System.err.println("Invoke activeGroup with inst1");
system.activeGroup(groupID, inst1, 0);
System.err.println("activeGroup call succeeded");
System.err.println("Test 2 (of 2) passed");
} catch (ActivationException unexpected) {
throw new RuntimeException(
"TEST FAILED: activeGroup with equal groups failed!",
unexpected);
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
try {
if (inst1 != null) {
UnicastRemoteObject.unexportObject(inst1, true);
}
if (inst2 != null) {
UnicastRemoteObject.unexportObject(inst2, true);
}
} catch (NoSuchObjectException unexpected) {
throw new AssertionError(unexpected);
}
ActivationLibrary.rmidCleanup(rmid);
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
try {
if (inst1 != null) {
UnicastRemoteObject.unexportObject(inst1, true);
}
if (inst2 != null) {
UnicastRemoteObject.unexportObject(inst2, true);
}
} catch (NoSuchObjectException unexpected) {
throw new AssertionError(unexpected);
}
ActivationLibrary.rmidCleanup(rmid);
}
}
private static class FakeInstantiator
extends UnicastRemoteObject
implements ActivationInstantiator
extends UnicastRemoteObject
implements ActivationInstantiator
{
FakeInstantiator() throws RemoteException {}
FakeInstantiator() throws RemoteException {}
public MarshalledObject newInstance(ActivationID id,
ActivationDesc desc)
{
throw new AssertionError();
}
public MarshalledObject newInstance(ActivationID id,
ActivationDesc desc)
{
throw new AssertionError();
}
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......
/*
/*
* Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -25,7 +25,7 @@
* @bug 4127754
*
* @summary synopsis: need to modify registered ActivationDesc and
* ActivationGroupDesc
* ActivationGroupDesc
* @author Ann Wollrath
*
* @library ../../../testlibrary
......@@ -43,7 +43,7 @@ import java.rmi.registry.*;
import java.util.*;
public class ModifyDescriptor
implements ActivateMe, Runnable
implements ActivateMe, Runnable
{
private ActivationID id;
......@@ -54,28 +54,28 @@ public class ModifyDescriptor
public ModifyDescriptor(ActivationID id, MarshalledObject mobj)
throws ActivationException, RemoteException
throws ActivationException, RemoteException
{
this.id = id;
Activatable.exportObject(this, id, 0);
try {
message = (String) mobj.get();
} catch (Exception e) {
System.err.println("unable to get message from marshalled object");
}
this.id = id;
Activatable.exportObject(this, id, 0);
try {
message = (String) mobj.get();
} catch (Exception e) {
System.err.println("unable to get message from marshalled object");
}
}
public String getMessage() {
return message;
return message;
}
public String getProperty(String name) {
return TestLibrary.getProperty(name, null);
return TestLibrary.getProperty(name, null);
}
public ActivationID getID() {
return id;
return id;
}
/**
......@@ -83,7 +83,7 @@ public class ModifyDescriptor
*/
public void shutdown() throws Exception
{
(new Thread(this,"ModifyDescriptor")).start();
(new Thread(this,"ModifyDescriptor")).start();
}
/**
......@@ -93,165 +93,165 @@ public class ModifyDescriptor
* unexport the object forcibly.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
ActivationLibrary.deactivate(this, getID());
}
public static void main(String[] args) {
System.out.println("\nRegression test for bug 4127754\n");
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
RMID rmid = null;
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/*
* Create and register a group and activatable object
*/
System.err.println("Creating group descriptor");
Properties props = new Properties();
props.put("java.security.policy",
TestParams.defaultGroupPolicy);
props.put("java.security.manager",
TestParams.defaultSecurityManager);
props.put("test.message", MESSAGE1);
ActivationGroupDesc initialGroupDesc =
new ActivationGroupDesc(props, null);
System.err.println("Registering group");
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(initialGroupDesc);
System.err.println("Creating descriptor");
ActivationDesc initialDesc =
new ActivationDesc(groupID, "ModifyDescriptor", null,
new MarshalledObject(MESSAGE1), false);
System.err.println("Registering descriptor");
ActivateMe obj = (ActivateMe) Activatable.register(initialDesc);
/*
* Ping object and verify that MarshalledObject is okay.
*/
System.err.println("Ping object");
String message1 = obj.getMessage();
System.err.println("message = " + message1);
if (message1.equals(MESSAGE1)) {
System.err.println("Test1a passed: initial MarshalledObject " +
"correct");
} else {
TestLibrary.bomb("Test1 failed: unexpected MarshalledObject passed to " +
"constructor", null);
}
/*
* Get property from remote group and make sure it's okay
*/
message1 = obj.getProperty("test.message");
if (message1.equals(MESSAGE1)) {
System.err.println("Test1b passed: initial group property " +
"correct");
} else {
TestLibrary.bomb("Test1 failed: unexpected property passed to " +
"group", null);
}
/*
* Update activation descriptor for object and group
*/
System.err.println("Update activation descriptor");
ActivationDesc newDesc =
new ActivationDesc(groupID, "ModifyDescriptor", null,
new MarshalledObject(MESSAGE2), false);
ActivationID id = obj.getID();
ActivationDesc oldDesc = system.setActivationDesc(id, newDesc);
if (oldDesc.equals(initialDesc)) {
System.err.println("Test2a passed: desc returned from " +
"setActivationDesc is okay");
} else {
TestLibrary.bomb("Test2a failed: desc returned from setActivationDesc " +
"is not the initial descriptor!", null);
}
Properties props2 = new Properties();
props2.put("test.message", MESSAGE2);
props2.put("java.security.policy",
TestParams.defaultGroupPolicy);
props2.put("java.security.manager",
TestParams.defaultSecurityManager);
ActivationGroupDesc newGroupDesc =
new ActivationGroupDesc(props2, null);
ActivationGroupDesc oldGroupDesc =
system.setActivationGroupDesc(groupID, newGroupDesc);
if (oldGroupDesc.equals(initialGroupDesc)) {
System.err.println("Test2b passed: group desc returned from " +
"setActivationGroupDesc is okay");
} else {
TestLibrary.bomb("Test2b failed: group desc returned from " +
"setActivationGroupDesc is not the initial descriptor!",
null);
}
/*
* Restart rmid; and ping object to make sure that it has
* new message.
*/
rmid.restart();
System.err.println("Ping object after restart");
String message2 = obj.getMessage();
if (message2.equals(MESSAGE2)) {
System.err.println("Test3a passed: setActivationDesc takes " +
"effect after a restart");
} else {
TestLibrary.bomb("Test3a failed: setActivationDesc did not take effect " +
"after a restart", null);
}
message2 = obj.getProperty("test.message");
if (message2.equals(MESSAGE2)) {
System.err.println("Test3b passed: setActivationGroupDesc " +
"takes effect after a restart");
} else {
TestLibrary.bomb("Test3b failed: setActivationGroupDesc did not take " +
"effect after a restart", null);
}
System.err.println("Get activation descriptor");
ActivationDesc latestDesc = system.getActivationDesc(id);
if (latestDesc.equals(newDesc)) {
System.err.println("Test4a passed: desc is same as latest");
} else {
TestLibrary.bomb("Test4a failed: there is no way this would happen", null);
}
System.err.println("Get activation group descriptor");
ActivationGroupDesc latestGroupDesc =
system.getActivationGroupDesc(groupID);
if (latestGroupDesc.equals(newGroupDesc)) {
System.err.println("Test4b passed: group desc is same as " +
"latest");
} else {
TestLibrary.bomb("Test4b failed: there is no way this would happen", null);
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
}
System.out.println("\nRegression test for bug 4127754\n");
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
RMID rmid = null;
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/*
* Create and register a group and activatable object
*/
System.err.println("Creating group descriptor");
Properties props = new Properties();
props.put("java.security.policy",
TestParams.defaultGroupPolicy);
props.put("java.security.manager",
TestParams.defaultSecurityManager);
props.put("test.message", MESSAGE1);
ActivationGroupDesc initialGroupDesc =
new ActivationGroupDesc(props, null);
System.err.println("Registering group");
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(initialGroupDesc);
System.err.println("Creating descriptor");
ActivationDesc initialDesc =
new ActivationDesc(groupID, "ModifyDescriptor", null,
new MarshalledObject(MESSAGE1), false);
System.err.println("Registering descriptor");
ActivateMe obj = (ActivateMe) Activatable.register(initialDesc);
/*
* Ping object and verify that MarshalledObject is okay.
*/
System.err.println("Ping object");
String message1 = obj.getMessage();
System.err.println("message = " + message1);
if (message1.equals(MESSAGE1)) {
System.err.println("Test1a passed: initial MarshalledObject " +
"correct");
} else {
TestLibrary.bomb("Test1 failed: unexpected MarshalledObject passed to " +
"constructor", null);
}
/*
* Get property from remote group and make sure it's okay
*/
message1 = obj.getProperty("test.message");
if (message1.equals(MESSAGE1)) {
System.err.println("Test1b passed: initial group property " +
"correct");
} else {
TestLibrary.bomb("Test1 failed: unexpected property passed to " +
"group", null);
}
/*
* Update activation descriptor for object and group
*/
System.err.println("Update activation descriptor");
ActivationDesc newDesc =
new ActivationDesc(groupID, "ModifyDescriptor", null,
new MarshalledObject(MESSAGE2), false);
ActivationID id = obj.getID();
ActivationDesc oldDesc = system.setActivationDesc(id, newDesc);
if (oldDesc.equals(initialDesc)) {
System.err.println("Test2a passed: desc returned from " +
"setActivationDesc is okay");
} else {
TestLibrary.bomb("Test2a failed: desc returned from setActivationDesc " +
"is not the initial descriptor!", null);
}
Properties props2 = new Properties();
props2.put("test.message", MESSAGE2);
props2.put("java.security.policy",
TestParams.defaultGroupPolicy);
props2.put("java.security.manager",
TestParams.defaultSecurityManager);
ActivationGroupDesc newGroupDesc =
new ActivationGroupDesc(props2, null);
ActivationGroupDesc oldGroupDesc =
system.setActivationGroupDesc(groupID, newGroupDesc);
if (oldGroupDesc.equals(initialGroupDesc)) {
System.err.println("Test2b passed: group desc returned from " +
"setActivationGroupDesc is okay");
} else {
TestLibrary.bomb("Test2b failed: group desc returned from " +
"setActivationGroupDesc is not the initial descriptor!",
null);
}
/*
* Restart rmid; and ping object to make sure that it has
* new message.
*/
rmid.restart();
System.err.println("Ping object after restart");
String message2 = obj.getMessage();
if (message2.equals(MESSAGE2)) {
System.err.println("Test3a passed: setActivationDesc takes " +
"effect after a restart");
} else {
TestLibrary.bomb("Test3a failed: setActivationDesc did not take effect " +
"after a restart", null);
}
message2 = obj.getProperty("test.message");
if (message2.equals(MESSAGE2)) {
System.err.println("Test3b passed: setActivationGroupDesc " +
"takes effect after a restart");
} else {
TestLibrary.bomb("Test3b failed: setActivationGroupDesc did not take " +
"effect after a restart", null);
}
System.err.println("Get activation descriptor");
ActivationDesc latestDesc = system.getActivationDesc(id);
if (latestDesc.equals(newDesc)) {
System.err.println("Test4a passed: desc is same as latest");
} else {
TestLibrary.bomb("Test4a failed: there is no way this would happen", null);
}
System.err.println("Get activation group descriptor");
ActivationGroupDesc latestGroupDesc =
system.getActivationGroupDesc(groupID);
if (latestGroupDesc.equals(newGroupDesc)) {
System.err.println("Test4b passed: group desc is same as " +
"latest");
} else {
TestLibrary.bomb("Test4b failed: there is no way this would happen", null);
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
}
}
}
/*
/*
* Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -29,166 +29,166 @@ public final class ModifyDescriptor_Stub
implements ActivateMe
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("java.rmi.activation.ActivationID getID()"),
new java.rmi.server.Operation("java.lang.String getMessage()"),
new java.rmi.server.Operation("java.lang.String getProperty(java.lang.String)"),
new java.rmi.server.Operation("void shutdown()")
new java.rmi.server.Operation("java.rmi.activation.ActivationID getID()"),
new java.rmi.server.Operation("java.lang.String getMessage()"),
new java.rmi.server.Operation("java.lang.String getProperty(java.lang.String)"),
new java.rmi.server.Operation("void shutdown()")
};
private static final long interfaceHash = 7998207954486691383L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_getID_0;
private static java.lang.reflect.Method $method_getMessage_1;
private static java.lang.reflect.Method $method_getProperty_2;
private static java.lang.reflect.Method $method_shutdown_3;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getID_0 = ActivateMe.class.getMethod("getID", new java.lang.Class[] {});
$method_getMessage_1 = ActivateMe.class.getMethod("getMessage", new java.lang.Class[] {});
$method_getProperty_2 = ActivateMe.class.getMethod("getProperty", new java.lang.Class[] {java.lang.String.class});
$method_shutdown_3 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getID_0 = ActivateMe.class.getMethod("getID", new java.lang.Class[] {});
$method_getMessage_1 = ActivateMe.class.getMethod("getMessage", new java.lang.Class[] {});
$method_getProperty_2 = ActivateMe.class.getMethod("getProperty", new java.lang.Class[] {java.lang.String.class});
$method_shutdown_3 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public ModifyDescriptor_Stub() {
super();
super();
}
public ModifyDescriptor_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of getID()
public java.rmi.activation.ActivationID getID()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getID_0, null, -7795865521150345044L);
return ((java.rmi.activation.ActivationID) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
java.rmi.activation.ActivationID $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.activation.ActivationID) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getID_0, null, -7795865521150345044L);
return ((java.rmi.activation.ActivationID) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
java.rmi.activation.ActivationID $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.activation.ActivationID) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of getMessage()
public java.lang.String getMessage()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getMessage_1, null, 5353407034680111516L);
return ((java.lang.String) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.lang.String $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getMessage_1, null, 5353407034680111516L);
return ((java.lang.String) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.lang.String $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of getProperty(String)
public java.lang.String getProperty(java.lang.String $param_String_1)
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getProperty_2, new java.lang.Object[] {$param_String_1}, 77249282285080913L);
return ((java.lang.String) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
java.lang.String $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getProperty_2, new java.lang.Object[] {$param_String_1}, 77249282285080913L);
return ((java.lang.String) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
java.lang.String $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public void shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -34,4 +34,3 @@ interface CanCreateStubs extends java.rmi.Remote {
Object getForbiddenClass() throws Exception;
ActivationGroupID returnGroupID() throws RemoteException;
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -20,7 +20,7 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 4179055
* @summary Some java apps need to have access to read "accessClassInPackage.sun.rmi.server"
......@@ -55,151 +55,151 @@ import java.util.StringTokenizer;
*
* The test causes the activation system to need to create each of
* these classes in turn. The test will fail if the activation system
* does not allow these classes to be created.
* does not allow these classes to be created.
*/
public class StubClassesPermitted
extends Activatable implements Runnable, CanCreateStubs
{
public static boolean sameGroup = false;
private static CanCreateStubs canCreateStubs = null;
private static Registry registry = null;
public static void main(String args[]) {
sameGroup = true;
RMID rmid = null;
System.err.println("\nRegression test for bug/rfe 4179055\n");
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
registry = java.rmi.registry.LocateRegistry.
createRegistry(TestLibrary.REGISTRY_PORT);
// must run with java.lang.SecurityManager or the test
// result will be nullified if running with a build where
// 4180392 has not been fixed.
String smClassName =
System.getSecurityManager().getClass().getName();
if (!smClassName.equals("java.lang.SecurityManager")) {
TestLibrary.bomb("Test must run with java.lang.SecurityManager");
}
// start an rmid.
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
//rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"});
// Ensure that activation groups run with the correct
// security manager.
//
Properties p = new Properties();
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
"java.lang.SecurityManager");
// This action causes the following classes to be created
// in this VM (RMI must permit the creation of these classes):
//
// sun.rmi.server.Activation$ActivationSystemImpl_Stub
// sun.rmi.server.Activation$ActivationMonitorImpl_Stub
//
System.err.println("Create activation group, in a new VM");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(groupDesc);
System.err.println("register activatable");
// Fix for: 4271615: make sure activation group runs in a new VM
ActivationDesc desc = new ActivationDesc
(groupID, "StubClassesPermitted", null, null);
canCreateStubs = (CanCreateStubs) Activatable.register(desc);
// ensure registry stub can be passed in a remote call
System.err.println("getting the registry");
registry = canCreateStubs.getRegistry();
// make sure a client cant load just any sun.* class, just
// as a sanity check, try to create a class we are not
// allowed to access but which was passed in a remote call
try {
System.err.println("accessing forbidden class");
Object secureRandom = canCreateStubs.getForbiddenClass();
TestLibrary.bomb("test allowed to access forbidden class," +
" sun.security.provider.SecureRandom");
} catch (java.security.AccessControlException e) {
// Make sure we received a *local* AccessControlException
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bout);
e.printStackTrace(ps);
ps.flush();
String trace = new String(bout.toByteArray());
if ((trace.indexOf("exceptionReceivedFromServer") >= 0) ||
trace.equals(""))
public static void main(String args[]) {
sameGroup = true;
RMID rmid = null;
System.err.println("\nRegression test for bug/rfe 4179055\n");
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
registry = java.rmi.registry.LocateRegistry.
createRegistry(TestLibrary.REGISTRY_PORT);
// must run with java.lang.SecurityManager or the test
// result will be nullified if running with a build where
// 4180392 has not been fixed.
String smClassName =
System.getSecurityManager().getClass().getName();
if (!smClassName.equals("java.lang.SecurityManager")) {
TestLibrary.bomb("Test must run with java.lang.SecurityManager");
}
// start an rmid.
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
//rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"});
// Ensure that activation groups run with the correct
// security manager.
//
Properties p = new Properties();
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
"java.lang.SecurityManager");
// This action causes the following classes to be created
// in this VM (RMI must permit the creation of these classes):
//
// sun.rmi.server.Activation$ActivationSystemImpl_Stub
// sun.rmi.server.Activation$ActivationMonitorImpl_Stub
//
System.err.println("Create activation group, in a new VM");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(groupDesc);
System.err.println("register activatable");
// Fix for: 4271615: make sure activation group runs in a new VM
ActivationDesc desc = new ActivationDesc
(groupID, "StubClassesPermitted", null, null);
canCreateStubs = (CanCreateStubs) Activatable.register(desc);
// ensure registry stub can be passed in a remote call
System.err.println("getting the registry");
registry = canCreateStubs.getRegistry();
// make sure a client cant load just any sun.* class, just
// as a sanity check, try to create a class we are not
// allowed to access but which was passed in a remote call
try {
System.err.println("accessing forbidden class");
Object secureRandom = canCreateStubs.getForbiddenClass();
TestLibrary.bomb("test allowed to access forbidden class," +
" sun.security.provider.SecureRandom");
} catch (java.security.AccessControlException e) {
// Make sure we received a *local* AccessControlException
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bout);
e.printStackTrace(ps);
ps.flush();
String trace = new String(bout.toByteArray());
if ((trace.indexOf("exceptionReceivedFromServer") >= 0) ||
trace.equals(""))
{
throw e;
}
System.err.println("received expected local access control exception");
}
// make sure that an ActivationGroupID can be passed in a
// remote call; this is slightly more inclusive than
// just passing a reference to the activation system
System.err.println("returning group desc");
canCreateStubs.returnGroupID();
// Clean up object
System.err.println
("Deactivate object via method call");
canCreateStubs.shutdown();
System.err.println
("\nsuccess: StubClassesPermitted test passed ");
} catch (Exception e) {
TestLibrary.bomb("\nfailure: unexpected exception ", e);
} finally {
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
}
canCreateStubs = null;
ActivationLibrary.rmidCleanup(rmid);
System.err.println("rmid shut down");
}
throw e;
}
System.err.println("received expected local access control exception");
}
// make sure that an ActivationGroupID can be passed in a
// remote call; this is slightly more inclusive than
// just passing a reference to the activation system
System.err.println("returning group desc");
canCreateStubs.returnGroupID();
// Clean up object
System.err.println
("Deactivate object via method call");
canCreateStubs.shutdown();
System.err.println
("\nsuccess: StubClassesPermitted test passed ");
} catch (Exception e) {
TestLibrary.bomb("\nfailure: unexpected exception ", e);
} finally {
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
}
canCreateStubs = null;
ActivationLibrary.rmidCleanup(rmid);
System.err.println("rmid shut down");
}
}
static ActivationGroupID GroupID = null;
/**
* implementation of CanCreateStubs
* implementation of CanCreateStubs
*/
public StubClassesPermitted
(ActivationID id, MarshalledObject mo) throws RemoteException
(ActivationID id, MarshalledObject mo) throws RemoteException
{
// register/export anonymously
super(id, 0);
// register/export anonymously
super(id, 0);
// obtain reference to the test registry
registry = java.rmi.registry.LocateRegistry.
getRegistry(TestLibrary.REGISTRY_PORT);
// obtain reference to the test registry
registry = java.rmi.registry.LocateRegistry.
getRegistry(TestLibrary.REGISTRY_PORT);
}
/**
* Spawns a thread to deactivate the object.
*/
public void shutdown() throws Exception {
(new Thread(this,"StubClassesPermitted")).start();
(new Thread(this,"StubClassesPermitted")).start();
}
/**
......@@ -209,7 +209,7 @@ public class StubClassesPermitted
* unexport the object forcibly.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
ActivationLibrary.deactivate(this, getID());
}
/**
......@@ -217,12 +217,12 @@ public class StubClassesPermitted
* the stub for it can be deserialized in the test client VM.
*/
public Registry getRegistry() throws RemoteException {
if (sameGroup) {
System.out.println("in same group");
} else {
System.out.println("not in same group");
}
return registry;
if (sameGroup) {
System.out.println("in same group");
} else {
System.out.println("not in same group");
}
return registry;
}
/**
......@@ -232,8 +232,8 @@ public class StubClassesPermitted
* can be resolved in a remote call.
*/
public Object getForbiddenClass() throws RemoteException {
System.err.println("creating sun class");
return new sun.security.provider.SecureRandom();
System.err.println("creating sun class");
return new sun.security.provider.SecureRandom();
}
/**
......@@ -242,6 +242,6 @@ public class StubClassesPermitted
* system implementation).
*/
public ActivationGroupID returnGroupID() throws RemoteException {
return ActivationGroup.currentGroupID();
return ActivationGroup.currentGroupID();
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -29,152 +29,152 @@ public final class StubClassesPermitted_Stub
implements CanCreateStubs, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("java.lang.Object getForbiddenClass()"),
new java.rmi.server.Operation("java.rmi.registry.Registry getRegistry()"),
new java.rmi.server.Operation("java.rmi.activation.ActivationGroupID returnGroupID()"),
new java.rmi.server.Operation("void shutdown()")
new java.rmi.server.Operation("java.lang.Object getForbiddenClass()"),
new java.rmi.server.Operation("java.rmi.registry.Registry getRegistry()"),
new java.rmi.server.Operation("java.rmi.activation.ActivationGroupID returnGroupID()"),
new java.rmi.server.Operation("void shutdown()")
};
private static final long interfaceHash = 1677779850431817575L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_getForbiddenClass_0;
private static java.lang.reflect.Method $method_getRegistry_1;
private static java.lang.reflect.Method $method_returnGroupID_2;
private static java.lang.reflect.Method $method_shutdown_3;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getForbiddenClass_0 = CanCreateStubs.class.getMethod("getForbiddenClass", new java.lang.Class[] {});
$method_getRegistry_1 = CanCreateStubs.class.getMethod("getRegistry", new java.lang.Class[] {});
$method_returnGroupID_2 = CanCreateStubs.class.getMethod("returnGroupID", new java.lang.Class[] {});
$method_shutdown_3 = CanCreateStubs.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getForbiddenClass_0 = CanCreateStubs.class.getMethod("getForbiddenClass", new java.lang.Class[] {});
$method_getRegistry_1 = CanCreateStubs.class.getMethod("getRegistry", new java.lang.Class[] {});
$method_returnGroupID_2 = CanCreateStubs.class.getMethod("returnGroupID", new java.lang.Class[] {});
$method_shutdown_3 = CanCreateStubs.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public StubClassesPermitted_Stub() {
super();
super();
}
public StubClassesPermitted_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of getForbiddenClass()
public java.lang.Object getForbiddenClass()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getForbiddenClass_0, null, -658265783646674294L);
return ((java.lang.Object) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
java.lang.Object $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.Object) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getForbiddenClass_0, null, -658265783646674294L);
return ((java.lang.Object) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
java.lang.Object $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.Object) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
}
// implementation of getRegistry()
public java.rmi.registry.Registry getRegistry()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getRegistry_1, null, 255311215504696981L);
return ((java.rmi.registry.Registry) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.rmi.registry.Registry $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.registry.Registry) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getRegistry_1, null, 255311215504696981L);
return ((java.rmi.registry.Registry) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.rmi.registry.Registry $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.registry.Registry) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of returnGroupID()
public java.rmi.activation.ActivationGroupID returnGroupID()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_returnGroupID_2, null, 6267304638191237098L);
return ((java.rmi.activation.ActivationGroupID) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
ref.invoke(call);
java.rmi.activation.ActivationGroupID $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.activation.ActivationGroupID) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_returnGroupID_2, null, 6267304638191237098L);
return ((java.rmi.activation.ActivationGroupID) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
ref.invoke(call);
java.rmi.activation.ActivationGroupID $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.activation.ActivationGroupID) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public void shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -27,4 +27,3 @@ public interface CallbackInterface extends Remote {
public void inc() throws RemoteException;
public int getNumDeactivated() throws RemoteException;
}
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -29,94 +29,94 @@ public final class Callback_Stub
implements CallbackInterface, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("int getNumDeactivated()"),
new java.rmi.server.Operation("void inc()")
new java.rmi.server.Operation("int getNumDeactivated()"),
new java.rmi.server.Operation("void inc()")
};
private static final long interfaceHash = -1008194523112388035L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_getNumDeactivated_0;
private static java.lang.reflect.Method $method_inc_1;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getNumDeactivated_0 = CallbackInterface.class.getMethod("getNumDeactivated", new java.lang.Class[] {});
$method_inc_1 = CallbackInterface.class.getMethod("inc", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getNumDeactivated_0 = CallbackInterface.class.getMethod("getNumDeactivated", new java.lang.Class[] {});
$method_inc_1 = CallbackInterface.class.getMethod("inc", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public Callback_Stub() {
super();
super();
}
public Callback_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of getNumDeactivated()
public int getNumDeactivated()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getNumDeactivated_0, null, -761062487639949912L);
return ((java.lang.Integer) $result).intValue();
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
int $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = in.readInt();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getNumDeactivated_0, null, -761062487639949912L);
return ((java.lang.Integer) $result).intValue();
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
int $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = in.readInt();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of inc()
public void inc()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
ref.invoke(this, $method_inc_1, null, 4394985085384332959L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
ref.invoke(this, $method_inc_1, null, 4394985085384332959L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
}
/*
/*
* Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -65,8 +65,8 @@ class Callback extends UnicastRemoteObject implements CallbackInterface {
}
public class UnregisterGroup
extends Activatable
implements ActivateMe, Runnable
extends Activatable
implements ActivateMe, Runnable
{
private static Exception exception = null;
......@@ -77,30 +77,30 @@ public class UnregisterGroup
private static int PORT = 2006;
public UnregisterGroup(ActivationID id, MarshalledObject mobj)
throws Exception
throws Exception
{
super(id, 0);
super(id, 0);
}
public void ping()
{}
public void unregister() throws Exception {
super.unregister(super.getID());
super.unregister(super.getID());
}
/**
* Spawns a thread to deactivate the object.
*/
public void shutdown() throws Exception {
(new Thread(this,"UnregisterGroup")).start();
(new Thread(this,"UnregisterGroup")).start();
}
/**
* To support exiting of group VM as a last resort
*/
public void justGoAway() {
System.exit(0);
System.exit(0);
}
/**
......@@ -111,151 +111,151 @@ public class UnregisterGroup
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
System.err.println("\tActivationLibrary.deactivate returned");
ActivationLibrary.deactivate(this, getID());
System.err.println("\tActivationLibrary.deactivate returned");
try {
CallbackInterface cobj =
(CallbackInterface)Naming.lookup("//:" + PORT + "/Callback");
cobj.inc();
} catch (Exception e) {
System.err.println("cobj.inc exception");
e.printStackTrace();
}
try {
CallbackInterface cobj =
(CallbackInterface)Naming.lookup("//:" + PORT + "/Callback");
cobj.inc();
} catch (Exception e) {
System.err.println("cobj.inc exception");
e.printStackTrace();
}
}
public static void main(String[] args) {
Registry registry;
System.err.println("\nRegression test for bug 4134233\n");
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
RMID rmid = null;
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
final Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
//final int NUM_OBJECTS = 10;
Thread t = new Thread() {
public void run () {
try {
System.err.println("Creating group descriptor");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID =
system.registerGroup(groupDesc);
ActivateMe[] obj = new ActivateMe[NUM_OBJECTS];
for (int i = 0; i < NUM_OBJECTS; i++) {
System.err.println("Creating descriptor: " + i);
ActivationDesc desc =
new ActivationDesc(groupID, "UnregisterGroup",
null, null);
System.err.println("Registering descriptor: " + i);
obj[i] = (ActivateMe) Activatable.register(desc);
System.err.println("Activating object: " + i);
obj[i].ping();
}
lastResortExitObj = obj[0];
System.err.println("Unregistering group");
system.unregisterGroup(groupID);
try {
System.err.println("Get the group descriptor");
system.getActivationGroupDesc(groupID);
error = "test failed: group still registered";
} catch (UnknownGroupException e) {
System.err.println("Test passed: " +
"group unregistered");
}
/*
* Deactivate objects so group VM will exit.
*/
for (int i = 0; i < NUM_OBJECTS; i++) {
System.err.println("Deactivating object: " + i);
obj[i].shutdown();
obj[i] = null;
}
lastResortExitObj = null;
} catch (Exception e) {
exception = e;
}
done = true;
}
};
t.start();
t.join(120000);
if (exception != null) {
TestLibrary.bomb("test failed", exception);
} else if (error != null) {
TestLibrary.bomb(error, null);
} else if (!done) {
TestLibrary.bomb("test failed: not completed before timeout", null);
} else {
System.err.println("Test passed");
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
if (lastResortExitObj != null) {
try {
lastResortExitObj.justGoAway();
} catch (Exception munch) {
}
}
// Wait for the object deactivation to take place first
try {
// create reg and export callback object
registry = LocateRegistry.createRegistry(PORT);
Callback robj = new Callback();
registry.bind("Callback", robj);
//get the callback object
int maxwait=30;
int nd = robj.getNumDeactivated();
while ((nd < NUM_OBJECTS) && (maxwait> 0)) {
System.err.println("num_deactivated="+nd);
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {}
maxwait--;
nd = robj.getNumDeactivated();
}
} catch (Exception ce) {
System.err.println("E:"+ce);
ce.printStackTrace();
}
ActivationLibrary.rmidCleanup(rmid);
}
Registry registry;
System.err.println("\nRegression test for bug 4134233\n");
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
RMID rmid = null;
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
final Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
//final int NUM_OBJECTS = 10;
Thread t = new Thread() {
public void run () {
try {
System.err.println("Creating group descriptor");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID =
system.registerGroup(groupDesc);
ActivateMe[] obj = new ActivateMe[NUM_OBJECTS];
for (int i = 0; i < NUM_OBJECTS; i++) {
System.err.println("Creating descriptor: " + i);
ActivationDesc desc =
new ActivationDesc(groupID, "UnregisterGroup",
null, null);
System.err.println("Registering descriptor: " + i);
obj[i] = (ActivateMe) Activatable.register(desc);
System.err.println("Activating object: " + i);
obj[i].ping();
}
lastResortExitObj = obj[0];
System.err.println("Unregistering group");
system.unregisterGroup(groupID);
try {
System.err.println("Get the group descriptor");
system.getActivationGroupDesc(groupID);
error = "test failed: group still registered";
} catch (UnknownGroupException e) {
System.err.println("Test passed: " +
"group unregistered");
}
/*
* Deactivate objects so group VM will exit.
*/
for (int i = 0; i < NUM_OBJECTS; i++) {
System.err.println("Deactivating object: " + i);
obj[i].shutdown();
obj[i] = null;
}
lastResortExitObj = null;
} catch (Exception e) {
exception = e;
}
done = true;
}
};
t.start();
t.join(120000);
if (exception != null) {
TestLibrary.bomb("test failed", exception);
} else if (error != null) {
TestLibrary.bomb(error, null);
} else if (!done) {
TestLibrary.bomb("test failed: not completed before timeout", null);
} else {
System.err.println("Test passed");
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
if (lastResortExitObj != null) {
try {
lastResortExitObj.justGoAway();
} catch (Exception munch) {
}
}
// Wait for the object deactivation to take place first
try {
// create reg and export callback object
registry = LocateRegistry.createRegistry(PORT);
Callback robj = new Callback();
registry.bind("Callback", robj);
//get the callback object
int maxwait=30;
int nd = robj.getNumDeactivated();
while ((nd < NUM_OBJECTS) && (maxwait> 0)) {
System.err.println("num_deactivated="+nd);
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {}
maxwait--;
nd = robj.getNumDeactivated();
}
} catch (Exception ce) {
System.err.println("E:"+ce);
ce.printStackTrace();
}
ActivationLibrary.rmidCleanup(rmid);
}
}
}
/*
/*
* Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -29,116 +29,116 @@ public final class UnregisterGroup_Stub
implements ActivateMe, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("void justGoAway()"),
new java.rmi.server.Operation("void ping()"),
new java.rmi.server.Operation("void shutdown()"),
new java.rmi.server.Operation("void unregister()")
new java.rmi.server.Operation("void justGoAway()"),
new java.rmi.server.Operation("void ping()"),
new java.rmi.server.Operation("void shutdown()"),
new java.rmi.server.Operation("void unregister()")
};
private static final long interfaceHash = -4733924075192691630L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_justGoAway_0;
private static java.lang.reflect.Method $method_ping_1;
private static java.lang.reflect.Method $method_shutdown_2;
private static java.lang.reflect.Method $method_unregister_3;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_justGoAway_0 = ActivateMe.class.getMethod("justGoAway", new java.lang.Class[] {});
$method_ping_1 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_2 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
$method_unregister_3 = ActivateMe.class.getMethod("unregister", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_justGoAway_0 = ActivateMe.class.getMethod("justGoAway", new java.lang.Class[] {});
$method_ping_1 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_2 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
$method_unregister_3 = ActivateMe.class.getMethod("unregister", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public UnregisterGroup_Stub() {
super();
super();
}
public UnregisterGroup_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of justGoAway()
public void justGoAway()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
ref.invoke(this, $method_justGoAway_0, null, -5382478058620783904L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
ref.invoke(this, $method_justGoAway_0, null, -5382478058620783904L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of ping()
public void ping()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
ref.invoke(this, $method_ping_1, null, 5866401369815527589L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
ref.invoke(this, $method_ping_1, null, 5866401369815527589L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public void shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_2, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
ref.invoke(call);
ref.done(call);
}
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_2, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
ref.invoke(call);
ref.done(call);
}
}
// implementation of unregister()
public void unregister()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
ref.invoke(this, $method_unregister_3, null, -5366864281862648102L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
if (useNewInvoke) {
ref.invoke(this, $method_unregister_3, null, -5366864281862648102L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -41,17 +41,17 @@ public class CheckVMID {
public static void main(String[] args) {
System.err.println("\nRegression test for bug 4171370\n");
System.err.println("\nRegression test for bug 4171370\n");
TestLibrary.suggestSecurityManager(null);
TestLibrary.suggestSecurityManager(null);
try {
System.err.println("Create a VMID");
VMID vmid = new VMID();
System.err.println("vmid = " + vmid);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
}
try {
System.err.println("Create a VMID");
VMID vmid = new VMID();
System.err.println("vmid = " + vmid);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
}
}
}
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -51,123 +51,123 @@ public class DGCAckFailure implements ReturnRemote {
private static final long TIMEOUT = 20000;
public Object returnRemote() {
return new Wrapper(this);
return new Wrapper(this);
}
public static void main(String[] args) throws Exception {
System.setProperty("sun.rmi.dgc.ackTimeout", "10000");
/*
* Set a socket factory that has a hook for shutting down all client
* output (writes from client-created sockets and new connection
* attempts). We then use this hook right before a remote stub gets
* deserialized, so that the client will not be able to send a DGC
* dirty call, or a DGC acknowledgment. Without the DGC ack, we
* hope that the RMI runtime will still eventually allow the remote
* object to be garbage collected.
*/
RMISocketFactory.setSocketFactory(new TestSF());
System.err.println("test socket factory set");
Remote impl = new DGCAckFailure();
ReferenceQueue refQueue = new ReferenceQueue();
Reference weakRef = new WeakReference(impl, refQueue);
ReturnRemote stub =
(ReturnRemote) UnicastRemoteObject.exportObject(impl);
System.err.println("remote object exported; stub = " + stub);
try {
Object wrappedStub = stub.returnRemote();
System.err.println("invocation returned: " + wrappedStub);
impl = null;
stub = null; // in case 4114579 ever gets fixed
System.err.println("strong references to impl cleared");
System.err.println("waiting for weak reference notification:");
Reference ref = null;
for (int i = 0; i < 6; i++) {
System.gc();
ref = refQueue.remove(TIMEOUT / 5);
if (ref != null) {
break;
}
}
if (ref == weakRef) {
System.err.println("TEST PASSED");
} else {
throw new RuntimeException("TEST FAILED: " +
"timed out, remote object not garbage collected");
}
} finally {
try {
UnicastRemoteObject.unexportObject((Remote) weakRef.get(),
true);
} catch (Exception e) {
}
}
System.setProperty("sun.rmi.dgc.ackTimeout", "10000");
/*
* Set a socket factory that has a hook for shutting down all client
* output (writes from client-created sockets and new connection
* attempts). We then use this hook right before a remote stub gets
* deserialized, so that the client will not be able to send a DGC
* dirty call, or a DGC acknowledgment. Without the DGC ack, we
* hope that the RMI runtime will still eventually allow the remote
* object to be garbage collected.
*/
RMISocketFactory.setSocketFactory(new TestSF());
System.err.println("test socket factory set");
Remote impl = new DGCAckFailure();
ReferenceQueue refQueue = new ReferenceQueue();
Reference weakRef = new WeakReference(impl, refQueue);
ReturnRemote stub =
(ReturnRemote) UnicastRemoteObject.exportObject(impl);
System.err.println("remote object exported; stub = " + stub);
try {
Object wrappedStub = stub.returnRemote();
System.err.println("invocation returned: " + wrappedStub);
impl = null;
stub = null; // in case 4114579 ever gets fixed
System.err.println("strong references to impl cleared");
System.err.println("waiting for weak reference notification:");
Reference ref = null;
for (int i = 0; i < 6; i++) {
System.gc();
ref = refQueue.remove(TIMEOUT / 5);
if (ref != null) {
break;
}
}
if (ref == weakRef) {
System.err.println("TEST PASSED");
} else {
throw new RuntimeException("TEST FAILED: " +
"timed out, remote object not garbage collected");
}
} finally {
try {
UnicastRemoteObject.unexportObject((Remote) weakRef.get(),
true);
} catch (Exception e) {
}
}
}
private static class Wrapper implements Serializable {
private final Remote obj;
Wrapper(Remote obj) { this.obj = obj; }
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
TestSF.shutdownClientOutput();
System.err.println(
"Wrapper.readObject: SHUTTING DOWN CLIENT OUTPUT");
in.defaultReadObject();
}
public String toString() { return "Wrapper[" + obj + "]"; }
private final Remote obj;
Wrapper(Remote obj) { this.obj = obj; }
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
TestSF.shutdownClientOutput();
System.err.println(
"Wrapper.readObject: SHUTTING DOWN CLIENT OUTPUT");
in.defaultReadObject();
}
public String toString() { return "Wrapper[" + obj + "]"; }
}
private static class TestSF extends RMISocketFactory {
private static volatile boolean shutdown = false;
static void shutdownClientOutput() { shutdown = true; }
public Socket createSocket(String host, int port) throws IOException {
if (shutdown) {
IOException e = new java.net.ConnectException(
"test socket factory rejecting client connection");
System.err.println(e);
// e.printStackTrace();
throw e;
} else {
return new TestSocket(host, port);
}
}
public ServerSocket createServerSocket(int port) throws IOException {
return new ServerSocket(port);
}
private static class TestSocket extends Socket {
TestSocket(String host, int port) throws IOException {
super(host, port);
}
public OutputStream getOutputStream() throws IOException {
return new TestOutputStream(super.getOutputStream());
}
}
private static class TestOutputStream extends FilterOutputStream {
TestOutputStream(OutputStream out) { super(out); }
public void write(int b) throws IOException {
if (shutdown) {
IOException e = new IOException(
"connection broken by test socket factory");
System.err.println(e);
// e.printStackTrace();
throw e;
} else {
super.write(b);
}
}
}
private static volatile boolean shutdown = false;
static void shutdownClientOutput() { shutdown = true; }
public Socket createSocket(String host, int port) throws IOException {
if (shutdown) {
IOException e = new java.net.ConnectException(
"test socket factory rejecting client connection");
System.err.println(e);
// e.printStackTrace();
throw e;
} else {
return new TestSocket(host, port);
}
}
public ServerSocket createServerSocket(int port) throws IOException {
return new ServerSocket(port);
}
private static class TestSocket extends Socket {
TestSocket(String host, int port) throws IOException {
super(host, port);
}
public OutputStream getOutputStream() throws IOException {
return new TestOutputStream(super.getOutputStream());
}
}
private static class TestOutputStream extends FilterOutputStream {
TestOutputStream(OutputStream out) { super(out); }
public void write(int b) throws IOException {
if (shutdown) {
IOException e = new IOException(
"connection broken by test socket factory");
System.err.println(e);
// e.printStackTrace();
throw e;
} else {
super.write(b);
}
}
}
}
}
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -29,38 +29,38 @@ public final class DGCAckFailure_Stub
implements ReturnRemote
{
private static final long serialVersionUID = 2;
private static java.lang.reflect.Method $method_returnRemote_0;
static {
try {
$method_returnRemote_0 = ReturnRemote.class.getMethod("returnRemote", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
try {
$method_returnRemote_0 = ReturnRemote.class.getMethod("returnRemote", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
}
// constructors
public DGCAckFailure_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of returnRemote()
public java.lang.Object returnRemote()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
Object $result = ref.invoke(this, $method_returnRemote_0, null, -8981544221566403070L);
return ((java.lang.Object) $result);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
Object $result = ref.invoke(this, $method_returnRemote_0, null, -8981544221566403070L);
return ((java.lang.Object) $result);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
}
/*
/*
* Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -57,55 +57,55 @@ public class DGCImplInsulation implements java.rmi.Remote {
public static void main(String[] args) throws Exception {
TestLibrary.suggestSecurityManager(null);
TestLibrary.suggestSecurityManager(null);
Permissions perms = new Permissions();
perms.add(new SocketPermission("*:1024-", "listen"));
AccessControlContext acc =
new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(
new CodeSource(null, (Certificate[]) null), perms) });
Permissions perms = new Permissions();
perms.add(new SocketPermission("*:1024-", "listen"));
AccessControlContext acc =
new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(
new CodeSource(null, (Certificate[]) null), perms) });
Remote impl = new DGCImplInsulation();;
Remote impl = new DGCImplInsulation();;
try {
Remote stub = (Remote) java.security.AccessController.doPrivileged(
new ExportAction(impl));
System.err.println("exported remote object; local stub: " + stub);
try {
Remote stub = (Remote) java.security.AccessController.doPrivileged(
new ExportAction(impl));
System.err.println("exported remote object; local stub: " + stub);
MarshalledObject mobj = new MarshalledObject(stub);
stub = (Remote) mobj.get();
System.err.println("marshalled/unmarshalled stub: " + stub);
MarshalledObject mobj = new MarshalledObject(stub);
stub = (Remote) mobj.get();
System.err.println("marshalled/unmarshalled stub: " + stub);
ReferenceQueue refQueue = new ReferenceQueue();
Reference weakRef = new WeakReference(impl, refQueue);
impl = null;
System.gc();
if (refQueue.remove(TIMEOUT) == weakRef) {
throw new RuntimeException(
"TEST FAILED: remote object garbage collected");
} else {
System.err.println("TEST PASSED");
stub = null;
System.gc();
Thread.sleep(2000);
System.gc();
}
} finally {
try {
UnicastRemoteObject.unexportObject(impl, true);
} catch (Exception e) {
}
}
ReferenceQueue refQueue = new ReferenceQueue();
Reference weakRef = new WeakReference(impl, refQueue);
impl = null;
System.gc();
if (refQueue.remove(TIMEOUT) == weakRef) {
throw new RuntimeException(
"TEST FAILED: remote object garbage collected");
} else {
System.err.println("TEST PASSED");
stub = null;
System.gc();
Thread.sleep(2000);
System.gc();
}
} finally {
try {
UnicastRemoteObject.unexportObject(impl, true);
} catch (Exception e) {
}
}
}
private static class ExportAction implements PrivilegedExceptionAction {
private final Remote impl;
ExportAction(Remote impl) {
this.impl = impl;
}
public Object run() throws Exception {
return UnicastRemoteObject.exportObject(impl);
}
private final Remote impl;
ExportAction(Remote impl) {
this.impl = impl;
}
public Object run() throws Exception {
return UnicastRemoteObject.exportObject(impl);
}
}
}
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -29,10 +29,10 @@ public final class DGCImplInsulation_Stub
implements java.rmi.Remote
{
private static final long serialVersionUID = 2;
// constructors
public DGCImplInsulation_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -55,108 +55,108 @@ public class RetryDirtyCalls implements Self, Unreferenced {
* Return this object. The need for this method is explained below.
*/
public Self getSelf() {
return this;
return this;
}
public void unreferenced() {
synchronized (this) {
unreferenced = true;
notifyAll();
}
synchronized (this) {
unreferenced = true;
notifyAll();
}
}
public static void main(String[] args) {
System.err.println("\nRegression test for bug 4268258\n");
/*
* Set properties to tweak DGC behavior so that this test will execute
* quickly: set the granted lease duration to 10 seconds, the interval
* that leases are checked to 3 seconds.
*/
System.setProperty("java.rmi.dgc.leaseValue", "10000");
System.setProperty("sun.rmi.dgc.checkInterval", "3000");
/*
* Make idle connections time out almost instantly (0.1 seconds) so
* that the DGC implementation will have to make a new connection for
* each dirty call, thus going through the socket factory, where we
* can easily cause the operation to fail.
*/
System.setProperty("sun.rmi.transport.connectionTimeout", "100");
RetryDirtyCalls impl = new RetryDirtyCalls();
try {
TestSF sf = new TestSF();
RMISocketFactory.setSocketFactory(sf);
/*
* The stub returned by UnicastRemoteObject.exportObject() does
* not participate in DGC, but it does allow us to invoke a method
* on the remote object through RMI. Therefore, we invoke the
* getSelf() method through RMI, which returns an equivalent stub
* that does participate in DGC.
*/
Self stub = (Self) UnicastRemoteObject.exportObject(impl);
Self dgcStub = stub.getSelf();
stub = null; // in case 4114579 has been fixed
/*
* Set the socket factory to cause 3 connections attempts in a row
* to fail before allowing a connection to succeed, expecting the
* client-side DGC implementation to make at least four attempts.
*/
final int FLAKE_FACTOR = 3;
sf.setFlakeFactor(FLAKE_FACTOR);
long deadline = System.currentTimeMillis() + TIMEOUT;
boolean unreferenced;
synchronized (impl) {
while (!(unreferenced = impl.unreferenced)) {
long timeToWait = deadline - System.currentTimeMillis();
if (timeToWait > 0) {
impl.wait(timeToWait);
} else {
break;
}
}
}
if (unreferenced) {
throw new RuntimeException("remote object unreferenced");
}
int createCount = sf.getCreateCount();
if (createCount == 0) {
throw new RuntimeException("test socket factory never used");
} else if (createCount < (FLAKE_FACTOR + 3)) {
/*
* The unreferenced method was not invoked for some reason,
* but the dirty calls were clearly not retried well enough.
*/
throw new RuntimeException(
"test failed because dirty calls not retried enough, " +
"but remote object not unreferenced");
}
System.err.println(
"TEST PASSED: remote object not unreferenced");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + 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 {
UnicastRemoteObject.unexportObject(impl, true);
} catch (Exception e) {
}
}
System.err.println("\nRegression test for bug 4268258\n");
/*
* Set properties to tweak DGC behavior so that this test will execute
* quickly: set the granted lease duration to 10 seconds, the interval
* that leases are checked to 3 seconds.
*/
System.setProperty("java.rmi.dgc.leaseValue", "10000");
System.setProperty("sun.rmi.dgc.checkInterval", "3000");
/*
* Make idle connections time out almost instantly (0.1 seconds) so
* that the DGC implementation will have to make a new connection for
* each dirty call, thus going through the socket factory, where we
* can easily cause the operation to fail.
*/
System.setProperty("sun.rmi.transport.connectionTimeout", "100");
RetryDirtyCalls impl = new RetryDirtyCalls();
try {
TestSF sf = new TestSF();
RMISocketFactory.setSocketFactory(sf);
/*
* The stub returned by UnicastRemoteObject.exportObject() does
* not participate in DGC, but it does allow us to invoke a method
* on the remote object through RMI. Therefore, we invoke the
* getSelf() method through RMI, which returns an equivalent stub
* that does participate in DGC.
*/
Self stub = (Self) UnicastRemoteObject.exportObject(impl);
Self dgcStub = stub.getSelf();
stub = null; // in case 4114579 has been fixed
/*
* Set the socket factory to cause 3 connections attempts in a row
* to fail before allowing a connection to succeed, expecting the
* client-side DGC implementation to make at least four attempts.
*/
final int FLAKE_FACTOR = 3;
sf.setFlakeFactor(FLAKE_FACTOR);
long deadline = System.currentTimeMillis() + TIMEOUT;
boolean unreferenced;
synchronized (impl) {
while (!(unreferenced = impl.unreferenced)) {
long timeToWait = deadline - System.currentTimeMillis();
if (timeToWait > 0) {
impl.wait(timeToWait);
} else {
break;
}
}
}
if (unreferenced) {
throw new RuntimeException("remote object unreferenced");
}
int createCount = sf.getCreateCount();
if (createCount == 0) {
throw new RuntimeException("test socket factory never used");
} else if (createCount < (FLAKE_FACTOR + 3)) {
/*
* The unreferenced method was not invoked for some reason,
* but the dirty calls were clearly not retried well enough.
*/
throw new RuntimeException(
"test failed because dirty calls not retried enough, " +
"but remote object not unreferenced");
}
System.err.println(
"TEST PASSED: remote object not unreferenced");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + 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 {
UnicastRemoteObject.unexportObject(impl, true);
} catch (Exception e) {
}
}
}
}
......@@ -169,30 +169,30 @@ class TestSF extends RMISocketFactory {
private int createCount = 0;
public synchronized void setFlakeFactor(int newFlakeFactor) {
flakeFactor = newFlakeFactor;
flakeFactor = newFlakeFactor;
}
public synchronized int getCreateCount() {
return createCount;
return createCount;
}
public synchronized Socket createSocket(String host, int port)
throws IOException
throws IOException
{
createCount++;
createCount++;
if (++flakeState > flakeFactor) {
flakeState = 0;
}
if (++flakeState > flakeFactor) {
flakeState = 0;
}
if (flakeState == 0) {
return new Socket(host, port);
} else {
throw new IOException("random network failure");
}
if (flakeState == 0) {
return new Socket(host, port);
} else {
throw new IOException("random network failure");
}
}
public ServerSocket createServerSocket(int port) throws IOException {
return new ServerSocket(port);
return new ServerSocket(port);
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -29,38 +29,38 @@ public final class RetryDirtyCalls_Stub
implements Self
{
private static final long serialVersionUID = 2;
private static java.lang.reflect.Method $method_getSelf_0;
static {
try {
$method_getSelf_0 = Self.class.getMethod("getSelf", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
try {
$method_getSelf_0 = Self.class.getMethod("getSelf", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
}
// constructors
public RetryDirtyCalls_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of getSelf()
public Self getSelf()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
Object $result = ref.invoke(this, $method_getSelf_0, null, 2868857108246021904L);
return ((Self) $result);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
Object $result = ref.invoke(this, $method_getSelf_0, null, 2868857108246021904L);
return ((Self) $result);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
}
/*
/*
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -26,8 +26,8 @@
* @summary rmid and rmiregistry could allow alternate security manager
* @author Laird Dornin
*
* @library ../../testlibrary
* @build StreamPipe TestParams TestLibrary JavaVM
* @library ../../testlibrary
* @build StreamPipe TestParams TestLibrary JavaVM
* @build AltSecurityManager TestSecurityManager
* @run main/othervm AltSecurityManager
*/
......@@ -38,7 +38,7 @@
* that throws a runtime exception in its checkListen method, this
* will cause rmiregistry and rmid to exit early because those
* utilities will be unable to export any remote objects; test fails
* if registry and rmid take too long to exit.
* if registry and rmid take too long to exit.
*/
public class AltSecurityManager implements Runnable {
......@@ -54,74 +54,74 @@ public class AltSecurityManager implements Runnable {
static long TIME_OUT = 15000;
public void run() {
try {
vm = new JavaVM(utilityToStart,
" -Djava.security.manager=TestSecurityManager",
"");
System.err.println("starting " + utilityToStart);
vm.start();
vm.getVM().waitFor();
} catch (Exception e) {
TestLibrary.bomb(e);
}
try {
vm = new JavaVM(utilityToStart,
" -Djava.security.manager=TestSecurityManager",
"");
System.err.println("starting " + utilityToStart);
vm.start();
vm.getVM().waitFor();
} catch (Exception e) {
TestLibrary.bomb(e);
}
}
/**
* Wait to make sure that the registry and rmid exit after
* their security manager is set.
*/
public static void ensureExit(String utility) throws Exception {
utilityToStart = utility;
try {
Thread thread = new Thread(new AltSecurityManager());
System.err.println("expecting RuntimeException for " +
"checkListen in child process");
long start = System.currentTimeMillis();
thread.start();
thread.join(TIME_OUT);
long time = System.currentTimeMillis() - start;
System.err.println("waited " + time + " millis for " +
utilityToStart + " to die");
if (time >= TIME_OUT) {
// dont pollute other tests; increase the likelihood
utilityToStart = utility;
try {
Thread thread = new Thread(new AltSecurityManager());
System.err.println("expecting RuntimeException for " +
"checkListen in child process");
long start = System.currentTimeMillis();
thread.start();
thread.join(TIME_OUT);
long time = System.currentTimeMillis() - start;
System.err.println("waited " + time + " millis for " +
utilityToStart + " to die");
if (time >= TIME_OUT) {
// dont pollute other tests; increase the likelihood
// that rmid will go away if it did not exit already.
if (utility.equals(rmid)) {
RMID.shutdown();
}
TestLibrary.bomb(utilityToStart +
" took too long to die...");
} else {
System.err.println(utilityToStart +
" terminated on time");
}
} finally {
vm.destroy();
vm = null;
}
if (utility.equals(rmid)) {
RMID.shutdown();
}
TestLibrary.bomb(utilityToStart +
" took too long to die...");
} else {
System.err.println(utilityToStart +
" terminated on time");
}
} finally {
vm.destroy();
vm = null;
}
}
public static void main(String[] args) {
try {
System.err.println("\nRegression test for bug 4183202\n");
try {
System.err.println("\nRegression test for bug 4183202\n");
// make sure the registry exits early.
ensureExit(registry);
// make sure the registry exits early.
ensureExit(registry);
// make sure rmid exits early
ensureExit(rmid);
// make sure rmid exits early
ensureExit(rmid);
System.err.println("test passed");
System.err.println("test passed");
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
RMID.removeLog();
}
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
RMID.removeLog();
}
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -28,18 +28,18 @@ public class TestSecurityManager extends SecurityManager {
}
public void checkListen(int port) {
// 4269910: ok, now rmid and the regsitry will *really* go
// away...
//
// rmid and the registry need to listen on sockets so they
// will exit when they try to do so... this is used as a sign
// by the main test process to detect that the proper security
// manager has been installed in the relevant VMs.
//
System.exit(1);
// 4269910: ok, now rmid and the regsitry will *really* go
// away...
//
// rmid and the registry need to listen on sockets so they
// will exit when they try to do so... this is used as a sign
// by the main test process to detect that the proper security
// manager has been installed in the relevant VMs.
//
System.exit(1);
}
public void checkExit(int status) {
// permit check exit for all code
// permit check exit for all code
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -36,48 +36,48 @@ import java.io.ByteArrayOutputStream;
/**
* Make sure that the rmiregistry prints out a correct usage statement
* when run with an incorrect command line; test written to conform to
* new tighter bug fix/regression test guidelines.
* new tighter bug fix/regression test guidelines.
*/
public class CheckUsage {
public static void main(String[] args) {
System.err.println("\nregression test for 4151966\n");
System.err.println("\nregression test for 4151966\n");
JavaVM registryVM = null;
JavaVM registryVM = null;
try {
// make sure the registry exits with a proper usage statement
ByteArrayOutputStream berr = new ByteArrayOutputStream();
// run a VM to start the registry
registryVM = new JavaVM("sun.rmi.registry.RegistryImpl",
"", "foo",
System.out, berr);
System.err.println("starting registry");
registryVM.start();
// wait for registry exit
System.err.println(" registry exited with status: " +
registryVM.getVM().waitFor());
try {
Thread.sleep(7000);
} catch (InterruptedException ie) {
}
String usage = new String(berr.toByteArray());
System.err.println("rmiregistry usage: " + usage);
if (usage.indexOf("-J") < 0) {
TestLibrary.bomb("rmiregistry has incorrect usage statement");
} else {
System.err.println("test passed");
}
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
registryVM.destroy();
registryVM = null;
}
try {
// make sure the registry exits with a proper usage statement
ByteArrayOutputStream berr = new ByteArrayOutputStream();
// run a VM to start the registry
registryVM = new JavaVM("sun.rmi.registry.RegistryImpl",
"", "foo",
System.out, berr);
System.err.println("starting registry");
registryVM.start();
// wait for registry exit
System.err.println(" registry exited with status: " +
registryVM.getVM().waitFor());
try {
Thread.sleep(7000);
} catch (InterruptedException ie) {
}
String usage = new String(berr.toByteArray());
System.err.println("rmiregistry usage: " + usage);
if (usage.indexOf("-J") < 0) {
TestLibrary.bomb("rmiregistry has incorrect usage statement");
} else {
System.err.println("test passed");
}
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
registryVM.destroy();
registryVM = null;
}
}
}
/*
/*
* Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -55,121 +55,121 @@ public class ClassPathCodebase {
public static void main(String[] args) {
System.err.println("\nRegression test for bug 4242317\n");
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
Process rmiregistry = null;
try {
/*
* Install a dummy class in two codebases: one that will be in
* the rmiregistry's CLASSPATH (the "import" codebase) and one
* that will be in the rmiregistry's "java.rmi.server.codebase"
* property (the "export" codebase).
*/
URL importCodebaseURL = TestLibrary.installClassInCodebase(
dummyClassName, importCodebase, false);
URL exportCodebaseURL = TestLibrary.installClassInCodebase(
dummyClassName, exportCodebase, true);
/*
* Spawn an rmiregistry in the "import" codebase directory.
*/
File rmiregistryDir =
new File(System.getProperty("user.dir", "."), importCodebase);
String rmiregistryCommand =
System.getProperty("java.home") + File.separator +
"bin" + File.separator + "rmiregistry";
String cmdarray[] = new String[] {
rmiregistryCommand,
"-J-Denv.class.path=.",
"-J-Djava.rmi.server.codebase=" + exportCodebaseURL,
Integer.toString(TestLibrary.REGISTRY_PORT) };
System.err.println("\nCommand used to spawn rmiregistry process:");
System.err.println("\t" + Arrays.asList(cmdarray).toString());
rmiregistry = Runtime.getRuntime().exec(cmdarray, null, rmiregistryDir);
// pipe rmiregistry output to our output, for debugging failures
StreamPipe.plugTogether(rmiregistry.getInputStream(), System.err);
StreamPipe.plugTogether(rmiregistry.getErrorStream(), System.err);
/*
* Wait for the registry to initialize and be ready to call.
*/
Thread.sleep(REGISTRY_WAIT);
System.err.println();
/*
* Create an instance of the dummy class, finding it from the
* "import" codebase.
*/
ClassLoader loader = URLClassLoader.newInstance(
new URL[] { importCodebaseURL });
Class dummyClass = Class.forName(dummyClassName, false, loader);
Remote dummyObject = (Remote) dummyClass.newInstance();
/*
* Find the registry that we created and bind the
* dummy object to it.
*/
Registry registry = LocateRegistry.getRegistry(
"localhost", TestLibrary.REGISTRY_PORT);
try {
registry.bind(dummyBinding, dummyObject);
System.err.println("Bound dummy object in registry");
} catch (java.rmi.ConnectException e) {
System.err.println("Error: rmiregistry not started in time");
throw e;
} catch (ServerException e) {
if (e.detail instanceof UnmarshalException &&
((UnmarshalException) e.detail).detail instanceof
ClassNotFoundException)
{
System.err.println(
"Error: another registry running on port " +
TestLibrary.REGISTRY_PORT + "?");
}
throw e;
}
/*
* Look up the dummy object from our registry and make sure
* that its class was annotated with the "export" codebase.
*/
Remote dummyLookup = registry.lookup(dummyBinding);
System.err.println(
"Looked up dummy object from registry: " + dummyLookup);
Class dummyLookupClass = dummyLookup.getClass();
String dummyLookupAnnotation =
RMIClassLoader.getClassAnnotation(dummyLookupClass);
System.err.println(
"Class annotation from registry: " + dummyLookupAnnotation);
System.err.println();
if (dummyLookupAnnotation.indexOf(exportCodebase) >= 0) {
System.err.println("TEST PASSED");
} else if (dummyLookupAnnotation.indexOf(importCodebase) >= 0) {
throw new RuntimeException(
"rmiregistry annotated with CLASSPATH element URL");
} else {
throw new RuntimeException(
"rmiregistry used unexpected annotation: \"" +
dummyLookupAnnotation + "\"");
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
} finally {
if (rmiregistry != null) {
rmiregistry.destroy();
}
}
System.err.println("\nRegression test for bug 4242317\n");
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
Process rmiregistry = null;
try {
/*
* Install a dummy class in two codebases: one that will be in
* the rmiregistry's CLASSPATH (the "import" codebase) and one
* that will be in the rmiregistry's "java.rmi.server.codebase"
* property (the "export" codebase).
*/
URL importCodebaseURL = TestLibrary.installClassInCodebase(
dummyClassName, importCodebase, false);
URL exportCodebaseURL = TestLibrary.installClassInCodebase(
dummyClassName, exportCodebase, true);
/*
* Spawn an rmiregistry in the "import" codebase directory.
*/
File rmiregistryDir =
new File(System.getProperty("user.dir", "."), importCodebase);
String rmiregistryCommand =
System.getProperty("java.home") + File.separator +
"bin" + File.separator + "rmiregistry";
String cmdarray[] = new String[] {
rmiregistryCommand,
"-J-Denv.class.path=.",
"-J-Djava.rmi.server.codebase=" + exportCodebaseURL,
Integer.toString(TestLibrary.REGISTRY_PORT) };
System.err.println("\nCommand used to spawn rmiregistry process:");
System.err.println("\t" + Arrays.asList(cmdarray).toString());
rmiregistry = Runtime.getRuntime().exec(cmdarray, null, rmiregistryDir);
// pipe rmiregistry output to our output, for debugging failures
StreamPipe.plugTogether(rmiregistry.getInputStream(), System.err);
StreamPipe.plugTogether(rmiregistry.getErrorStream(), System.err);
/*
* Wait for the registry to initialize and be ready to call.
*/
Thread.sleep(REGISTRY_WAIT);
System.err.println();
/*
* Create an instance of the dummy class, finding it from the
* "import" codebase.
*/
ClassLoader loader = URLClassLoader.newInstance(
new URL[] { importCodebaseURL });
Class dummyClass = Class.forName(dummyClassName, false, loader);
Remote dummyObject = (Remote) dummyClass.newInstance();
/*
* Find the registry that we created and bind the
* dummy object to it.
*/
Registry registry = LocateRegistry.getRegistry(
"localhost", TestLibrary.REGISTRY_PORT);
try {
registry.bind(dummyBinding, dummyObject);
System.err.println("Bound dummy object in registry");
} catch (java.rmi.ConnectException e) {
System.err.println("Error: rmiregistry not started in time");
throw e;
} catch (ServerException e) {
if (e.detail instanceof UnmarshalException &&
((UnmarshalException) e.detail).detail instanceof
ClassNotFoundException)
{
System.err.println(
"Error: another registry running on port " +
TestLibrary.REGISTRY_PORT + "?");
}
throw e;
}
/*
* Look up the dummy object from our registry and make sure
* that its class was annotated with the "export" codebase.
*/
Remote dummyLookup = registry.lookup(dummyBinding);
System.err.println(
"Looked up dummy object from registry: " + dummyLookup);
Class dummyLookupClass = dummyLookup.getClass();
String dummyLookupAnnotation =
RMIClassLoader.getClassAnnotation(dummyLookupClass);
System.err.println(
"Class annotation from registry: " + dummyLookupAnnotation);
System.err.println();
if (dummyLookupAnnotation.indexOf(exportCodebase) >= 0) {
System.err.println("TEST PASSED");
} else if (dummyLookupAnnotation.indexOf(importCodebase) >= 0) {
throw new RuntimeException(
"rmiregistry annotated with CLASSPATH element URL");
} else {
throw new RuntimeException(
"rmiregistry used unexpected annotation: \"" +
dummyLookupAnnotation + "\"");
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
} finally {
if (rmiregistry != null) {
rmiregistry.destroy();
}
}
}
}
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -36,12 +36,12 @@ public class Dummy
}
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
throws java.io.IOException
{
}
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException, ClassNotFoundException
throws java.io.IOException, ClassNotFoundException
{
}
}
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -32,12 +32,12 @@ import java.rmi.server.RemoteObject;
public class EmptyName {
public static void main(String[] args) throws Exception {
Registry impl = LocateRegistry.createRegistry(0);
Registry stub = (Registry) RemoteObject.toStub(impl);
stub.bind("", stub);
stub.lookup("");
stub.rebind("", stub);
stub.lookup("");
stub.unbind("");
Registry impl = LocateRegistry.createRegistry(0);
Registry stub = (Registry) RemoteObject.toStub(impl);
stub.bind("", stub);
stub.lookup("");
stub.rebind("", stub);
stub.lookup("");
stub.unbind("");
}
}
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -62,157 +62,157 @@ public class InterfaceHash {
private static final String NAME = "WMM";
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 4472769");
System.err.println(
"\n=== verifying that J2SE registry's skeleton uses" +
"\ncorrect interface hash and operation numbers:");
Registry testImpl = LocateRegistry.createRegistry(PORT);
System.err.println("created test registry on port " + PORT);
RemoteRef ref = new UnicastRef(
new LiveRef(new ObjID(ObjID.REGISTRY_ID),
new TCPEndpoint("", PORT), false));
Registry referenceStub = new ReferenceRegistryStub(ref);
System.err.println("created reference registry stub: " +
referenceStub);
referenceStub.bind(NAME, referenceStub);
System.err.println("bound name \"" + NAME + "\" in registry");
String[] list = referenceStub.list();
System.err.println("list of registry contents: " +
Arrays.asList(list));
if (list.length != 1 || !list[0].equals(NAME)) {
throw new RuntimeException(
"TEST FAILED: unexpected list contents");
}
Registry result = (Registry) referenceStub.lookup(NAME);
System.err.println("lookup of name \"" + NAME + "\" returned: " +
result);
if (!result.equals(referenceStub)) {
throw new RuntimeException(
"TEST FAILED: unexpected lookup result");
}
referenceStub.rebind(NAME, referenceStub);
referenceStub.unbind(NAME);
System.err.println("unbound name \"" + NAME + "\"");
list = referenceStub.list();
System.err.println("list of registry contents: " +
Arrays.asList(list));
if (list.length != 0) {
throw new RuntimeException("TEST FAILED: list not empty");
}
System.err.println("\n=== verifying that J2SE registry's stub uses" +
"correct interface hash:");
class FakeRemoteRef implements RemoteRef {
long hash;
int opnum;
public RemoteCall newCall(RemoteObject obj, Operation[] op,
int opnum, long hash)
{
this.hash = hash;
this.opnum = opnum;
throw new UnsupportedOperationException();
}
public void invoke(RemoteCall call) { }
public void done(RemoteCall call) { }
public Object invoke(Remote obj, Method method,
Object[] args, long hash)
{
throw new UnsupportedOperationException();
}
public String getRefClass(java.io.ObjectOutput out) {
return "FakeRemoteRef";
}
public int remoteHashCode() { return 1013; }
public boolean remoteEquals(RemoteRef obj) { return false; }
public String remoteToString() { return "FakeRemoteRef"; }
public void writeExternal(java.io.ObjectOutput out) { }
public void readExternal(java.io.ObjectInput in) { }
}
FakeRemoteRef f = new FakeRemoteRef();
Registry testRegistry = LocateRegistry.getRegistry(PORT);
System.err.println("created original test registry stub: " +
testRegistry);
Class stubClass = testRegistry.getClass();
System.err.println("test registry stub class: " + stubClass);
Constructor cons = stubClass.getConstructor(
new Class[] { RemoteRef.class });
Registry testStub = (Registry) cons.newInstance(
new Object[] { f });
System.err.println("created new instrumented test registry stub: " +
testStub);
System.err.println("invoking bind:");
try {
testStub.bind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 0) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking list:");
try {
testStub.list();
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 1) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking lookup:");
try {
testStub.lookup(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 2) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking rebind:");
try {
testStub.rebind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 3) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking unbind:");
try {
testStub.unbind(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 4) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("TEST PASSED");
System.err.println("\nRegression test for bug 4472769");
System.err.println(
"\n=== verifying that J2SE registry's skeleton uses" +
"\ncorrect interface hash and operation numbers:");
Registry testImpl = LocateRegistry.createRegistry(PORT);
System.err.println("created test registry on port " + PORT);
RemoteRef ref = new UnicastRef(
new LiveRef(new ObjID(ObjID.REGISTRY_ID),
new TCPEndpoint("", PORT), false));
Registry referenceStub = new ReferenceRegistryStub(ref);
System.err.println("created reference registry stub: " +
referenceStub);
referenceStub.bind(NAME, referenceStub);
System.err.println("bound name \"" + NAME + "\" in registry");
String[] list = referenceStub.list();
System.err.println("list of registry contents: " +
Arrays.asList(list));
if (list.length != 1 || !list[0].equals(NAME)) {
throw new RuntimeException(
"TEST FAILED: unexpected list contents");
}
Registry result = (Registry) referenceStub.lookup(NAME);
System.err.println("lookup of name \"" + NAME + "\" returned: " +
result);
if (!result.equals(referenceStub)) {
throw new RuntimeException(
"TEST FAILED: unexpected lookup result");
}
referenceStub.rebind(NAME, referenceStub);
referenceStub.unbind(NAME);
System.err.println("unbound name \"" + NAME + "\"");
list = referenceStub.list();
System.err.println("list of registry contents: " +
Arrays.asList(list));
if (list.length != 0) {
throw new RuntimeException("TEST FAILED: list not empty");
}
System.err.println("\n=== verifying that J2SE registry's stub uses" +
"correct interface hash:");
class FakeRemoteRef implements RemoteRef {
long hash;
int opnum;
public RemoteCall newCall(RemoteObject obj, Operation[] op,
int opnum, long hash)
{
this.hash = hash;
this.opnum = opnum;
throw new UnsupportedOperationException();
}
public void invoke(RemoteCall call) { }
public void done(RemoteCall call) { }
public Object invoke(Remote obj, Method method,
Object[] args, long hash)
{
throw new UnsupportedOperationException();
}
public String getRefClass(java.io.ObjectOutput out) {
return "FakeRemoteRef";
}
public int remoteHashCode() { return 1013; }
public boolean remoteEquals(RemoteRef obj) { return false; }
public String remoteToString() { return "FakeRemoteRef"; }
public void writeExternal(java.io.ObjectOutput out) { }
public void readExternal(java.io.ObjectInput in) { }
}
FakeRemoteRef f = new FakeRemoteRef();
Registry testRegistry = LocateRegistry.getRegistry(PORT);
System.err.println("created original test registry stub: " +
testRegistry);
Class stubClass = testRegistry.getClass();
System.err.println("test registry stub class: " + stubClass);
Constructor cons = stubClass.getConstructor(
new Class[] { RemoteRef.class });
Registry testStub = (Registry) cons.newInstance(
new Object[] { f });
System.err.println("created new instrumented test registry stub: " +
testStub);
System.err.println("invoking bind:");
try {
testStub.bind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 0) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking list:");
try {
testStub.list();
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 1) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking lookup:");
try {
testStub.lookup(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 2) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking rebind:");
try {
testStub.rebind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 3) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking unbind:");
try {
testStub.unbind(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 4) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("TEST PASSED");
}
}
/*
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -41,49 +41,49 @@ public class MultipleRegistries implements RemoteInterface {
private static final String NAME = "MultipleRegistries";
public Object passObject(Object obj) {
return obj;
return obj;
}
public static void main(String[] args) throws Exception {
RemoteInterface server = null;
RemoteInterface proxy = null;
try {
System.err.println("export object");
server = new MultipleRegistries();
proxy =
(RemoteInterface) UnicastRemoteObject.exportObject(server, 0);
System.err.println("proxy = " + proxy);
System.err.println("export registries");
Registry registryImpl1 = LocateRegistry.createRegistry(2030);
Registry registryImpl2 = LocateRegistry.createRegistry(2040);
System.err.println("bind remote object in registries");
Registry registry1 = LocateRegistry.getRegistry(2030);
Registry registry2 = LocateRegistry.getRegistry(2040);
registry1.bind(NAME, proxy);
registry2.bind(NAME, proxy);
System.err.println("lookup remote object in registries");
RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME);
RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME);
System.err.println("invoke methods on remote objects");
remote1.passObject(remote1);
remote2.passObject(remote2);
System.err.println("TEST PASSED");
} finally {
if (proxy != null) {
UnicastRemoteObject.unexportObject(server, true);
}
}
RemoteInterface server = null;
RemoteInterface proxy = null;
try {
System.err.println("export object");
server = new MultipleRegistries();
proxy =
(RemoteInterface) UnicastRemoteObject.exportObject(server, 0);
System.err.println("proxy = " + proxy);
System.err.println("export registries");
Registry registryImpl1 = LocateRegistry.createRegistry(2030);
Registry registryImpl2 = LocateRegistry.createRegistry(2040);
System.err.println("bind remote object in registries");
Registry registry1 = LocateRegistry.getRegistry(2030);
Registry registry2 = LocateRegistry.getRegistry(2040);
registry1.bind(NAME, proxy);
registry2.bind(NAME, proxy);
System.err.println("lookup remote object in registries");
RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME);
RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME);
System.err.println("invoke methods on remote objects");
remote1.passObject(remote1);
remote2.passObject(remote2);
System.err.println("TEST PASSED");
} finally {
if (proxy != null) {
UnicastRemoteObject.unexportObject(server, true);
}
}
}
}
......
/*
/*
* Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
......@@ -33,7 +33,7 @@ import java.rmi.RemoteException;
/**
* The RMI benchmark server is a simple compute-engine-like server which allows
* client benchmarks to create/export and unexport objects off of the server,
* client benchmarks to create/export and unexport objects off of the server,
* or run arbitrary tasks.
*/
public interface BenchServer extends Remote {
......@@ -41,41 +41,40 @@ public interface BenchServer extends Remote {
* Interface used for creating server-side remote objects.
*/
public interface RemoteObjectFactory extends Serializable {
Remote create() throws RemoteException;
Remote create() throws RemoteException;
}
/**
* Interface used for server-side tasks.
*/
public interface Task extends Serializable {
Object execute() throws Exception;
Object execute() throws Exception;
}
/**
* Uses the given remote object factory to create a new remote object on
* Uses the given remote object factory to create a new remote object on
* the server side.
*/
Remote create(RemoteObjectFactory factory) throws RemoteException;
/**
* Unexports the specified remote object. Returns true if successful,
* Unexports the specified remote object. Returns true if successful,
* false otherwise.
*/
boolean unexport(Remote obj, boolean force) throws RemoteException;
/**
* Execute given task.
*/
Object execute(Task task) throws Exception;
/**
* Invoke the garbage collector.
*/
void gc() throws RemoteException;
/**
* Terminate the server.
*/
void terminate(int delay) throws RemoteException;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册