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