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

Just missed a few files being normalized in rev 0.

Reviewed-by: xdono
This commit is contained in:
Kelly O'Hair 2008-04-01 15:41:23 -07:00
parent 3d9e4854d0
commit de514b4b6e
189 changed files with 8229 additions and 8318 deletions

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -49,116 +49,116 @@ import java.util.Properties;
public class CreatePrivateActivatable
{
private static class PrivateActivatable extends Activatable
implements ActivateMe, Runnable
implements ActivateMe, Runnable
{
private PrivateActivatable(ActivationID id, MarshalledObject obj)
throws ActivationException, RemoteException
{
super(id, 0);
}
private PrivateActivatable(ActivationID id, MarshalledObject obj)
throws ActivationException, RemoteException
{
super(id, 0);
}
public void ping()
{}
public void ping()
{}
/**
* Spawns a thread to deactivate the object.
*/
public void shutdown() throws Exception
{
(new Thread(this, "CreatePrivateActivatable$PrivateActivatable")).start();
}
/**
* Spawns a thread to deactivate the object.
*/
public void shutdown() throws Exception
{
(new Thread(this, "CreatePrivateActivatable$PrivateActivatable")).start();
}
/**
* Thread to deactivate object. First attempts to make object
* inactive (via the inactive method). If that fails (the
* object may still have pending/executing calls), then
* unexport the object forcibly.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
}
/**
* Thread to deactivate object. First attempts to make object
* inactive (via the inactive method). If that fails (the
* object may still have pending/executing calls), then
* unexport the object forcibly.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
}
}
public static void main(String[] args) {
/*
* The following line is required with the JDK 1.2 VM so that the
* VM can exit gracefully when this test completes. Otherwise, the
* conservative garbage collector will find a handle to the server
* object on the native stack and not clear the weak reference to
* it in the RMI runtime's object table.
*/
Object dummy = new Object();
RMID rmid = null;
ActivateMe obj;
/*
* The following line is required with the JDK 1.2 VM so that the
* VM can exit gracefully when this test completes. Otherwise, the
* conservative garbage collector will find a handle to the server
* object on the native stack and not clear the weak reference to
* it in the RMI runtime's object table.
*/
Object dummy = new Object();
RMID rmid = null;
ActivateMe obj;
System.err.println("\nRegression test for bug 4164971\n");
System.err.println("java.security.policy = " +
System.getProperty("java.security.policy", "no policy"));
System.err.println("\nRegression test for bug 4164971\n");
System.err.println("java.security.policy = " +
System.getProperty("java.security.policy", "no policy"));
CreatePrivateActivatable server;
try {
TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager);
CreatePrivateActivatable server;
try {
TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager);
// start an rmid.
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
/*
* Activate an object by registering its object
* descriptor and invoking a method on the
* stub returned from the register call.
*/
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(groupDesc);
// start an rmid.
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
System.err.println("Creating descriptor");
ActivationDesc desc =
new ActivationDesc(groupID,
"CreatePrivateActivatable$PrivateActivatable",
null, null);
System.err.println("Registering descriptor");
obj = (ActivateMe) Activatable.register(desc);
/*
* Loop a bunch of times to force activator to
* spawn VMs (groups)
*/
System.err.println("Activate object via method call");
obj.ping();
/*
* Clean up object too.
*/
System.err.println("Deactivate object via method call");
obj.shutdown();
System.err.println("\nsuccess: CreatePrivateActivatable test passed ");
} catch (Exception e) {
if (e instanceof java.security.PrivilegedActionException) {
e = ((java.security.PrivilegedActionException)e).getException();
}
TestLibrary.bomb("\nfailure: unexpected exception " +
e.getClass().getName(), e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
obj = null;
}
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
/*
* Activate an object by registering its object
* descriptor and invoking a method on the
* stub returned from the register call.
*/
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(groupDesc);
System.err.println("Creating descriptor");
ActivationDesc desc =
new ActivationDesc(groupID,
"CreatePrivateActivatable$PrivateActivatable",
null, null);
System.err.println("Registering descriptor");
obj = (ActivateMe) Activatable.register(desc);
/*
* Loop a bunch of times to force activator to
* spawn VMs (groups)
*/
System.err.println("Activate object via method call");
obj.ping();
/*
* Clean up object too.
*/
System.err.println("Deactivate object via method call");
obj.shutdown();
System.err.println("\nsuccess: CreatePrivateActivatable test passed ");
} catch (Exception e) {
if (e instanceof java.security.PrivilegedActionException) {
e = ((java.security.PrivilegedActionException)e).getException();
}
TestLibrary.bomb("\nfailure: unexpected exception " +
e.getClass().getName(), e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
obj = null;
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -24,10 +24,10 @@
/* @test
* @bug 4097135
* @summary Need a specific subtype of RemoteException for activation failure.
* If activation fails to happen during a call to a remote object,
* then the call should end in an ActivateFailedException. In this
* test, the actual "activatable" remote object fails to activate
* since its * "activation" constructor throws an exception.
* If activation fails to happen during a call to a remote object,
* then the call should end in an ActivateFailedException. In this
* test, the actual "activatable" remote object fails to activate
* since its * "activation" constructor throws an exception.
* @author Ann Wollrath
*
* @library ../../../testlibrary
@ -46,128 +46,127 @@ import java.io.*;
import java.util.Properties;
public class ActivateFails
extends Activatable
implements ActivateMe
extends Activatable
implements ActivateMe
{
public ActivateFails(ActivationID id, MarshalledObject obj)
throws ActivationException, RemoteException
throws ActivationException, RemoteException
{
super(id, 0);
super(id, 0);
boolean refuseToActivate = false;
try {
refuseToActivate = ((Boolean)obj.get()).booleanValue();
} catch (Exception impossible) {
}
if (refuseToActivate)
throw new RemoteException("object refuses to activate");
boolean refuseToActivate = false;
try {
refuseToActivate = ((Boolean)obj.get()).booleanValue();
} catch (Exception impossible) {
}
if (refuseToActivate)
throw new RemoteException("object refuses to activate");
}
public void ping()
{}
/**
* Spawns a thread to deactivate the object.
*/
public ShutdownThread shutdown() throws Exception
{
ShutdownThread shutdownThread = new ShutdownThread(this, getID());
shutdownThread.start();
return(shutdownThread);
ShutdownThread shutdownThread = new ShutdownThread(this, getID());
shutdownThread.start();
return(shutdownThread);
}
public static void main(String[] args)
public static void main(String[] args)
{
RMID rmid = null;
ActivateMe obj1, obj2;
ShutdownThread shutdownThread;
System.err.println("\nRegression test for bug 4097135\n");
try {
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
RMID rmid = null;
ActivateMe obj1, obj2;
ShutdownThread shutdownThread;
/*
* First run "rmid" and wait for it to start up.
*/
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
System.err.println("\nRegression test for bug 4097135\n");
try {
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
/*
* First run "rmid" and wait for it to start up.
*/
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/*
* Create activation descriptor...
*/
System.err.println("creating activation descriptor...");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
ActivationDesc desc1 =
new ActivationDesc(groupID, "ActivateFails",
null,
new MarshalledObject(new Boolean(true)));
ActivationDesc desc2 =
new ActivationDesc(groupID, "ActivateFails",
null,
new MarshalledObject(new Boolean(false)));
/*
* Register activation descriptor and make a call on
* the stub. Activation should fail with an
* ActivateFailedException. If not, report an
* error as a RuntimeException
*/
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
System.err.println("registering activation descriptor...");
obj1 = (ActivateMe)Activatable.register(desc1);
obj2 = (ActivateMe)Activatable.register(desc2);
/*
* Create activation descriptor...
*/
System.err.println("creating activation descriptor...");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
System.err.println("invoking method on activatable object...");
try {
obj1.ping();
} catch (ActivateFailedException e) {
ActivationDesc desc1 =
new ActivationDesc(groupID, "ActivateFails",
null,
new MarshalledObject(new Boolean(true)));
/*
* This is what is expected so exit with status 0
*/
System.err.println("\nsuccess: ActivateFailedException " +
"generated");
e.getMessage();
}
ActivationDesc desc2 =
new ActivationDesc(groupID, "ActivateFails",
null,
new MarshalledObject(new Boolean(false)));
/*
* Register activation descriptor and make a call on
* the stub. Activation should fail with an
* ActivateFailedException. If not, report an
* error as a RuntimeException
*/
obj2.ping();
shutdownThread = obj2.shutdown();
System.err.println("registering activation descriptor...");
obj1 = (ActivateMe)Activatable.register(desc1);
obj2 = (ActivateMe)Activatable.register(desc2);
// wait for shutdown to work
Thread.sleep(2000);
System.err.println("invoking method on activatable object...");
try {
obj1.ping();
shutdownThread = null;
} catch (Exception e) {
/*
* Test failed; unexpected exception generated.
*/
TestLibrary.bomb("\nfailure: unexpected exception " +
e.getClass().getName() + ": " + e.getMessage(), e);
} finally {
obj1 = obj2 = null;
ActivationLibrary.rmidCleanup(rmid);
}
} catch (ActivateFailedException e) {
/*
* This is what is expected so exit with status 0
*/
System.err.println("\nsuccess: ActivateFailedException " +
"generated");
e.getMessage();
}
obj2.ping();
shutdownThread = obj2.shutdown();
// wait for shutdown to work
Thread.sleep(2000);
shutdownThread = null;
} catch (Exception e) {
/*
* Test failed; unexpected exception generated.
*/
TestLibrary.bomb("\nfailure: unexpected exception " +
e.getClass().getName() + ": " + e.getMessage(), e);
} finally {
obj1 = obj2 = null;
ActivationLibrary.rmidCleanup(rmid);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,88 +29,88 @@ public final class ActivateFails_Stub
implements ActivateMe, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("void ping()"),
new java.rmi.server.Operation("ShutdownThread shutdown()")
new java.rmi.server.Operation("void ping()"),
new java.rmi.server.Operation("ShutdownThread shutdown()")
};
private static final long interfaceHash = -6632667923281093978L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_ping_0;
private static java.lang.reflect.Method $method_shutdown_1;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_ping_0 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_1 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_ping_0 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_1 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public ActivateFails_Stub() {
super();
super();
}
public ActivateFails_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of ping()
public void ping()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
ref.invoke(this, $method_ping_0, null, 5866401369815527589L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
ref.invoke(this, $method_ping_0, null, 5866401369815527589L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public ShutdownThread shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_shutdown_1, null, -3616843253114182719L);
return ((ShutdownThread) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ShutdownThread $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (ShutdownThread) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_shutdown_1, null, -3616843253114182719L);
return ((ShutdownThread) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ShutdownThread $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (ShutdownThread) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -31,21 +31,20 @@ public class ShutdownThread extends Thread implements Serializable {
ActivationID activationID = null;
public ShutdownThread(Remote remoteObject, ActivationID activationID) {
remoteObject = remoteObject;
activationID = activationID;
remoteObject = remoteObject;
activationID = activationID;
}
public void run() {
try {
try {
Activatable.unexportObject(remoteObject, true);
Activatable.inactive(activationID);
Activatable.unexportObject(remoteObject, true);
Activatable.inactive(activationID);
} catch (Exception e) {
}
} catch (Exception e) {
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -23,7 +23,7 @@
/*
* @test
* @bug 4510355
* @bug 4510355
* @summary ActivationGroup implementations cannot be downloaded by default;
* Creates a custom activation group without setting a security manager
* in activation group's descriptor. The custom activation group
@ -49,28 +49,28 @@ import java.util.Vector;
import java.util.Properties;
public class DownloadActivationGroup
implements Ping, Runnable
implements Ping, Runnable
{
private ActivationID id;
public DownloadActivationGroup(ActivationID id, MarshalledObject mobj)
throws ActivationException, RemoteException
throws ActivationException, RemoteException
{
this.id = id;
Activatable.exportObject(this, id, 0);
System.err.println("object activated in group");
this.id = id;
Activatable.exportObject(this, id, 0);
System.err.println("object activated in group");
}
public DownloadActivationGroup() throws RemoteException {
UnicastRemoteObject.exportObject(this, 0);
UnicastRemoteObject.exportObject(this, 0);
}
/**
* Used to activate object.
*/
public void ping() {
System.err.println("received ping");
System.err.println("received ping");
}
/**
@ -79,87 +79,87 @@ public class DownloadActivationGroup
*/
public void shutdown() throws Exception
{
(new Thread(this,"DownloadActivationGroup")).start();
(new Thread(this,"DownloadActivationGroup")).start();
}
/**
* Thread to deactivate object.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
ActivationLibrary.deactivate(this, getID());
}
public ActivationID getID() {
return id;
return id;
}
public static void main(String[] args) {
RMID rmid = null;
System.out.println("\nRegression test for bug 4510355\n");
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
RMID rmid = null;
/*
* Install group class file in codebase.
*/
System.err.println("install class file in codebase");
URL groupURL = TestLibrary.installClassInCodebase(
"MyActivationGroupImpl", "group");
System.err.println("class file installed");
System.out.println("\nRegression test for bug 4510355\n");
/*
* Start rmid.
*/
RMID.removeLog();
rmid = RMID.createRMID();
String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
rmid.addOptions(new String[] { execPolicyOption });
rmid.start();
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
/*
* Create and register descriptors for custom group and an
* activatable object in that group.
*/
System.err.println("register group");
Properties p = new Properties();
p.put("java.security.policy", TestParams.defaultGroupPolicy);
ActivationGroupDesc groupDesc =
new ActivationGroupDesc("MyActivationGroupImpl",
groupURL.toExternalForm(),
null, p, null);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
System.err.println("register activatable object");
ActivationDesc desc =
new ActivationDesc(groupID, "DownloadActivationGroup",
null, null);
Ping obj = (Ping) Activatable.register(desc);
/*
* Install group class file in codebase.
*/
System.err.println("install class file in codebase");
URL groupURL = TestLibrary.installClassInCodebase(
"MyActivationGroupImpl", "group");
System.err.println("class file installed");
/*
* Start group (by calling ping).
*/
System.err.println(
"ping object (forces download of group's class)");
obj.ping();
System.err.println(
"TEST PASSED: group's class downloaded successfully");
System.err.println("shutdown object");
obj.shutdown();
System.err.println("TEST PASSED");
/*
* Start rmid.
*/
RMID.removeLog();
rmid = RMID.createRMID();
String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
rmid.addOptions(new String[] { execPolicyOption });
rmid.start();
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
}
/*
* Create and register descriptors for custom group and an
* activatable object in that group.
*/
System.err.println("register group");
Properties p = new Properties();
p.put("java.security.policy", TestParams.defaultGroupPolicy);
ActivationGroupDesc groupDesc =
new ActivationGroupDesc("MyActivationGroupImpl",
groupURL.toExternalForm(),
null, p, null);
ActivationGroupID groupID =
ActivationGroup.getSystem().registerGroup(groupDesc);
System.err.println("register activatable object");
ActivationDesc desc =
new ActivationDesc(groupID, "DownloadActivationGroup",
null, null);
Ping obj = (Ping) Activatable.register(desc);
/*
* Start group (by calling ping).
*/
System.err.println(
"ping object (forces download of group's class)");
obj.ping();
System.err.println(
"TEST PASSED: group's class downloaded successfully");
System.err.println("shutdown object");
obj.shutdown();
System.err.println("TEST PASSED");
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,46 +29,46 @@ public final class DownloadActivationGroup_Stub
implements Ping
{
private static final long serialVersionUID = 2;
private static java.lang.reflect.Method $method_ping_0;
private static java.lang.reflect.Method $method_shutdown_1;
static {
try {
$method_ping_0 = Ping.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_1 = Ping.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
try {
$method_ping_0 = Ping.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_1 = Ping.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
}
// constructors
public DownloadActivationGroup_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of ping()
public void ping()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
ref.invoke(this, $method_ping_0, null, 5866401369815527589L);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
ref.invoke(this, $method_ping_0, null, 5866401369815527589L);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public void shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
ref.invoke(this, $method_shutdown_1, null, -7207851917985848402L);
ref.invoke(this, $method_shutdown_1, null, -7207851917985848402L);
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -27,11 +27,11 @@ import java.rmi.activation.*;
public class MyActivationGroupImpl extends ActivationGroupImpl {
public MyActivationGroupImpl(ActivationGroupID id, MarshalledObject mobj)
throws RemoteException, ActivationException
throws RemoteException, ActivationException
{
super(id, mobj);
System.err.println("custom group implementation created");
super(id, mobj);
System.err.println("custom group implementation created");
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -42,19 +42,19 @@ import java.rmi.activation.*;
*/
public class CheckDefaultGroupName {
public static void main(String[] args) {
System.out.println("\n\nRegression test for, 4252236\n\n");
System.out.println("\n\nRegression test for, 4252236\n\n");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(null, null);
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(null, null);
String className = groupDesc.getClassName();
if (className != null) {
TestLibrary.bomb("ActivationGroupDesc had incorrect default" +
" group implementation class name: " + className);
} else {
System.err.println("test passed, had correct default group" +
" implementation class name: " + className +
"\n\n");
}
String className = groupDesc.getClassName();
if (className != null) {
TestLibrary.bomb("ActivationGroupDesc had incorrect default" +
" group implementation class name: " + className);
} else {
System.err.println("test passed, had correct default group" +
" implementation class name: " + className +
"\n\n");
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -49,81 +49,81 @@ import java.rmi.activation.ActivationSystem;
import java.rmi.server.UnicastRemoteObject;
public class IdempotentActiveGroup {
public static void main(String[] args) {
System.err.println("\nRegression test for bug 4720528\n");
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
RMID rmid = null;
ActivationInstantiator inst1 = null;
ActivationInstantiator inst2 = null;
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
System.err.println("\nRegression test for bug 4720528\n");
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);
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
RMID rmid = null;
ActivationInstantiator inst1 = null;
ActivationInstantiator inst2 = null;
try {
System.err.println("Invoke activeGroup with inst2");
system.activeGroup(groupID, inst2, 0);
throw new RuntimeException(
"TEST FAILED: activeGroup with unequal groups succeeded!");
} catch (ActivationException expected) {
System.err.println("Caught expected ActivationException");
System.err.println("Test 1 (of 2) passed");
}
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
try {
System.err.println("Invoke activeGroup with inst1");
system.activeGroup(groupID, inst1, 0);
System.err.println("activeGroup call succeeded");
System.err.println("Test 2 (of 2) passed");
} catch (ActivationException unexpected) {
throw new RuntimeException(
"TEST FAILED: activeGroup with equal groups failed!",
unexpected);
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
try {
if (inst1 != null) {
UnicastRemoteObject.unexportObject(inst1, true);
}
if (inst2 != null) {
UnicastRemoteObject.unexportObject(inst2, true);
}
} catch (NoSuchObjectException unexpected) {
throw new AssertionError(unexpected);
}
ActivationLibrary.rmidCleanup(rmid);
}
System.err.println("Create group descriptor");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(null, null);
ActivationSystem system = ActivationGroup.getSystem();
System.err.println("Register group descriptor");
ActivationGroupID groupID = system.registerGroup(groupDesc);
inst1 = new FakeInstantiator();
inst2 = new FakeInstantiator();
System.err.println("Invoke activeGroup with inst1");
system.activeGroup(groupID, inst1, 0);
try {
System.err.println("Invoke activeGroup with inst2");
system.activeGroup(groupID, inst2, 0);
throw new RuntimeException(
"TEST FAILED: activeGroup with unequal groups succeeded!");
} catch (ActivationException expected) {
System.err.println("Caught expected ActivationException");
System.err.println("Test 1 (of 2) passed");
}
try {
System.err.println("Invoke activeGroup with inst1");
system.activeGroup(groupID, inst1, 0);
System.err.println("activeGroup call succeeded");
System.err.println("Test 2 (of 2) passed");
} catch (ActivationException unexpected) {
throw new RuntimeException(
"TEST FAILED: activeGroup with equal groups failed!",
unexpected);
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
try {
if (inst1 != null) {
UnicastRemoteObject.unexportObject(inst1, true);
}
if (inst2 != null) {
UnicastRemoteObject.unexportObject(inst2, true);
}
} catch (NoSuchObjectException unexpected) {
throw new AssertionError(unexpected);
}
ActivationLibrary.rmidCleanup(rmid);
}
}
private static class FakeInstantiator
extends UnicastRemoteObject
implements ActivationInstantiator
extends UnicastRemoteObject
implements ActivationInstantiator
{
FakeInstantiator() throws RemoteException {}
FakeInstantiator() throws RemoteException {}
public MarshalledObject newInstance(ActivationID id,
ActivationDesc desc)
{
throw new AssertionError();
}
public MarshalledObject newInstance(ActivationID id,
ActivationDesc desc)
{
throw new AssertionError();
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -25,7 +25,7 @@
* @bug 4127754
*
* @summary synopsis: need to modify registered ActivationDesc and
* ActivationGroupDesc
* ActivationGroupDesc
* @author Ann Wollrath
*
* @library ../../../testlibrary
@ -43,7 +43,7 @@ import java.rmi.registry.*;
import java.util.*;
public class ModifyDescriptor
implements ActivateMe, Runnable
implements ActivateMe, Runnable
{
private ActivationID id;
@ -54,28 +54,28 @@ public class ModifyDescriptor
public ModifyDescriptor(ActivationID id, MarshalledObject mobj)
throws ActivationException, RemoteException
throws ActivationException, RemoteException
{
this.id = id;
Activatable.exportObject(this, id, 0);
try {
message = (String) mobj.get();
} catch (Exception e) {
System.err.println("unable to get message from marshalled object");
}
this.id = id;
Activatable.exportObject(this, id, 0);
try {
message = (String) mobj.get();
} catch (Exception e) {
System.err.println("unable to get message from marshalled object");
}
}
public String getMessage() {
return message;
return message;
}
public String getProperty(String name) {
return TestLibrary.getProperty(name, null);
return TestLibrary.getProperty(name, null);
}
public ActivationID getID() {
return id;
return id;
}
/**
@ -83,7 +83,7 @@ public class ModifyDescriptor
*/
public void shutdown() throws Exception
{
(new Thread(this,"ModifyDescriptor")).start();
(new Thread(this,"ModifyDescriptor")).start();
}
/**
@ -93,165 +93,165 @@ public class ModifyDescriptor
* unexport the object forcibly.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
ActivationLibrary.deactivate(this, getID());
}
public static void main(String[] args) {
System.out.println("\nRegression test for bug 4127754\n");
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
System.out.println("\nRegression test for bug 4127754\n");
RMID rmid = null;
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
/*
* Create and register a group and activatable object
*/
RMID rmid = null;
System.err.println("Creating group descriptor");
Properties props = new Properties();
props.put("java.security.policy",
TestParams.defaultGroupPolicy);
props.put("java.security.manager",
TestParams.defaultSecurityManager);
props.put("test.message", MESSAGE1);
ActivationGroupDesc initialGroupDesc =
new ActivationGroupDesc(props, null);
System.err.println("Registering group");
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(initialGroupDesc);
System.err.println("Creating descriptor");
ActivationDesc initialDesc =
new ActivationDesc(groupID, "ModifyDescriptor", null,
new MarshalledObject(MESSAGE1), false);
System.err.println("Registering descriptor");
ActivateMe obj = (ActivateMe) Activatable.register(initialDesc);
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
/*
* Ping object and verify that MarshalledObject is okay.
*/
System.err.println("Ping object");
String message1 = obj.getMessage();
System.err.println("message = " + message1);
/*
* Create and register a group and activatable object
*/
if (message1.equals(MESSAGE1)) {
System.err.println("Test1a passed: initial MarshalledObject " +
"correct");
} else {
TestLibrary.bomb("Test1 failed: unexpected MarshalledObject passed to " +
"constructor", null);
}
System.err.println("Creating group descriptor");
Properties props = new Properties();
props.put("java.security.policy",
TestParams.defaultGroupPolicy);
props.put("java.security.manager",
TestParams.defaultSecurityManager);
props.put("test.message", MESSAGE1);
ActivationGroupDesc initialGroupDesc =
new ActivationGroupDesc(props, null);
System.err.println("Registering group");
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(initialGroupDesc);
/*
* Get property from remote group and make sure it's okay
*/
message1 = obj.getProperty("test.message");
if (message1.equals(MESSAGE1)) {
System.err.println("Test1b passed: initial group property " +
"correct");
} else {
TestLibrary.bomb("Test1 failed: unexpected property passed to " +
"group", null);
}
System.err.println("Creating descriptor");
ActivationDesc initialDesc =
new ActivationDesc(groupID, "ModifyDescriptor", null,
new MarshalledObject(MESSAGE1), false);
/*
* Update activation descriptor for object and group
*/
System.err.println("Update activation descriptor");
ActivationDesc newDesc =
new ActivationDesc(groupID, "ModifyDescriptor", null,
new MarshalledObject(MESSAGE2), false);
ActivationID id = obj.getID();
ActivationDesc oldDesc = system.setActivationDesc(id, newDesc);
System.err.println("Registering descriptor");
ActivateMe obj = (ActivateMe) Activatable.register(initialDesc);
if (oldDesc.equals(initialDesc)) {
System.err.println("Test2a passed: desc returned from " +
"setActivationDesc is okay");
} else {
TestLibrary.bomb("Test2a failed: desc returned from setActivationDesc " +
"is not the initial descriptor!", null);
}
/*
* Ping object and verify that MarshalledObject is okay.
*/
System.err.println("Ping object");
String message1 = obj.getMessage();
System.err.println("message = " + message1);
if (message1.equals(MESSAGE1)) {
System.err.println("Test1a passed: initial MarshalledObject " +
"correct");
} else {
TestLibrary.bomb("Test1 failed: unexpected MarshalledObject passed to " +
"constructor", null);
}
/*
* Get property from remote group and make sure it's okay
*/
message1 = obj.getProperty("test.message");
if (message1.equals(MESSAGE1)) {
System.err.println("Test1b passed: initial group property " +
"correct");
} else {
TestLibrary.bomb("Test1 failed: unexpected property passed to " +
"group", null);
}
/*
* Update activation descriptor for object and group
*/
System.err.println("Update activation descriptor");
ActivationDesc newDesc =
new ActivationDesc(groupID, "ModifyDescriptor", null,
new MarshalledObject(MESSAGE2), false);
ActivationID id = obj.getID();
ActivationDesc oldDesc = system.setActivationDesc(id, newDesc);
if (oldDesc.equals(initialDesc)) {
System.err.println("Test2a passed: desc returned from " +
"setActivationDesc is okay");
} else {
TestLibrary.bomb("Test2a failed: desc returned from setActivationDesc " +
"is not the initial descriptor!", null);
}
Properties props2 = new Properties();
props2.put("test.message", MESSAGE2);
props2.put("java.security.policy",
TestParams.defaultGroupPolicy);
props2.put("java.security.manager",
TestParams.defaultSecurityManager);
ActivationGroupDesc newGroupDesc =
new ActivationGroupDesc(props2, null);
Properties props2 = new Properties();
props2.put("test.message", MESSAGE2);
props2.put("java.security.policy",
TestParams.defaultGroupPolicy);
props2.put("java.security.manager",
TestParams.defaultSecurityManager);
ActivationGroupDesc newGroupDesc =
new ActivationGroupDesc(props2, null);
ActivationGroupDesc oldGroupDesc =
system.setActivationGroupDesc(groupID, newGroupDesc);
ActivationGroupDesc oldGroupDesc =
system.setActivationGroupDesc(groupID, newGroupDesc);
if (oldGroupDesc.equals(initialGroupDesc)) {
System.err.println("Test2b passed: group desc returned from " +
"setActivationGroupDesc is okay");
} else {
TestLibrary.bomb("Test2b failed: group desc returned from " +
"setActivationGroupDesc is not the initial descriptor!",
null);
}
/*
* Restart rmid; and ping object to make sure that it has
* new message.
*/
rmid.restart();
if (oldGroupDesc.equals(initialGroupDesc)) {
System.err.println("Test2b passed: group desc returned from " +
"setActivationGroupDesc is okay");
} else {
TestLibrary.bomb("Test2b failed: group desc returned from " +
"setActivationGroupDesc is not the initial descriptor!",
null);
}
System.err.println("Ping object after restart");
String message2 = obj.getMessage();
/*
* Restart rmid; and ping object to make sure that it has
* new message.
*/
rmid.restart();
if (message2.equals(MESSAGE2)) {
System.err.println("Test3a passed: setActivationDesc takes " +
"effect after a restart");
} else {
TestLibrary.bomb("Test3a failed: setActivationDesc did not take effect " +
"after a restart", null);
}
System.err.println("Ping object after restart");
String message2 = obj.getMessage();
message2 = obj.getProperty("test.message");
if (message2.equals(MESSAGE2)) {
System.err.println("Test3b passed: setActivationGroupDesc " +
"takes effect after a restart");
} else {
TestLibrary.bomb("Test3b failed: setActivationGroupDesc did not take " +
"effect after a restart", null);
}
if (message2.equals(MESSAGE2)) {
System.err.println("Test3a passed: setActivationDesc takes " +
"effect after a restart");
} else {
TestLibrary.bomb("Test3a failed: setActivationDesc did not take effect " +
"after a restart", null);
}
System.err.println("Get activation descriptor");
ActivationDesc latestDesc = system.getActivationDesc(id);
message2 = obj.getProperty("test.message");
if (latestDesc.equals(newDesc)) {
System.err.println("Test4a passed: desc is same as latest");
} else {
TestLibrary.bomb("Test4a failed: there is no way this would happen", null);
}
if (message2.equals(MESSAGE2)) {
System.err.println("Test3b passed: setActivationGroupDesc " +
"takes effect after a restart");
} else {
TestLibrary.bomb("Test3b failed: setActivationGroupDesc did not take " +
"effect after a restart", null);
}
System.err.println("Get activation group descriptor");
ActivationGroupDesc latestGroupDesc =
system.getActivationGroupDesc(groupID);
System.err.println("Get activation descriptor");
ActivationDesc latestDesc = system.getActivationDesc(id);
if (latestGroupDesc.equals(newGroupDesc)) {
System.err.println("Test4b passed: group desc is same as " +
"latest");
} else {
TestLibrary.bomb("Test4b failed: there is no way this would happen", null);
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
}
if (latestDesc.equals(newDesc)) {
System.err.println("Test4a passed: desc is same as latest");
} else {
TestLibrary.bomb("Test4a failed: there is no way this would happen", null);
}
System.err.println("Get activation group descriptor");
ActivationGroupDesc latestGroupDesc =
system.getActivationGroupDesc(groupID);
if (latestGroupDesc.equals(newGroupDesc)) {
System.err.println("Test4b passed: group desc is same as " +
"latest");
} else {
TestLibrary.bomb("Test4b failed: there is no way this would happen", null);
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
ActivationLibrary.rmidCleanup(rmid);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,166 +29,166 @@ public final class ModifyDescriptor_Stub
implements ActivateMe
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("java.rmi.activation.ActivationID getID()"),
new java.rmi.server.Operation("java.lang.String getMessage()"),
new java.rmi.server.Operation("java.lang.String getProperty(java.lang.String)"),
new java.rmi.server.Operation("void shutdown()")
new java.rmi.server.Operation("java.rmi.activation.ActivationID getID()"),
new java.rmi.server.Operation("java.lang.String getMessage()"),
new java.rmi.server.Operation("java.lang.String getProperty(java.lang.String)"),
new java.rmi.server.Operation("void shutdown()")
};
private static final long interfaceHash = 7998207954486691383L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_getID_0;
private static java.lang.reflect.Method $method_getMessage_1;
private static java.lang.reflect.Method $method_getProperty_2;
private static java.lang.reflect.Method $method_shutdown_3;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getID_0 = ActivateMe.class.getMethod("getID", new java.lang.Class[] {});
$method_getMessage_1 = ActivateMe.class.getMethod("getMessage", new java.lang.Class[] {});
$method_getProperty_2 = ActivateMe.class.getMethod("getProperty", new java.lang.Class[] {java.lang.String.class});
$method_shutdown_3 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getID_0 = ActivateMe.class.getMethod("getID", new java.lang.Class[] {});
$method_getMessage_1 = ActivateMe.class.getMethod("getMessage", new java.lang.Class[] {});
$method_getProperty_2 = ActivateMe.class.getMethod("getProperty", new java.lang.Class[] {java.lang.String.class});
$method_shutdown_3 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public ModifyDescriptor_Stub() {
super();
super();
}
public ModifyDescriptor_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of getID()
public java.rmi.activation.ActivationID getID()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getID_0, null, -7795865521150345044L);
return ((java.rmi.activation.ActivationID) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
java.rmi.activation.ActivationID $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.activation.ActivationID) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getID_0, null, -7795865521150345044L);
return ((java.rmi.activation.ActivationID) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
java.rmi.activation.ActivationID $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.activation.ActivationID) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of getMessage()
public java.lang.String getMessage()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getMessage_1, null, 5353407034680111516L);
return ((java.lang.String) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.lang.String $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getMessage_1, null, 5353407034680111516L);
return ((java.lang.String) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.lang.String $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of getProperty(String)
public java.lang.String getProperty(java.lang.String $param_String_1)
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getProperty_2, new java.lang.Object[] {$param_String_1}, 77249282285080913L);
return ((java.lang.String) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
java.lang.String $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getProperty_2, new java.lang.Object[] {$param_String_1}, 77249282285080913L);
return ((java.lang.String) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
java.lang.String $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public void shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -34,4 +34,3 @@ interface CanCreateStubs extends java.rmi.Remote {
Object getForbiddenClass() throws Exception;
ActivationGroupID returnGroupID() throws RemoteException;
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -20,7 +20,7 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 4179055
* @summary Some java apps need to have access to read "accessClassInPackage.sun.rmi.server"
@ -55,151 +55,151 @@ import java.util.StringTokenizer;
*
* The test causes the activation system to need to create each of
* these classes in turn. The test will fail if the activation system
* does not allow these classes to be created.
* does not allow these classes to be created.
*/
public class StubClassesPermitted
extends Activatable implements Runnable, CanCreateStubs
{
public static boolean sameGroup = false;
private static CanCreateStubs canCreateStubs = null;
private static Registry registry = null;
public static void main(String args[]) {
public static void main(String args[]) {
sameGroup = true;
RMID rmid = null;
sameGroup = true;
System.err.println("\nRegression test for bug/rfe 4179055\n");
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
RMID rmid = null;
registry = java.rmi.registry.LocateRegistry.
createRegistry(TestLibrary.REGISTRY_PORT);
System.err.println("\nRegression test for bug/rfe 4179055\n");
// must run with java.lang.SecurityManager or the test
// result will be nullified if running with a build where
// 4180392 has not been fixed.
String smClassName =
System.getSecurityManager().getClass().getName();
if (!smClassName.equals("java.lang.SecurityManager")) {
TestLibrary.bomb("Test must run with java.lang.SecurityManager");
}
try {
TestLibrary.suggestSecurityManager("java.lang.SecurityManager");
// start an rmid.
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
registry = java.rmi.registry.LocateRegistry.
createRegistry(TestLibrary.REGISTRY_PORT);
//rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"});
// must run with java.lang.SecurityManager or the test
// result will be nullified if running with a build where
// 4180392 has not been fixed.
String smClassName =
System.getSecurityManager().getClass().getName();
if (!smClassName.equals("java.lang.SecurityManager")) {
TestLibrary.bomb("Test must run with java.lang.SecurityManager");
}
// Ensure that activation groups run with the correct
// security manager.
//
Properties p = new Properties();
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
"java.lang.SecurityManager");
// start an rmid.
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
// This action causes the following classes to be created
// in this VM (RMI must permit the creation of these classes):
//
// sun.rmi.server.Activation$ActivationSystemImpl_Stub
// sun.rmi.server.Activation$ActivationMonitorImpl_Stub
//
System.err.println("Create activation group, in a new VM");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(groupDesc);
System.err.println("register activatable");
// Fix for: 4271615: make sure activation group runs in a new VM
ActivationDesc desc = new ActivationDesc
(groupID, "StubClassesPermitted", null, null);
canCreateStubs = (CanCreateStubs) Activatable.register(desc);
//rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"});
// ensure registry stub can be passed in a remote call
System.err.println("getting the registry");
registry = canCreateStubs.getRegistry();
// Ensure that activation groups run with the correct
// security manager.
//
Properties p = new Properties();
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
"java.lang.SecurityManager");
// make sure a client cant load just any sun.* class, just
// as a sanity check, try to create a class we are not
// allowed to access but which was passed in a remote call
try {
System.err.println("accessing forbidden class");
Object secureRandom = canCreateStubs.getForbiddenClass();
TestLibrary.bomb("test allowed to access forbidden class," +
" sun.security.provider.SecureRandom");
} catch (java.security.AccessControlException e) {
// This action causes the following classes to be created
// in this VM (RMI must permit the creation of these classes):
//
// sun.rmi.server.Activation$ActivationSystemImpl_Stub
// sun.rmi.server.Activation$ActivationMonitorImpl_Stub
//
System.err.println("Create activation group, in a new VM");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID = system.registerGroup(groupDesc);
// Make sure we received a *local* AccessControlException
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bout);
e.printStackTrace(ps);
ps.flush();
String trace = new String(bout.toByteArray());
if ((trace.indexOf("exceptionReceivedFromServer") >= 0) ||
trace.equals(""))
System.err.println("register activatable");
// Fix for: 4271615: make sure activation group runs in a new VM
ActivationDesc desc = new ActivationDesc
(groupID, "StubClassesPermitted", null, null);
canCreateStubs = (CanCreateStubs) Activatable.register(desc);
// ensure registry stub can be passed in a remote call
System.err.println("getting the registry");
registry = canCreateStubs.getRegistry();
// make sure a client cant load just any sun.* class, just
// as a sanity check, try to create a class we are not
// allowed to access but which was passed in a remote call
try {
System.err.println("accessing forbidden class");
Object secureRandom = canCreateStubs.getForbiddenClass();
TestLibrary.bomb("test allowed to access forbidden class," +
" sun.security.provider.SecureRandom");
} catch (java.security.AccessControlException e) {
// Make sure we received a *local* AccessControlException
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(bout);
e.printStackTrace(ps);
ps.flush();
String trace = new String(bout.toByteArray());
if ((trace.indexOf("exceptionReceivedFromServer") >= 0) ||
trace.equals(""))
{
throw e;
}
System.err.println("received expected local access control exception");
}
throw e;
}
System.err.println("received expected local access control exception");
}
// make sure that an ActivationGroupID can be passed in a
// remote call; this is slightly more inclusive than
// just passing a reference to the activation system
System.err.println("returning group desc");
canCreateStubs.returnGroupID();
// Clean up object
System.err.println
("Deactivate object via method call");
canCreateStubs.shutdown();
// make sure that an ActivationGroupID can be passed in a
// remote call; this is slightly more inclusive than
// just passing a reference to the activation system
System.err.println("returning group desc");
canCreateStubs.returnGroupID();
System.err.println
("\nsuccess: StubClassesPermitted test passed ");
} catch (Exception e) {
TestLibrary.bomb("\nfailure: unexpected exception ", e);
} finally {
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
}
canCreateStubs = null;
ActivationLibrary.rmidCleanup(rmid);
System.err.println("rmid shut down");
}
// Clean up object
System.err.println
("Deactivate object via method call");
canCreateStubs.shutdown();
System.err.println
("\nsuccess: StubClassesPermitted test passed ");
} catch (Exception e) {
TestLibrary.bomb("\nfailure: unexpected exception ", e);
} finally {
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
}
canCreateStubs = null;
ActivationLibrary.rmidCleanup(rmid);
System.err.println("rmid shut down");
}
}
static ActivationGroupID GroupID = null;
/**
* implementation of CanCreateStubs
* implementation of CanCreateStubs
*/
public StubClassesPermitted
(ActivationID id, MarshalledObject mo) throws RemoteException
(ActivationID id, MarshalledObject mo) throws RemoteException
{
// register/export anonymously
super(id, 0);
// register/export anonymously
super(id, 0);
// obtain reference to the test registry
registry = java.rmi.registry.LocateRegistry.
getRegistry(TestLibrary.REGISTRY_PORT);
// obtain reference to the test registry
registry = java.rmi.registry.LocateRegistry.
getRegistry(TestLibrary.REGISTRY_PORT);
}
/**
* Spawns a thread to deactivate the object.
*/
public void shutdown() throws Exception {
(new Thread(this,"StubClassesPermitted")).start();
(new Thread(this,"StubClassesPermitted")).start();
}
/**
@ -209,7 +209,7 @@ public class StubClassesPermitted
* unexport the object forcibly.
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
ActivationLibrary.deactivate(this, getID());
}
/**
@ -217,12 +217,12 @@ public class StubClassesPermitted
* the stub for it can be deserialized in the test client VM.
*/
public Registry getRegistry() throws RemoteException {
if (sameGroup) {
System.out.println("in same group");
} else {
System.out.println("not in same group");
}
return registry;
if (sameGroup) {
System.out.println("in same group");
} else {
System.out.println("not in same group");
}
return registry;
}
/**
@ -232,8 +232,8 @@ public class StubClassesPermitted
* can be resolved in a remote call.
*/
public Object getForbiddenClass() throws RemoteException {
System.err.println("creating sun class");
return new sun.security.provider.SecureRandom();
System.err.println("creating sun class");
return new sun.security.provider.SecureRandom();
}
/**
@ -242,6 +242,6 @@ public class StubClassesPermitted
* system implementation).
*/
public ActivationGroupID returnGroupID() throws RemoteException {
return ActivationGroup.currentGroupID();
return ActivationGroup.currentGroupID();
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,152 +29,152 @@ public final class StubClassesPermitted_Stub
implements CanCreateStubs, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("java.lang.Object getForbiddenClass()"),
new java.rmi.server.Operation("java.rmi.registry.Registry getRegistry()"),
new java.rmi.server.Operation("java.rmi.activation.ActivationGroupID returnGroupID()"),
new java.rmi.server.Operation("void shutdown()")
new java.rmi.server.Operation("java.lang.Object getForbiddenClass()"),
new java.rmi.server.Operation("java.rmi.registry.Registry getRegistry()"),
new java.rmi.server.Operation("java.rmi.activation.ActivationGroupID returnGroupID()"),
new java.rmi.server.Operation("void shutdown()")
};
private static final long interfaceHash = 1677779850431817575L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_getForbiddenClass_0;
private static java.lang.reflect.Method $method_getRegistry_1;
private static java.lang.reflect.Method $method_returnGroupID_2;
private static java.lang.reflect.Method $method_shutdown_3;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getForbiddenClass_0 = CanCreateStubs.class.getMethod("getForbiddenClass", new java.lang.Class[] {});
$method_getRegistry_1 = CanCreateStubs.class.getMethod("getRegistry", new java.lang.Class[] {});
$method_returnGroupID_2 = CanCreateStubs.class.getMethod("returnGroupID", new java.lang.Class[] {});
$method_shutdown_3 = CanCreateStubs.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getForbiddenClass_0 = CanCreateStubs.class.getMethod("getForbiddenClass", new java.lang.Class[] {});
$method_getRegistry_1 = CanCreateStubs.class.getMethod("getRegistry", new java.lang.Class[] {});
$method_returnGroupID_2 = CanCreateStubs.class.getMethod("returnGroupID", new java.lang.Class[] {});
$method_shutdown_3 = CanCreateStubs.class.getMethod("shutdown", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public StubClassesPermitted_Stub() {
super();
super();
}
public StubClassesPermitted_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of getForbiddenClass()
public java.lang.Object getForbiddenClass()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getForbiddenClass_0, null, -658265783646674294L);
return ((java.lang.Object) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
java.lang.Object $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.Object) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getForbiddenClass_0, null, -658265783646674294L);
return ((java.lang.Object) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
java.lang.Object $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.Object) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
}
// implementation of getRegistry()
public java.rmi.registry.Registry getRegistry()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getRegistry_1, null, 255311215504696981L);
return ((java.rmi.registry.Registry) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.rmi.registry.Registry $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.registry.Registry) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getRegistry_1, null, 255311215504696981L);
return ((java.rmi.registry.Registry) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.rmi.registry.Registry $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.registry.Registry) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of returnGroupID()
public java.rmi.activation.ActivationGroupID returnGroupID()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_returnGroupID_2, null, 6267304638191237098L);
return ((java.rmi.activation.ActivationGroupID) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
ref.invoke(call);
java.rmi.activation.ActivationGroupID $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.activation.ActivationGroupID) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_returnGroupID_2, null, 6267304638191237098L);
return ((java.rmi.activation.ActivationGroupID) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
ref.invoke(call);
java.rmi.activation.ActivationGroupID $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.activation.ActivationGroupID) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public void shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_3, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -27,4 +27,3 @@ public interface CallbackInterface extends Remote {
public void inc() throws RemoteException;
public int getNumDeactivated() throws RemoteException;
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,94 +29,94 @@ public final class Callback_Stub
implements CallbackInterface, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("int getNumDeactivated()"),
new java.rmi.server.Operation("void inc()")
new java.rmi.server.Operation("int getNumDeactivated()"),
new java.rmi.server.Operation("void inc()")
};
private static final long interfaceHash = -1008194523112388035L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_getNumDeactivated_0;
private static java.lang.reflect.Method $method_inc_1;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getNumDeactivated_0 = CallbackInterface.class.getMethod("getNumDeactivated", new java.lang.Class[] {});
$method_inc_1 = CallbackInterface.class.getMethod("inc", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_getNumDeactivated_0 = CallbackInterface.class.getMethod("getNumDeactivated", new java.lang.Class[] {});
$method_inc_1 = CallbackInterface.class.getMethod("inc", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public Callback_Stub() {
super();
super();
}
public Callback_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of getNumDeactivated()
public int getNumDeactivated()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getNumDeactivated_0, null, -761062487639949912L);
return ((java.lang.Integer) $result).intValue();
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
int $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = in.readInt();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
Object $result = ref.invoke(this, $method_getNumDeactivated_0, null, -761062487639949912L);
return ((java.lang.Integer) $result).intValue();
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
int $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = in.readInt();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of inc()
public void inc()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
ref.invoke(this, $method_inc_1, null, 4394985085384332959L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
ref.invoke(this, $method_inc_1, null, 4394985085384332959L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -65,8 +65,8 @@ class Callback extends UnicastRemoteObject implements CallbackInterface {
}
public class UnregisterGroup
extends Activatable
implements ActivateMe, Runnable
extends Activatable
implements ActivateMe, Runnable
{
private static Exception exception = null;
@ -77,30 +77,30 @@ public class UnregisterGroup
private static int PORT = 2006;
public UnregisterGroup(ActivationID id, MarshalledObject mobj)
throws Exception
throws Exception
{
super(id, 0);
super(id, 0);
}
public void ping()
{}
public void unregister() throws Exception {
super.unregister(super.getID());
super.unregister(super.getID());
}
/**
* Spawns a thread to deactivate the object.
*/
public void shutdown() throws Exception {
(new Thread(this,"UnregisterGroup")).start();
(new Thread(this,"UnregisterGroup")).start();
}
/**
* To support exiting of group VM as a last resort
*/
public void justGoAway() {
System.exit(0);
System.exit(0);
}
/**
@ -111,151 +111,151 @@ public class UnregisterGroup
*/
public void run() {
ActivationLibrary.deactivate(this, getID());
System.err.println("\tActivationLibrary.deactivate returned");
ActivationLibrary.deactivate(this, getID());
System.err.println("\tActivationLibrary.deactivate returned");
try {
CallbackInterface cobj =
(CallbackInterface)Naming.lookup("//:" + PORT + "/Callback");
cobj.inc();
} catch (Exception e) {
System.err.println("cobj.inc exception");
e.printStackTrace();
}
try {
CallbackInterface cobj =
(CallbackInterface)Naming.lookup("//:" + PORT + "/Callback");
cobj.inc();
} catch (Exception e) {
System.err.println("cobj.inc exception");
e.printStackTrace();
}
}
public static void main(String[] args) {
Registry registry;
Registry registry;
System.err.println("\nRegression test for bug 4134233\n");
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
RMID rmid = null;
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
System.err.println("\nRegression test for bug 4134233\n");
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
final Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager");
RMID rmid = null;
//final int NUM_OBJECTS = 10;
Thread t = new Thread() {
public void run () {
try {
System.err.println("Creating group descriptor");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID =
system.registerGroup(groupDesc);
try {
RMID.removeLog();
rmid = RMID.createRMID();
rmid.start();
ActivateMe[] obj = new ActivateMe[NUM_OBJECTS];
/* Cause activation groups to have a security policy that will
* allow security managers to be downloaded and installed
*/
final Properties p = new Properties();
// this test must always set policies/managers in its
// activation groups
p.put("java.security.policy",
TestParams.defaultGroupPolicy);
p.put("java.security.manager",
TestParams.defaultSecurityManager);
for (int i = 0; i < NUM_OBJECTS; i++) {
System.err.println("Creating descriptor: " + i);
ActivationDesc desc =
new ActivationDesc(groupID, "UnregisterGroup",
null, null);
System.err.println("Registering descriptor: " + i);
obj[i] = (ActivateMe) Activatable.register(desc);
System.err.println("Activating object: " + i);
obj[i].ping();
}
lastResortExitObj = obj[0];
//final int NUM_OBJECTS = 10;
System.err.println("Unregistering group");
system.unregisterGroup(groupID);
Thread t = new Thread() {
public void run () {
try {
System.err.println("Creating group descriptor");
ActivationGroupDesc groupDesc =
new ActivationGroupDesc(p, null);
ActivationSystem system = ActivationGroup.getSystem();
ActivationGroupID groupID =
system.registerGroup(groupDesc);
try {
System.err.println("Get the group descriptor");
system.getActivationGroupDesc(groupID);
error = "test failed: group still registered";
} catch (UnknownGroupException e) {
System.err.println("Test passed: " +
"group unregistered");
}
ActivateMe[] obj = new ActivateMe[NUM_OBJECTS];
for (int i = 0; i < NUM_OBJECTS; i++) {
System.err.println("Creating descriptor: " + i);
ActivationDesc desc =
new ActivationDesc(groupID, "UnregisterGroup",
null, null);
System.err.println("Registering descriptor: " + i);
obj[i] = (ActivateMe) Activatable.register(desc);
System.err.println("Activating object: " + i);
obj[i].ping();
}
lastResortExitObj = obj[0];
System.err.println("Unregistering group");
system.unregisterGroup(groupID);
try {
System.err.println("Get the group descriptor");
system.getActivationGroupDesc(groupID);
error = "test failed: group still registered";
} catch (UnknownGroupException e) {
System.err.println("Test passed: " +
"group unregistered");
}
/*
* Deactivate objects so group VM will exit.
*/
for (int i = 0; i < NUM_OBJECTS; i++) {
System.err.println("Deactivating object: " + i);
obj[i].shutdown();
obj[i] = null;
}
lastResortExitObj = null;
/*
* Deactivate objects so group VM will exit.
*/
for (int i = 0; i < NUM_OBJECTS; i++) {
System.err.println("Deactivating object: " + i);
obj[i].shutdown();
obj[i] = null;
}
lastResortExitObj = null;
} catch (Exception e) {
exception = e;
}
} catch (Exception e) {
exception = e;
}
done = true;
}
};
done = true;
}
};
t.start();
t.join(120000);
t.start();
t.join(120000);
if (exception != null) {
TestLibrary.bomb("test failed", exception);
} else if (error != null) {
TestLibrary.bomb(error, null);
} else if (!done) {
TestLibrary.bomb("test failed: not completed before timeout", null);
} else {
System.err.println("Test passed");
}
if (exception != null) {
TestLibrary.bomb("test failed", exception);
} else if (error != null) {
TestLibrary.bomb(error, null);
} else if (!done) {
TestLibrary.bomb("test failed: not completed before timeout", null);
} else {
System.err.println("Test passed");
}
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
if (lastResortExitObj != null) {
try {
lastResortExitObj.justGoAway();
} catch (Exception munch) {
}
}
// Wait for the object deactivation to take place first
try {
} catch (Exception e) {
TestLibrary.bomb("test failed", e);
} finally {
if (lastResortExitObj != null) {
try {
lastResortExitObj.justGoAway();
} catch (Exception munch) {
}
}
// create reg and export callback object
registry = LocateRegistry.createRegistry(PORT);
Callback robj = new Callback();
registry.bind("Callback", robj);
// Wait for the object deactivation to take place first
try {
//get the callback object
int maxwait=30;
int nd = robj.getNumDeactivated();
while ((nd < NUM_OBJECTS) && (maxwait> 0)) {
System.err.println("num_deactivated="+nd);
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {}
maxwait--;
nd = robj.getNumDeactivated();
}
} catch (Exception ce) {
System.err.println("E:"+ce);
ce.printStackTrace();
}
// create reg and export callback object
registry = LocateRegistry.createRegistry(PORT);
Callback robj = new Callback();
registry.bind("Callback", robj);
ActivationLibrary.rmidCleanup(rmid);
}
//get the callback object
int maxwait=30;
int nd = robj.getNumDeactivated();
while ((nd < NUM_OBJECTS) && (maxwait> 0)) {
System.err.println("num_deactivated="+nd);
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {}
maxwait--;
nd = robj.getNumDeactivated();
}
} catch (Exception ce) {
System.err.println("E:"+ce);
ce.printStackTrace();
}
ActivationLibrary.rmidCleanup(rmid);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1998-1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,116 +29,116 @@ public final class UnregisterGroup_Stub
implements ActivateMe, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("void justGoAway()"),
new java.rmi.server.Operation("void ping()"),
new java.rmi.server.Operation("void shutdown()"),
new java.rmi.server.Operation("void unregister()")
new java.rmi.server.Operation("void justGoAway()"),
new java.rmi.server.Operation("void ping()"),
new java.rmi.server.Operation("void shutdown()"),
new java.rmi.server.Operation("void unregister()")
};
private static final long interfaceHash = -4733924075192691630L;
private static final long serialVersionUID = 2;
private static boolean useNewInvoke;
private static java.lang.reflect.Method $method_justGoAway_0;
private static java.lang.reflect.Method $method_ping_1;
private static java.lang.reflect.Method $method_shutdown_2;
private static java.lang.reflect.Method $method_unregister_3;
static {
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_justGoAway_0 = ActivateMe.class.getMethod("justGoAway", new java.lang.Class[] {});
$method_ping_1 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_2 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
$method_unregister_3 = ActivateMe.class.getMethod("unregister", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
try {
java.rmi.server.RemoteRef.class.getMethod("invoke",
new java.lang.Class[] {
java.rmi.Remote.class,
java.lang.reflect.Method.class,
java.lang.Object[].class,
long.class
});
useNewInvoke = true;
$method_justGoAway_0 = ActivateMe.class.getMethod("justGoAway", new java.lang.Class[] {});
$method_ping_1 = ActivateMe.class.getMethod("ping", new java.lang.Class[] {});
$method_shutdown_2 = ActivateMe.class.getMethod("shutdown", new java.lang.Class[] {});
$method_unregister_3 = ActivateMe.class.getMethod("unregister", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
useNewInvoke = false;
}
}
// constructors
public UnregisterGroup_Stub() {
super();
super();
}
public UnregisterGroup_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of justGoAway()
public void justGoAway()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
ref.invoke(this, $method_justGoAway_0, null, -5382478058620783904L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
ref.invoke(this, $method_justGoAway_0, null, -5382478058620783904L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of ping()
public void ping()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
if (useNewInvoke) {
ref.invoke(this, $method_ping_1, null, 5866401369815527589L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
if (useNewInvoke) {
ref.invoke(this, $method_ping_1, null, 5866401369815527589L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
ref.done(call);
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of shutdown()
public void shutdown()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_2, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
ref.invoke(call);
ref.done(call);
}
if (useNewInvoke) {
ref.invoke(this, $method_shutdown_2, null, -7207851917985848402L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
ref.invoke(call);
ref.done(call);
}
}
// implementation of unregister()
public void unregister()
throws java.lang.Exception
throws java.lang.Exception
{
if (useNewInvoke) {
ref.invoke(this, $method_unregister_3, null, -5366864281862648102L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
if (useNewInvoke) {
ref.invoke(this, $method_unregister_3, null, -5366864281862648102L);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
ref.invoke(call);
ref.done(call);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -41,17 +41,17 @@ public class CheckVMID {
public static void main(String[] args) {
System.err.println("\nRegression test for bug 4171370\n");
System.err.println("\nRegression test for bug 4171370\n");
TestLibrary.suggestSecurityManager(null);
TestLibrary.suggestSecurityManager(null);
try {
System.err.println("Create a VMID");
VMID vmid = new VMID();
System.err.println("vmid = " + vmid);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
}
try {
System.err.println("Create a VMID");
VMID vmid = new VMID();
System.err.println("vmid = " + vmid);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -51,123 +51,123 @@ public class DGCAckFailure implements ReturnRemote {
private static final long TIMEOUT = 20000;
public Object returnRemote() {
return new Wrapper(this);
return new Wrapper(this);
}
public static void main(String[] args) throws Exception {
System.setProperty("sun.rmi.dgc.ackTimeout", "10000");
System.setProperty("sun.rmi.dgc.ackTimeout", "10000");
/*
* Set a socket factory that has a hook for shutting down all client
* output (writes from client-created sockets and new connection
* attempts). We then use this hook right before a remote stub gets
* deserialized, so that the client will not be able to send a DGC
* dirty call, or a DGC acknowledgment. Without the DGC ack, we
* hope that the RMI runtime will still eventually allow the remote
* object to be garbage collected.
*/
RMISocketFactory.setSocketFactory(new TestSF());
System.err.println("test socket factory set");
/*
* Set a socket factory that has a hook for shutting down all client
* output (writes from client-created sockets and new connection
* attempts). We then use this hook right before a remote stub gets
* deserialized, so that the client will not be able to send a DGC
* dirty call, or a DGC acknowledgment. Without the DGC ack, we
* hope that the RMI runtime will still eventually allow the remote
* object to be garbage collected.
*/
RMISocketFactory.setSocketFactory(new TestSF());
System.err.println("test socket factory set");
Remote impl = new DGCAckFailure();
ReferenceQueue refQueue = new ReferenceQueue();
Reference weakRef = new WeakReference(impl, refQueue);
ReturnRemote stub =
(ReturnRemote) UnicastRemoteObject.exportObject(impl);
System.err.println("remote object exported; stub = " + stub);
Remote impl = new DGCAckFailure();
ReferenceQueue refQueue = new ReferenceQueue();
Reference weakRef = new WeakReference(impl, refQueue);
ReturnRemote stub =
(ReturnRemote) UnicastRemoteObject.exportObject(impl);
System.err.println("remote object exported; stub = " + stub);
try {
Object wrappedStub = stub.returnRemote();
System.err.println("invocation returned: " + wrappedStub);
try {
Object wrappedStub = stub.returnRemote();
System.err.println("invocation returned: " + wrappedStub);
impl = null;
stub = null; // in case 4114579 ever gets fixed
System.err.println("strong references to impl cleared");
impl = null;
stub = null; // in case 4114579 ever gets fixed
System.err.println("strong references to impl cleared");
System.err.println("waiting for weak reference notification:");
Reference ref = null;
for (int i = 0; i < 6; i++) {
System.gc();
ref = refQueue.remove(TIMEOUT / 5);
if (ref != null) {
break;
}
}
if (ref == weakRef) {
System.err.println("TEST PASSED");
} else {
throw new RuntimeException("TEST FAILED: " +
"timed out, remote object not garbage collected");
}
} finally {
try {
UnicastRemoteObject.unexportObject((Remote) weakRef.get(),
true);
} catch (Exception e) {
}
}
System.err.println("waiting for weak reference notification:");
Reference ref = null;
for (int i = 0; i < 6; i++) {
System.gc();
ref = refQueue.remove(TIMEOUT / 5);
if (ref != null) {
break;
}
}
if (ref == weakRef) {
System.err.println("TEST PASSED");
} else {
throw new RuntimeException("TEST FAILED: " +
"timed out, remote object not garbage collected");
}
} finally {
try {
UnicastRemoteObject.unexportObject((Remote) weakRef.get(),
true);
} catch (Exception e) {
}
}
}
private static class Wrapper implements Serializable {
private final Remote obj;
Wrapper(Remote obj) { this.obj = obj; }
private final Remote obj;
Wrapper(Remote obj) { this.obj = obj; }
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
TestSF.shutdownClientOutput();
System.err.println(
"Wrapper.readObject: SHUTTING DOWN CLIENT OUTPUT");
in.defaultReadObject();
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
TestSF.shutdownClientOutput();
System.err.println(
"Wrapper.readObject: SHUTTING DOWN CLIENT OUTPUT");
in.defaultReadObject();
}
public String toString() { return "Wrapper[" + obj + "]"; }
public String toString() { return "Wrapper[" + obj + "]"; }
}
private static class TestSF extends RMISocketFactory {
private static volatile boolean shutdown = false;
static void shutdownClientOutput() { shutdown = true; }
private static volatile boolean shutdown = false;
static void shutdownClientOutput() { shutdown = true; }
public Socket createSocket(String host, int port) throws IOException {
if (shutdown) {
IOException e = new java.net.ConnectException(
"test socket factory rejecting client connection");
System.err.println(e);
// e.printStackTrace();
throw e;
} else {
return new TestSocket(host, port);
}
}
public Socket createSocket(String host, int port) throws IOException {
if (shutdown) {
IOException e = new java.net.ConnectException(
"test socket factory rejecting client connection");
System.err.println(e);
// e.printStackTrace();
throw e;
} else {
return new TestSocket(host, port);
}
}
public ServerSocket createServerSocket(int port) throws IOException {
return new ServerSocket(port);
}
public ServerSocket createServerSocket(int port) throws IOException {
return new ServerSocket(port);
}
private static class TestSocket extends Socket {
TestSocket(String host, int port) throws IOException {
super(host, port);
}
public OutputStream getOutputStream() throws IOException {
return new TestOutputStream(super.getOutputStream());
}
}
private static class TestSocket extends Socket {
TestSocket(String host, int port) throws IOException {
super(host, port);
}
public OutputStream getOutputStream() throws IOException {
return new TestOutputStream(super.getOutputStream());
}
}
private static class TestOutputStream extends FilterOutputStream {
TestOutputStream(OutputStream out) { super(out); }
public void write(int b) throws IOException {
if (shutdown) {
IOException e = new IOException(
"connection broken by test socket factory");
System.err.println(e);
// e.printStackTrace();
throw e;
} else {
super.write(b);
}
}
}
private static class TestOutputStream extends FilterOutputStream {
TestOutputStream(OutputStream out) { super(out); }
public void write(int b) throws IOException {
if (shutdown) {
IOException e = new IOException(
"connection broken by test socket factory");
System.err.println(e);
// e.printStackTrace();
throw e;
} else {
super.write(b);
}
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,38 +29,38 @@ public final class DGCAckFailure_Stub
implements ReturnRemote
{
private static final long serialVersionUID = 2;
private static java.lang.reflect.Method $method_returnRemote_0;
static {
try {
$method_returnRemote_0 = ReturnRemote.class.getMethod("returnRemote", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
try {
$method_returnRemote_0 = ReturnRemote.class.getMethod("returnRemote", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
}
// constructors
public DGCAckFailure_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of returnRemote()
public java.lang.Object returnRemote()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
Object $result = ref.invoke(this, $method_returnRemote_0, null, -8981544221566403070L);
return ((java.lang.Object) $result);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
Object $result = ref.invoke(this, $method_returnRemote_0, null, -8981544221566403070L);
return ((java.lang.Object) $result);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -57,55 +57,55 @@ public class DGCImplInsulation implements java.rmi.Remote {
public static void main(String[] args) throws Exception {
TestLibrary.suggestSecurityManager(null);
TestLibrary.suggestSecurityManager(null);
Permissions perms = new Permissions();
perms.add(new SocketPermission("*:1024-", "listen"));
AccessControlContext acc =
new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(
new CodeSource(null, (Certificate[]) null), perms) });
Permissions perms = new Permissions();
perms.add(new SocketPermission("*:1024-", "listen"));
AccessControlContext acc =
new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(
new CodeSource(null, (Certificate[]) null), perms) });
Remote impl = new DGCImplInsulation();;
Remote impl = new DGCImplInsulation();;
try {
Remote stub = (Remote) java.security.AccessController.doPrivileged(
new ExportAction(impl));
System.err.println("exported remote object; local stub: " + stub);
try {
Remote stub = (Remote) java.security.AccessController.doPrivileged(
new ExportAction(impl));
System.err.println("exported remote object; local stub: " + stub);
MarshalledObject mobj = new MarshalledObject(stub);
stub = (Remote) mobj.get();
System.err.println("marshalled/unmarshalled stub: " + stub);
MarshalledObject mobj = new MarshalledObject(stub);
stub = (Remote) mobj.get();
System.err.println("marshalled/unmarshalled stub: " + stub);
ReferenceQueue refQueue = new ReferenceQueue();
Reference weakRef = new WeakReference(impl, refQueue);
impl = null;
System.gc();
if (refQueue.remove(TIMEOUT) == weakRef) {
throw new RuntimeException(
"TEST FAILED: remote object garbage collected");
} else {
System.err.println("TEST PASSED");
stub = null;
System.gc();
Thread.sleep(2000);
System.gc();
}
} finally {
try {
UnicastRemoteObject.unexportObject(impl, true);
} catch (Exception e) {
}
}
ReferenceQueue refQueue = new ReferenceQueue();
Reference weakRef = new WeakReference(impl, refQueue);
impl = null;
System.gc();
if (refQueue.remove(TIMEOUT) == weakRef) {
throw new RuntimeException(
"TEST FAILED: remote object garbage collected");
} else {
System.err.println("TEST PASSED");
stub = null;
System.gc();
Thread.sleep(2000);
System.gc();
}
} finally {
try {
UnicastRemoteObject.unexportObject(impl, true);
} catch (Exception e) {
}
}
}
private static class ExportAction implements PrivilegedExceptionAction {
private final Remote impl;
ExportAction(Remote impl) {
this.impl = impl;
}
public Object run() throws Exception {
return UnicastRemoteObject.exportObject(impl);
}
private final Remote impl;
ExportAction(Remote impl) {
this.impl = impl;
}
public Object run() throws Exception {
return UnicastRemoteObject.exportObject(impl);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,10 +29,10 @@ public final class DGCImplInsulation_Stub
implements java.rmi.Remote
{
private static final long serialVersionUID = 2;
// constructors
public DGCImplInsulation_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -55,108 +55,108 @@ public class RetryDirtyCalls implements Self, Unreferenced {
* Return this object. The need for this method is explained below.
*/
public Self getSelf() {
return this;
return this;
}
public void unreferenced() {
synchronized (this) {
unreferenced = true;
notifyAll();
}
synchronized (this) {
unreferenced = true;
notifyAll();
}
}
public static void main(String[] args) {
System.err.println("\nRegression test for bug 4268258\n");
System.err.println("\nRegression test for bug 4268258\n");
/*
* Set properties to tweak DGC behavior so that this test will execute
* quickly: set the granted lease duration to 10 seconds, the interval
* that leases are checked to 3 seconds.
*/
System.setProperty("java.rmi.dgc.leaseValue", "10000");
System.setProperty("sun.rmi.dgc.checkInterval", "3000");
/*
* Set properties to tweak DGC behavior so that this test will execute
* quickly: set the granted lease duration to 10 seconds, the interval
* that leases are checked to 3 seconds.
*/
System.setProperty("java.rmi.dgc.leaseValue", "10000");
System.setProperty("sun.rmi.dgc.checkInterval", "3000");
/*
* Make idle connections time out almost instantly (0.1 seconds) so
* that the DGC implementation will have to make a new connection for
* each dirty call, thus going through the socket factory, where we
* can easily cause the operation to fail.
*/
System.setProperty("sun.rmi.transport.connectionTimeout", "100");
/*
* Make idle connections time out almost instantly (0.1 seconds) so
* that the DGC implementation will have to make a new connection for
* each dirty call, thus going through the socket factory, where we
* can easily cause the operation to fail.
*/
System.setProperty("sun.rmi.transport.connectionTimeout", "100");
RetryDirtyCalls impl = new RetryDirtyCalls();
RetryDirtyCalls impl = new RetryDirtyCalls();
try {
TestSF sf = new TestSF();
RMISocketFactory.setSocketFactory(sf);
try {
TestSF sf = new TestSF();
RMISocketFactory.setSocketFactory(sf);
/*
* The stub returned by UnicastRemoteObject.exportObject() does
* not participate in DGC, but it does allow us to invoke a method
* on the remote object through RMI. Therefore, we invoke the
* getSelf() method through RMI, which returns an equivalent stub
* that does participate in DGC.
*/
Self stub = (Self) UnicastRemoteObject.exportObject(impl);
Self dgcStub = stub.getSelf();
stub = null; // in case 4114579 has been fixed
/*
* The stub returned by UnicastRemoteObject.exportObject() does
* not participate in DGC, but it does allow us to invoke a method
* on the remote object through RMI. Therefore, we invoke the
* getSelf() method through RMI, which returns an equivalent stub
* that does participate in DGC.
*/
Self stub = (Self) UnicastRemoteObject.exportObject(impl);
Self dgcStub = stub.getSelf();
stub = null; // in case 4114579 has been fixed
/*
* Set the socket factory to cause 3 connections attempts in a row
* to fail before allowing a connection to succeed, expecting the
* client-side DGC implementation to make at least four attempts.
*/
final int FLAKE_FACTOR = 3;
sf.setFlakeFactor(FLAKE_FACTOR);
/*
* Set the socket factory to cause 3 connections attempts in a row
* to fail before allowing a connection to succeed, expecting the
* client-side DGC implementation to make at least four attempts.
*/
final int FLAKE_FACTOR = 3;
sf.setFlakeFactor(FLAKE_FACTOR);
long deadline = System.currentTimeMillis() + TIMEOUT;
boolean unreferenced;
long deadline = System.currentTimeMillis() + TIMEOUT;
boolean unreferenced;
synchronized (impl) {
while (!(unreferenced = impl.unreferenced)) {
long timeToWait = deadline - System.currentTimeMillis();
if (timeToWait > 0) {
impl.wait(timeToWait);
} else {
break;
}
}
}
synchronized (impl) {
while (!(unreferenced = impl.unreferenced)) {
long timeToWait = deadline - System.currentTimeMillis();
if (timeToWait > 0) {
impl.wait(timeToWait);
} else {
break;
}
}
}
if (unreferenced) {
throw new RuntimeException("remote object unreferenced");
}
if (unreferenced) {
throw new RuntimeException("remote object unreferenced");
}
int createCount = sf.getCreateCount();
if (createCount == 0) {
throw new RuntimeException("test socket factory never used");
} else if (createCount < (FLAKE_FACTOR + 3)) {
/*
* The unreferenced method was not invoked for some reason,
* but the dirty calls were clearly not retried well enough.
*/
throw new RuntimeException(
"test failed because dirty calls not retried enough, " +
"but remote object not unreferenced");
}
int createCount = sf.getCreateCount();
if (createCount == 0) {
throw new RuntimeException("test socket factory never used");
} else if (createCount < (FLAKE_FACTOR + 3)) {
/*
* The unreferenced method was not invoked for some reason,
* but the dirty calls were clearly not retried well enough.
*/
throw new RuntimeException(
"test failed because dirty calls not retried enough, " +
"but remote object not unreferenced");
}
System.err.println(
"TEST PASSED: remote object not unreferenced");
System.err.println(
"TEST PASSED: remote object not unreferenced");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
} finally {
/*
* When all is said and done, try to unexport the remote object
* so that the VM has a chance to exit.
*/
try {
UnicastRemoteObject.unexportObject(impl, true);
} catch (Exception e) {
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
} finally {
/*
* When all is said and done, try to unexport the remote object
* so that the VM has a chance to exit.
*/
try {
UnicastRemoteObject.unexportObject(impl, true);
} catch (Exception e) {
}
}
}
}
@ -169,30 +169,30 @@ class TestSF extends RMISocketFactory {
private int createCount = 0;
public synchronized void setFlakeFactor(int newFlakeFactor) {
flakeFactor = newFlakeFactor;
flakeFactor = newFlakeFactor;
}
public synchronized int getCreateCount() {
return createCount;
return createCount;
}
public synchronized Socket createSocket(String host, int port)
throws IOException
throws IOException
{
createCount++;
createCount++;
if (++flakeState > flakeFactor) {
flakeState = 0;
}
if (++flakeState > flakeFactor) {
flakeState = 0;
}
if (flakeState == 0) {
return new Socket(host, port);
} else {
throw new IOException("random network failure");
}
if (flakeState == 0) {
return new Socket(host, port);
} else {
throw new IOException("random network failure");
}
}
public ServerSocket createServerSocket(int port) throws IOException {
return new ServerSocket(port);
return new ServerSocket(port);
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -29,38 +29,38 @@ public final class RetryDirtyCalls_Stub
implements Self
{
private static final long serialVersionUID = 2;
private static java.lang.reflect.Method $method_getSelf_0;
static {
try {
$method_getSelf_0 = Self.class.getMethod("getSelf", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
try {
$method_getSelf_0 = Self.class.getMethod("getSelf", new java.lang.Class[] {});
} catch (java.lang.NoSuchMethodException e) {
throw new java.lang.NoSuchMethodError(
"stub class initialization failed");
}
}
// constructors
public RetryDirtyCalls_Stub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of getSelf()
public Self getSelf()
throws java.rmi.RemoteException
throws java.rmi.RemoteException
{
try {
Object $result = ref.invoke(this, $method_getSelf_0, null, 2868857108246021904L);
return ((Self) $result);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
Object $result = ref.invoke(this, $method_getSelf_0, null, 2868857108246021904L);
return ((Self) $result);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -26,8 +26,8 @@
* @summary rmid and rmiregistry could allow alternate security manager
* @author Laird Dornin
*
* @library ../../testlibrary
* @build StreamPipe TestParams TestLibrary JavaVM
* @library ../../testlibrary
* @build StreamPipe TestParams TestLibrary JavaVM
* @build AltSecurityManager TestSecurityManager
* @run main/othervm AltSecurityManager
*/
@ -38,7 +38,7 @@
* that throws a runtime exception in its checkListen method, this
* will cause rmiregistry and rmid to exit early because those
* utilities will be unable to export any remote objects; test fails
* if registry and rmid take too long to exit.
* if registry and rmid take too long to exit.
*/
public class AltSecurityManager implements Runnable {
@ -54,74 +54,74 @@ public class AltSecurityManager implements Runnable {
static long TIME_OUT = 15000;
public void run() {
try {
vm = new JavaVM(utilityToStart,
" -Djava.security.manager=TestSecurityManager",
"");
System.err.println("starting " + utilityToStart);
vm.start();
vm.getVM().waitFor();
try {
vm = new JavaVM(utilityToStart,
" -Djava.security.manager=TestSecurityManager",
"");
System.err.println("starting " + utilityToStart);
vm.start();
vm.getVM().waitFor();
} catch (Exception e) {
TestLibrary.bomb(e);
}
} catch (Exception e) {
TestLibrary.bomb(e);
}
}
/**
* Wait to make sure that the registry and rmid exit after
* their security manager is set.
*/
public static void ensureExit(String utility) throws Exception {
utilityToStart = utility;
try {
Thread thread = new Thread(new AltSecurityManager());
System.err.println("expecting RuntimeException for " +
"checkListen in child process");
long start = System.currentTimeMillis();
thread.start();
thread.join(TIME_OUT);
long time = System.currentTimeMillis() - start;
System.err.println("waited " + time + " millis for " +
utilityToStart + " to die");
utilityToStart = utility;
if (time >= TIME_OUT) {
// dont pollute other tests; increase the likelihood
try {
Thread thread = new Thread(new AltSecurityManager());
System.err.println("expecting RuntimeException for " +
"checkListen in child process");
long start = System.currentTimeMillis();
thread.start();
thread.join(TIME_OUT);
long time = System.currentTimeMillis() - start;
System.err.println("waited " + time + " millis for " +
utilityToStart + " to die");
if (time >= TIME_OUT) {
// dont pollute other tests; increase the likelihood
// that rmid will go away if it did not exit already.
if (utility.equals(rmid)) {
RMID.shutdown();
}
TestLibrary.bomb(utilityToStart +
" took too long to die...");
} else {
System.err.println(utilityToStart +
" terminated on time");
}
} finally {
vm.destroy();
vm = null;
}
if (utility.equals(rmid)) {
RMID.shutdown();
}
TestLibrary.bomb(utilityToStart +
" took too long to die...");
} else {
System.err.println(utilityToStart +
" terminated on time");
}
} finally {
vm.destroy();
vm = null;
}
}
public static void main(String[] args) {
try {
System.err.println("\nRegression test for bug 4183202\n");
try {
System.err.println("\nRegression test for bug 4183202\n");
// make sure the registry exits early.
ensureExit(registry);
// make sure the registry exits early.
ensureExit(registry);
// make sure rmid exits early
ensureExit(rmid);
// make sure rmid exits early
ensureExit(rmid);
System.err.println("test passed");
System.err.println("test passed");
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
RMID.removeLog();
}
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
RMID.removeLog();
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -28,18 +28,18 @@ public class TestSecurityManager extends SecurityManager {
}
public void checkListen(int port) {
// 4269910: ok, now rmid and the regsitry will *really* go
// away...
//
// rmid and the registry need to listen on sockets so they
// will exit when they try to do so... this is used as a sign
// by the main test process to detect that the proper security
// manager has been installed in the relevant VMs.
//
System.exit(1);
// 4269910: ok, now rmid and the regsitry will *really* go
// away...
//
// rmid and the registry need to listen on sockets so they
// will exit when they try to do so... this is used as a sign
// by the main test process to detect that the proper security
// manager has been installed in the relevant VMs.
//
System.exit(1);
}
public void checkExit(int status) {
// permit check exit for all code
// permit check exit for all code
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -36,48 +36,48 @@ import java.io.ByteArrayOutputStream;
/**
* Make sure that the rmiregistry prints out a correct usage statement
* when run with an incorrect command line; test written to conform to
* new tighter bug fix/regression test guidelines.
* new tighter bug fix/regression test guidelines.
*/
public class CheckUsage {
public static void main(String[] args) {
System.err.println("\nregression test for 4151966\n");
System.err.println("\nregression test for 4151966\n");
JavaVM registryVM = null;
JavaVM registryVM = null;
try {
// make sure the registry exits with a proper usage statement
ByteArrayOutputStream berr = new ByteArrayOutputStream();
// run a VM to start the registry
registryVM = new JavaVM("sun.rmi.registry.RegistryImpl",
"", "foo",
System.out, berr);
System.err.println("starting registry");
registryVM.start();
// wait for registry exit
System.err.println(" registry exited with status: " +
registryVM.getVM().waitFor());
try {
Thread.sleep(7000);
} catch (InterruptedException ie) {
}
String usage = new String(berr.toByteArray());
System.err.println("rmiregistry usage: " + usage);
if (usage.indexOf("-J") < 0) {
TestLibrary.bomb("rmiregistry has incorrect usage statement");
} else {
System.err.println("test passed");
}
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
registryVM.destroy();
registryVM = null;
}
try {
// make sure the registry exits with a proper usage statement
ByteArrayOutputStream berr = new ByteArrayOutputStream();
// run a VM to start the registry
registryVM = new JavaVM("sun.rmi.registry.RegistryImpl",
"", "foo",
System.out, berr);
System.err.println("starting registry");
registryVM.start();
// wait for registry exit
System.err.println(" registry exited with status: " +
registryVM.getVM().waitFor());
try {
Thread.sleep(7000);
} catch (InterruptedException ie) {
}
String usage = new String(berr.toByteArray());
System.err.println("rmiregistry usage: " + usage);
if (usage.indexOf("-J") < 0) {
TestLibrary.bomb("rmiregistry has incorrect usage statement");
} else {
System.err.println("test passed");
}
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
registryVM.destroy();
registryVM = null;
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -55,121 +55,121 @@ public class ClassPathCodebase {
public static void main(String[] args) {
System.err.println("\nRegression test for bug 4242317\n");
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 {
/*
* Install a dummy class in two codebases: one that will be in
* the rmiregistry's CLASSPATH (the "import" codebase) and one
* that will be in the rmiregistry's "java.rmi.server.codebase"
* property (the "export" codebase).
*/
URL importCodebaseURL = TestLibrary.installClassInCodebase(
dummyClassName, importCodebase, false);
URL exportCodebaseURL = TestLibrary.installClassInCodebase(
dummyClassName, exportCodebase, true);
try {
/*
* Install a dummy class in two codebases: one that will be in
* the rmiregistry's CLASSPATH (the "import" codebase) and one
* that will be in the rmiregistry's "java.rmi.server.codebase"
* property (the "export" codebase).
*/
URL importCodebaseURL = TestLibrary.installClassInCodebase(
dummyClassName, importCodebase, false);
URL exportCodebaseURL = TestLibrary.installClassInCodebase(
dummyClassName, exportCodebase, true);
/*
* Spawn an rmiregistry in the "import" codebase directory.
*/
File rmiregistryDir =
new File(System.getProperty("user.dir", "."), importCodebase);
/*
* Spawn an rmiregistry in the "import" codebase directory.
*/
File rmiregistryDir =
new File(System.getProperty("user.dir", "."), importCodebase);
String rmiregistryCommand =
System.getProperty("java.home") + File.separator +
"bin" + File.separator + "rmiregistry";
String cmdarray[] = new String[] {
rmiregistryCommand,
"-J-Denv.class.path=.",
"-J-Djava.rmi.server.codebase=" + exportCodebaseURL,
Integer.toString(TestLibrary.REGISTRY_PORT) };
String rmiregistryCommand =
System.getProperty("java.home") + File.separator +
"bin" + File.separator + "rmiregistry";
System.err.println("\nCommand used to spawn rmiregistry process:");
System.err.println("\t" + Arrays.asList(cmdarray).toString());
String cmdarray[] = new String[] {
rmiregistryCommand,
"-J-Denv.class.path=.",
"-J-Djava.rmi.server.codebase=" + exportCodebaseURL,
Integer.toString(TestLibrary.REGISTRY_PORT) };
rmiregistry = Runtime.getRuntime().exec(cmdarray, null, rmiregistryDir);
System.err.println("\nCommand used to spawn rmiregistry process:");
System.err.println("\t" + Arrays.asList(cmdarray).toString());
// pipe rmiregistry output to our output, for debugging failures
StreamPipe.plugTogether(rmiregistry.getInputStream(), System.err);
StreamPipe.plugTogether(rmiregistry.getErrorStream(), System.err);
rmiregistry = Runtime.getRuntime().exec(cmdarray, null, rmiregistryDir);
/*
* Wait for the registry to initialize and be ready to call.
*/
Thread.sleep(REGISTRY_WAIT);
System.err.println();
// pipe rmiregistry output to our output, for debugging failures
StreamPipe.plugTogether(rmiregistry.getInputStream(), System.err);
StreamPipe.plugTogether(rmiregistry.getErrorStream(), System.err);
/*
* Create an instance of the dummy class, finding it from the
* "import" codebase.
*/
ClassLoader loader = URLClassLoader.newInstance(
new URL[] { importCodebaseURL });
Class dummyClass = Class.forName(dummyClassName, false, loader);
Remote dummyObject = (Remote) dummyClass.newInstance();
/*
* Wait for the registry to initialize and be ready to call.
*/
Thread.sleep(REGISTRY_WAIT);
System.err.println();
/*
* Find the registry that we created and bind the
* dummy object to it.
*/
Registry registry = LocateRegistry.getRegistry(
"localhost", TestLibrary.REGISTRY_PORT);
/*
* Create an instance of the dummy class, finding it from the
* "import" codebase.
*/
ClassLoader loader = URLClassLoader.newInstance(
new URL[] { importCodebaseURL });
Class dummyClass = Class.forName(dummyClassName, false, loader);
Remote dummyObject = (Remote) dummyClass.newInstance();
try {
registry.bind(dummyBinding, dummyObject);
System.err.println("Bound dummy object in registry");
} catch (java.rmi.ConnectException e) {
System.err.println("Error: rmiregistry not started in time");
throw e;
} catch (ServerException e) {
if (e.detail instanceof UnmarshalException &&
((UnmarshalException) e.detail).detail instanceof
ClassNotFoundException)
{
System.err.println(
"Error: another registry running on port " +
TestLibrary.REGISTRY_PORT + "?");
}
throw e;
}
/*
* Find the registry that we created and bind the
* dummy object to it.
*/
Registry registry = LocateRegistry.getRegistry(
"localhost", TestLibrary.REGISTRY_PORT);
/*
* Look up the dummy object from our registry and make sure
* that its class was annotated with the "export" codebase.
*/
Remote dummyLookup = registry.lookup(dummyBinding);
System.err.println(
"Looked up dummy object from registry: " + dummyLookup);
Class dummyLookupClass = dummyLookup.getClass();
String dummyLookupAnnotation =
RMIClassLoader.getClassAnnotation(dummyLookupClass);
System.err.println(
"Class annotation from registry: " + dummyLookupAnnotation);
try {
registry.bind(dummyBinding, dummyObject);
System.err.println("Bound dummy object in registry");
} catch (java.rmi.ConnectException e) {
System.err.println("Error: rmiregistry not started in time");
throw e;
} catch (ServerException e) {
if (e.detail instanceof UnmarshalException &&
((UnmarshalException) e.detail).detail instanceof
ClassNotFoundException)
{
System.err.println(
"Error: another registry running on port " +
TestLibrary.REGISTRY_PORT + "?");
}
throw e;
}
System.err.println();
if (dummyLookupAnnotation.indexOf(exportCodebase) >= 0) {
System.err.println("TEST PASSED");
} else if (dummyLookupAnnotation.indexOf(importCodebase) >= 0) {
throw new RuntimeException(
"rmiregistry annotated with CLASSPATH element URL");
} else {
throw new RuntimeException(
"rmiregistry used unexpected annotation: \"" +
dummyLookupAnnotation + "\"");
}
/*
* Look up the dummy object from our registry and make sure
* that its class was annotated with the "export" codebase.
*/
Remote dummyLookup = registry.lookup(dummyBinding);
System.err.println(
"Looked up dummy object from registry: " + dummyLookup);
Class dummyLookupClass = dummyLookup.getClass();
String dummyLookupAnnotation =
RMIClassLoader.getClassAnnotation(dummyLookupClass);
System.err.println(
"Class annotation from registry: " + dummyLookupAnnotation);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
} finally {
if (rmiregistry != null) {
rmiregistry.destroy();
}
}
System.err.println();
if (dummyLookupAnnotation.indexOf(exportCodebase) >= 0) {
System.err.println("TEST PASSED");
} else if (dummyLookupAnnotation.indexOf(importCodebase) >= 0) {
throw new RuntimeException(
"rmiregistry annotated with CLASSPATH element URL");
} else {
throw new RuntimeException(
"rmiregistry used unexpected annotation: \"" +
dummyLookupAnnotation + "\"");
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("TEST FAILED: " + e.toString());
} finally {
if (rmiregistry != null) {
rmiregistry.destroy();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -36,12 +36,12 @@ public class Dummy
}
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
throws java.io.IOException
{
}
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException, ClassNotFoundException
throws java.io.IOException, ClassNotFoundException
{
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -32,12 +32,12 @@ import java.rmi.server.RemoteObject;
public class EmptyName {
public static void main(String[] args) throws Exception {
Registry impl = LocateRegistry.createRegistry(0);
Registry stub = (Registry) RemoteObject.toStub(impl);
stub.bind("", stub);
stub.lookup("");
stub.rebind("", stub);
stub.lookup("");
stub.unbind("");
Registry impl = LocateRegistry.createRegistry(0);
Registry stub = (Registry) RemoteObject.toStub(impl);
stub.bind("", stub);
stub.lookup("");
stub.rebind("", stub);
stub.lookup("");
stub.unbind("");
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -62,157 +62,157 @@ public class InterfaceHash {
private static final String NAME = "WMM";
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 4472769");
System.err.println("\nRegression test for bug 4472769");
System.err.println(
"\n=== verifying that J2SE registry's skeleton uses" +
"\ncorrect interface hash and operation numbers:");
System.err.println(
"\n=== verifying that J2SE registry's skeleton uses" +
"\ncorrect interface hash and operation numbers:");
Registry testImpl = LocateRegistry.createRegistry(PORT);
System.err.println("created test registry on port " + PORT);
Registry testImpl = LocateRegistry.createRegistry(PORT);
System.err.println("created test registry on port " + PORT);
RemoteRef ref = new UnicastRef(
new LiveRef(new ObjID(ObjID.REGISTRY_ID),
new TCPEndpoint("", PORT), false));
Registry referenceStub = new ReferenceRegistryStub(ref);
System.err.println("created reference registry stub: " +
referenceStub);
RemoteRef ref = new UnicastRef(
new LiveRef(new ObjID(ObjID.REGISTRY_ID),
new TCPEndpoint("", PORT), false));
Registry referenceStub = new ReferenceRegistryStub(ref);
System.err.println("created reference registry stub: " +
referenceStub);
referenceStub.bind(NAME, referenceStub);
System.err.println("bound name \"" + NAME + "\" in registry");
referenceStub.bind(NAME, referenceStub);
System.err.println("bound name \"" + NAME + "\" in registry");
String[] list = referenceStub.list();
System.err.println("list of registry contents: " +
Arrays.asList(list));
if (list.length != 1 || !list[0].equals(NAME)) {
throw new RuntimeException(
"TEST FAILED: unexpected list contents");
}
String[] list = referenceStub.list();
System.err.println("list of registry contents: " +
Arrays.asList(list));
if (list.length != 1 || !list[0].equals(NAME)) {
throw new RuntimeException(
"TEST FAILED: unexpected list contents");
}
Registry result = (Registry) referenceStub.lookup(NAME);
System.err.println("lookup of name \"" + NAME + "\" returned: " +
result);
if (!result.equals(referenceStub)) {
throw new RuntimeException(
"TEST FAILED: unexpected lookup result");
}
Registry result = (Registry) referenceStub.lookup(NAME);
System.err.println("lookup of name \"" + NAME + "\" returned: " +
result);
if (!result.equals(referenceStub)) {
throw new RuntimeException(
"TEST FAILED: unexpected lookup result");
}
referenceStub.rebind(NAME, referenceStub);
referenceStub.unbind(NAME);
System.err.println("unbound name \"" + NAME + "\"");
referenceStub.rebind(NAME, referenceStub);
referenceStub.unbind(NAME);
System.err.println("unbound name \"" + NAME + "\"");
list = referenceStub.list();
System.err.println("list of registry contents: " +
Arrays.asList(list));
if (list.length != 0) {
throw new RuntimeException("TEST FAILED: list not empty");
}
list = referenceStub.list();
System.err.println("list of registry contents: " +
Arrays.asList(list));
if (list.length != 0) {
throw new RuntimeException("TEST FAILED: list not empty");
}
System.err.println("\n=== verifying that J2SE registry's stub uses" +
"correct interface hash:");
System.err.println("\n=== verifying that J2SE registry's stub uses" +
"correct interface hash:");
class FakeRemoteRef implements RemoteRef {
long hash;
int opnum;
public RemoteCall newCall(RemoteObject obj, Operation[] op,
int opnum, long hash)
{
this.hash = hash;
this.opnum = opnum;
throw new UnsupportedOperationException();
}
public void invoke(RemoteCall call) { }
public void done(RemoteCall call) { }
public Object invoke(Remote obj, Method method,
Object[] args, long hash)
{
throw new UnsupportedOperationException();
}
public String getRefClass(java.io.ObjectOutput out) {
return "FakeRemoteRef";
}
public int remoteHashCode() { return 1013; }
public boolean remoteEquals(RemoteRef obj) { return false; }
public String remoteToString() { return "FakeRemoteRef"; }
public void writeExternal(java.io.ObjectOutput out) { }
public void readExternal(java.io.ObjectInput in) { }
}
FakeRemoteRef f = new FakeRemoteRef();
class FakeRemoteRef implements RemoteRef {
long hash;
int opnum;
public RemoteCall newCall(RemoteObject obj, Operation[] op,
int opnum, long hash)
{
this.hash = hash;
this.opnum = opnum;
throw new UnsupportedOperationException();
}
public void invoke(RemoteCall call) { }
public void done(RemoteCall call) { }
public Object invoke(Remote obj, Method method,
Object[] args, long hash)
{
throw new UnsupportedOperationException();
}
public String getRefClass(java.io.ObjectOutput out) {
return "FakeRemoteRef";
}
public int remoteHashCode() { return 1013; }
public boolean remoteEquals(RemoteRef obj) { return false; }
public String remoteToString() { return "FakeRemoteRef"; }
public void writeExternal(java.io.ObjectOutput out) { }
public void readExternal(java.io.ObjectInput in) { }
}
FakeRemoteRef f = new FakeRemoteRef();
Registry testRegistry = LocateRegistry.getRegistry(PORT);
System.err.println("created original test registry stub: " +
testRegistry);
Registry testRegistry = LocateRegistry.getRegistry(PORT);
System.err.println("created original test registry stub: " +
testRegistry);
Class stubClass = testRegistry.getClass();
System.err.println("test registry stub class: " + stubClass);
Class stubClass = testRegistry.getClass();
System.err.println("test registry stub class: " + stubClass);
Constructor cons = stubClass.getConstructor(
new Class[] { RemoteRef.class });
Registry testStub = (Registry) cons.newInstance(
new Object[] { f });
System.err.println("created new instrumented test registry stub: " +
testStub);
Constructor cons = stubClass.getConstructor(
new Class[] { RemoteRef.class });
Registry testStub = (Registry) cons.newInstance(
new Object[] { f });
System.err.println("created new instrumented test registry stub: " +
testStub);
System.err.println("invoking bind:");
try {
testStub.bind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 0) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking bind:");
try {
testStub.bind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 0) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking list:");
try {
testStub.list();
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 1) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking list:");
try {
testStub.list();
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 1) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking lookup:");
try {
testStub.lookup(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 2) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking lookup:");
try {
testStub.lookup(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 2) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking rebind:");
try {
testStub.rebind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 3) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking rebind:");
try {
testStub.rebind(NAME, referenceStub);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 3) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking unbind:");
try {
testStub.unbind(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 4) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("invoking unbind:");
try {
testStub.unbind(NAME);
} catch (UnsupportedOperationException e) {
}
System.err.println("hash == " + f.hash + ", opnum == " + f.opnum);
if (f.hash != 4905912898345647071L) {
throw new RuntimeException("TEST FAILED: wrong interface hash");
} else if (f.opnum != 4) {
throw new RuntimeException("TEST FAILED: wrong operation number");
}
System.err.println("TEST PASSED");
System.err.println("TEST PASSED");
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -26,161 +26,161 @@ public final class ReferenceRegistryStub
implements java.rmi.registry.Registry, java.rmi.Remote
{
private static final java.rmi.server.Operation[] operations = {
new java.rmi.server.Operation("void bind(java.lang.String, java.rmi.Remote)"),
new java.rmi.server.Operation("java.lang.String list()[]"),
new java.rmi.server.Operation("java.rmi.Remote lookup(java.lang.String)"),
new java.rmi.server.Operation("void rebind(java.lang.String, java.rmi.Remote)"),
new java.rmi.server.Operation("void unbind(java.lang.String)")
new java.rmi.server.Operation("void bind(java.lang.String, java.rmi.Remote)"),
new java.rmi.server.Operation("java.lang.String list()[]"),
new java.rmi.server.Operation("java.rmi.Remote lookup(java.lang.String)"),
new java.rmi.server.Operation("void rebind(java.lang.String, java.rmi.Remote)"),
new java.rmi.server.Operation("void unbind(java.lang.String)")
};
private static final long interfaceHash = 4905912898345647071L;
// constructors
public ReferenceRegistryStub() {
super();
super();
}
public ReferenceRegistryStub(java.rmi.server.RemoteRef ref) {
super(ref);
super(ref);
}
// methods from remote interfaces
// implementation of bind(String, Remote)
public void bind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2)
throws java.rmi.AccessException, java.rmi.AlreadyBoundException, java.rmi.RemoteException
throws java.rmi.AccessException, java.rmi.AlreadyBoundException, java.rmi.RemoteException
{
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
out.writeObject($param_Remote_2);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
ref.done(call);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.rmi.AlreadyBoundException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 0, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
out.writeObject($param_Remote_2);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
ref.done(call);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.rmi.AlreadyBoundException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of list()
public java.lang.String[] list()
throws java.rmi.AccessException, java.rmi.RemoteException
throws java.rmi.AccessException, java.rmi.RemoteException
{
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.lang.String[] $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String[]) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 1, interfaceHash);
ref.invoke(call);
java.lang.String[] $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.lang.String[]) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of lookup(String)
public java.rmi.Remote lookup(java.lang.String $param_String_1)
throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException
throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException
{
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
java.rmi.Remote $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.Remote) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.rmi.NotBoundException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 2, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
java.rmi.Remote $result;
try {
java.io.ObjectInput in = call.getInputStream();
$result = (java.rmi.Remote) in.readObject();
} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.rmi.NotBoundException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of rebind(String, Remote)
public void rebind(java.lang.String $param_String_1, java.rmi.Remote $param_Remote_2)
throws java.rmi.AccessException, java.rmi.RemoteException
throws java.rmi.AccessException, java.rmi.RemoteException
{
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
out.writeObject($param_Remote_2);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
ref.done(call);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 3, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
out.writeObject($param_Remote_2);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
ref.done(call);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
// implementation of unbind(String)
public void unbind(java.lang.String $param_String_1)
throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException
throws java.rmi.AccessException, java.rmi.NotBoundException, java.rmi.RemoteException
{
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 4, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
ref.done(call);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.rmi.NotBoundException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
try {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 4, interfaceHash);
try {
java.io.ObjectOutput out = call.getOutputStream();
out.writeObject($param_String_1);
} catch (java.io.IOException e) {
throw new java.rmi.MarshalException("error marshalling arguments", e);
}
ref.invoke(call);
ref.done(call);
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.rmi.NotBoundException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -41,49 +41,49 @@ public class MultipleRegistries implements RemoteInterface {
private static final String NAME = "MultipleRegistries";
public Object passObject(Object obj) {
return obj;
return obj;
}
public static void main(String[] args) throws Exception {
RemoteInterface server = null;
RemoteInterface proxy = null;
try {
System.err.println("export object");
server = new MultipleRegistries();
proxy =
(RemoteInterface) UnicastRemoteObject.exportObject(server, 0);
System.err.println("proxy = " + proxy);
RemoteInterface server = null;
RemoteInterface proxy = null;
System.err.println("export registries");
Registry registryImpl1 = LocateRegistry.createRegistry(2030);
Registry registryImpl2 = LocateRegistry.createRegistry(2040);
try {
System.err.println("export object");
server = new MultipleRegistries();
proxy =
(RemoteInterface) UnicastRemoteObject.exportObject(server, 0);
System.err.println("bind remote object in registries");
Registry registry1 = LocateRegistry.getRegistry(2030);
Registry registry2 = LocateRegistry.getRegistry(2040);
System.err.println("proxy = " + proxy);
registry1.bind(NAME, proxy);
registry2.bind(NAME, proxy);
System.err.println("export registries");
Registry registryImpl1 = LocateRegistry.createRegistry(2030);
Registry registryImpl2 = LocateRegistry.createRegistry(2040);
System.err.println("lookup remote object in registries");
System.err.println("bind remote object in registries");
Registry registry1 = LocateRegistry.getRegistry(2030);
Registry registry2 = LocateRegistry.getRegistry(2040);
RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME);
RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME);
registry1.bind(NAME, proxy);
registry2.bind(NAME, proxy);
System.err.println("invoke methods on remote objects");
remote1.passObject(remote1);
remote2.passObject(remote2);
System.err.println("lookup remote object in registries");
System.err.println("TEST PASSED");
} finally {
if (proxy != null) {
UnicastRemoteObject.unexportObject(server, true);
}
}
RemoteInterface remote1 = (RemoteInterface) registry1.lookup(NAME);
RemoteInterface remote2 = (RemoteInterface) registry2.lookup(NAME);
System.err.println("invoke methods on remote objects");
remote1.passObject(remote1);
remote2.passObject(remote2);
System.err.println("TEST PASSED");
} finally {
if (proxy != null) {
UnicastRemoteObject.unexportObject(server, true);
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999-2004 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -25,13 +25,13 @@
* @bug 4120329
* @summary RMI registry creation is impossible if first attempt fails.
* @library ../../testlibrary
* @build StreamPipe TestParams TestLibrary JavaVM
* @build StreamPipe TestParams TestLibrary JavaVM
* @build RegistryRunner RegistryRunner_Stub
* @build Reexport
* @run main/othervm Reexport
*/
/*
/*
* If a VM could not create an RMI registry because another registry
* usually in another process, was using the registry port, the next
* time the VM tried to create a registry (after the other registry
@ -40,7 +40,7 @@
* use when it should never have been allocated.
*
* The test creates this conflict using Runtime.exec and ensures that
* a registry can still be created after the conflict is resolved.
* a registry can still be created after the conflict is resolved.
*/
import java.io.*;
@ -50,106 +50,106 @@ import java.rmi.server.*;
public class Reexport {
static public final int regport = TestLibrary.REGISTRY_PORT;
static public void main(String[] argv) {
Registry reg = null;
Registry reg = null;
try {
System.err.println("\nregression test for 4120329\n");
// establish the registry (we hope)
System.err.println("Starting registry on port " + regport);
Reexport.makeRegistry(regport);
// Get a handle to the registry
System.err.println("Creating duplicate registry, this should fail...");
reg = createReg(true);
if (reg != null) {
TestLibrary.bomb("failed was able to duplicate the registry?!?");
}
// Kill the first registry.
System.err.println("Bringing down the first registry");
try {
Reexport.killRegistry();
} catch (Exception foo) {
}
// start another registry now that the first is gone; this should work
System.err.println("Trying again to start our own " +
"registry... this should work");
reg = createReg(false);
if (reg == null) {
TestLibrary.bomb("Could not create registry on second try");
}
System.err.println("Test passed");
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
// dont leave the registry around to affect other tests.
killRegistry();
try {
System.err.println("\nregression test for 4120329\n");
reg = null;
}
// establish the registry (we hope)
System.err.println("Starting registry on port " + regport);
Reexport.makeRegistry(regport);
// Get a handle to the registry
System.err.println("Creating duplicate registry, this should fail...");
reg = createReg(true);
if (reg != null) {
TestLibrary.bomb("failed was able to duplicate the registry?!?");
}
// Kill the first registry.
System.err.println("Bringing down the first registry");
try {
Reexport.killRegistry();
} catch (Exception foo) {
}
// start another registry now that the first is gone; this should work
System.err.println("Trying again to start our own " +
"registry... this should work");
reg = createReg(false);
if (reg == null) {
TestLibrary.bomb("Could not create registry on second try");
}
System.err.println("Test passed");
} catch (Exception e) {
TestLibrary.bomb(e);
} finally {
// dont leave the registry around to affect other tests.
killRegistry();
reg = null;
}
}
static Registry createReg(boolean remoteOk) {
Registry reg = null;
Registry reg = null;
try {
reg = LocateRegistry.createRegistry(regport);
} catch (Throwable e) {
if (remoteOk) {
System.err.println("EXPECTING PORT IN USE EXCEPTION:");
System.err.println(e.getMessage());
e.printStackTrace();
} else {
TestLibrary.bomb((Exception) e);
}
}
try {
reg = LocateRegistry.createRegistry(regport);
} catch (Throwable e) {
if (remoteOk) {
System.err.println("EXPECTING PORT IN USE EXCEPTION:");
System.err.println(e.getMessage());
e.printStackTrace();
} else {
TestLibrary.bomb((Exception) e);
}
}
return reg;
return reg;
}
public static void makeRegistry(int p) {
// sadly, we can't kill a registry if we have too-close control
// over it. We must make it in a subprocess, and then kill the
// subprocess when it has served our needs.
// sadly, we can't kill a registry if we have too-close control
// over it. We must make it in a subprocess, and then kill the
// subprocess when it has served our needs.
try {
JavaVM jvm = new JavaVM("RegistryRunner", "", Integer.toString(p));
jvm.start();
Reexport.subreg = jvm.getVM();
try {
JavaVM jvm = new JavaVM("RegistryRunner", "", Integer.toString(p));
jvm.start();
Reexport.subreg = jvm.getVM();
} catch (IOException e) {
// one of these is summarily dropped, can't remember which one
System.out.println ("Test setup failed - cannot run rmiregistry");
TestLibrary.bomb("Test setup failed - cannot run test", e);
}
// Slop - wait for registry to come up. This is stupid.
try {
Thread.sleep (5000);
} catch (Exception whatever) {
}
} catch (IOException e) {
// one of these is summarily dropped, can't remember which one
System.out.println ("Test setup failed - cannot run rmiregistry");
TestLibrary.bomb("Test setup failed - cannot run test", e);
}
// Slop - wait for registry to come up. This is stupid.
try {
Thread.sleep (5000);
} catch (Exception whatever) {
}
}
private static Process subreg = null;
public static void killRegistry() {
if (Reexport.subreg != null) {
if (Reexport.subreg != null) {
RegistryRunner.requestExit();
RegistryRunner.requestExit();
try {
Reexport.subreg.waitFor();
} catch (InterruptedException ie) {
}
}
Reexport.subreg = null;
}
try {
Reexport.subreg.waitFor();
} catch (InterruptedException ie) {
}
}
Reexport.subreg = null;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -33,7 +33,7 @@ import java.rmi.RemoteException;
/**
* The RMI benchmark server is a simple compute-engine-like server which allows
* client benchmarks to create/export and unexport objects off of the server,
* client benchmarks to create/export and unexport objects off of the server,
* or run arbitrary tasks.
*/
public interface BenchServer extends Remote {
@ -41,41 +41,40 @@ public interface BenchServer extends Remote {
* Interface used for creating server-side remote objects.
*/
public interface RemoteObjectFactory extends Serializable {
Remote create() throws RemoteException;
Remote create() throws RemoteException;
}
/**
* Interface used for server-side tasks.
*/
public interface Task extends Serializable {
Object execute() throws Exception;
Object execute() throws Exception;
}
/**
* Uses the given remote object factory to create a new remote object on
* Uses the given remote object factory to create a new remote object on
* the server side.
*/
Remote create(RemoteObjectFactory factory) throws RemoteException;
/**
* Unexports the specified remote object. Returns true if successful,
* Unexports the specified remote object. Returns true if successful,
* false otherwise.
*/
boolean unexport(Remote obj, boolean force) throws RemoteException;
/**
* Execute given task.
*/
Object execute(Task task) throws Exception;
/**
* Invoke the garbage collector.
*/
void gc() throws RemoteException;
/**
* Terminate the server.
*/
void terminate(int delay) throws RemoteException;
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -37,8 +37,8 @@ import java.util.HashMap;
/**
* Benchmark server implementation.
*/
public class BenchServerImpl
extends UnicastRemoteObject implements BenchServer
public class BenchServerImpl
extends UnicastRemoteObject implements BenchServer
{
HashMap implTable = new HashMap();
@ -47,52 +47,51 @@ public class BenchServerImpl
*/
public BenchServerImpl() throws RemoteException {
}
/**
* 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.
*/
public Remote create(BenchServer.RemoteObjectFactory factory)
throws RemoteException
public Remote create(BenchServer.RemoteObjectFactory factory)
throws RemoteException
{
Remote impl = factory.create();
implTable.put(RemoteObject.toStub(impl), new WeakReference(impl));
return impl;
Remote impl = factory.create();
implTable.put(RemoteObject.toStub(impl), new WeakReference(impl));
return impl;
}
/**
* Unexports the specified remote object. Returns true if successful,
* Unexports the specified remote object. Returns true if successful,
* false otherwise.
*/
public boolean unexport(Remote obj, boolean force) throws RemoteException {
WeakReference iref = (WeakReference) implTable.get(obj);
if (iref == null)
return false;
Remote impl = (Remote) iref.get();
if (impl == null)
return false;
return UnicastRemoteObject.unexportObject(impl, force);
WeakReference iref = (WeakReference) implTable.get(obj);
if (iref == null)
return false;
Remote impl = (Remote) iref.get();
if (impl == null)
return false;
return UnicastRemoteObject.unexportObject(impl, force);
}
/**
* Execute given task.
*/
public Object execute(BenchServer.Task task) throws Exception {
return task.execute();
return task.execute();
}
/**
* Invoke the garbage collector.
*/
public void gc() throws RemoteException {
System.gc();
System.gc();
}
/**
* Terminate the server.
*/
public void terminate(int delay) throws RemoteException {
System.exit(0);
System.exit(0);
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject;
public class BooleanArrayCalls implements Benchmark {
interface Server extends Remote {
public boolean[] call(boolean[] a) throws RemoteException;
public boolean[] call(boolean[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public boolean[] call(boolean[] a) throws RemoteException {
return a;
}
public ServerImpl() throws RemoteException {
}
public boolean[] call(boolean[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue boolean array calls.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
boolean[] array = new boolean[size];
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
boolean[] array = new boolean[size];
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject;
public class BooleanCalls implements Benchmark {
interface Server extends Remote {
public boolean call(boolean val) throws RemoteException;
public boolean call(boolean val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public boolean call(boolean val) throws RemoteException {
return val;
}
public ServerImpl() throws RemoteException {
}
public boolean call(boolean val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue boolean calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call(true);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call(true);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject;
public class ByteArrayCalls implements Benchmark {
interface Server extends Remote {
public byte[] call(byte[] a) throws RemoteException;
public byte[] call(byte[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public byte[] call(byte[] a) throws RemoteException {
return a;
}
public ServerImpl() throws RemoteException {
}
public byte[] call(byte[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue byte array calls.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
byte[] array = new byte[size];
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
byte[] array = new byte[size];
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject;
public class ByteCalls implements Benchmark {
interface Server extends Remote {
public byte call(byte val) throws RemoteException;
public byte call(byte val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public byte call(byte val) throws RemoteException {
return val;
}
public ServerImpl() throws RemoteException {
}
public byte call(byte val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue byte calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call((byte) 0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call((byte) 0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject;
public class CharArrayCalls implements Benchmark {
interface Server extends Remote {
public char[] call(char[] a) throws RemoteException;
public char[] call(char[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public char[] call(char[] a) throws RemoteException {
return a;
}
public ServerImpl() throws RemoteException {
}
public char[] call(char[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue char array calls.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
char[] array = new char[size];
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
char[] array = new char[size];
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject;
public class CharCalls implements Benchmark {
interface Server extends Remote {
public char call(char val) throws RemoteException;
public char call(char val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public char call(char val) throws RemoteException {
return val;
}
public ServerImpl() throws RemoteException {
}
public char call(char val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue char calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call('0');
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call('0');
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -45,16 +45,15 @@ public class ClassLoading implements Benchmark {
* Arguments: <# reps>
*/
public long run(String[] args) throws Exception {
int reps = Integer.parseInt(args[0]);
CodeSource csrc = getClass().getProtectionDomain().getCodeSource();
String url = "jar:" + csrc.getLocation().toString() + ALTROOT;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
RMIClassLoader.loadClass(url, CLASSNAME);
long time = System.currentTimeMillis() - start;
return time;
int reps = Integer.parseInt(args[0]);
CodeSource csrc = getClass().getProtectionDomain().getCodeSource();
String url = "jar:" + csrc.getLocation().toString() + ALTROOT;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
RMIClassLoader.loadClass(url, CLASSNAME);
long time = System.currentTimeMillis() - start;
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject;
public class DoubleArrayCalls implements Benchmark {
interface Server extends Remote {
public double[] call(double[] a) throws RemoteException;
public double[] call(double[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public double[] call(double[] a) throws RemoteException {
return a;
}
public ServerImpl() throws RemoteException {
}
public double[] call(double[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue double array calls.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
double[] array = new double[size];
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
double[] array = new double[size];
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject;
public class DoubleCalls implements Benchmark {
interface Server extends Remote {
public double call(double val) throws RemoteException;
public double call(double val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public double call(double val) throws RemoteException {
return val;
}
public ServerImpl() throws RemoteException {
}
public double call(double val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue double calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call(0.0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call(0.0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -41,43 +41,42 @@ public class ExceptionCalls implements Benchmark {
}
interface Server extends Remote {
public void call() throws RemoteException, FooException;
public void call() throws RemoteException, FooException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public void call() throws RemoteException, FooException {
throw new FooException();
}
public ServerImpl() throws RemoteException {
}
public void call() throws RemoteException, FooException {
throw new FooException();
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue calls which throw exceptions.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int reps = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int reps = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++) {
try {
stub.call();
} catch (FooException e) {}
}
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++) {
try {
stub.call();
} catch (FooException e) {}
}
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.rmi.server.UnicastRemoteObject;
* Benchmark for testing speed of UnicastRemoteObject.exportObject().
*/
public class ExportObjs implements Benchmark {
static class RemoteObj implements Remote {
}
@ -44,19 +44,18 @@ public class ExportObjs implements Benchmark {
* Arguments: <# objects>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
Remote[] objs = new Remote[size];
for (int i = 0; i < size; i++)
objs[i] = new RemoteObj();
long start = System.currentTimeMillis();
for (int i = 0; i < size; i++)
UnicastRemoteObject.exportObject(objs[i],0);
long time = System.currentTimeMillis() - start;
for (int i = 0; i < size; i++)
UnicastRemoteObject.unexportObject(objs[i], true);
return time;
int size = Integer.parseInt(args[0]);
Remote[] objs = new Remote[size];
for (int i = 0; i < size; i++)
objs[i] = new RemoteObj();
long start = System.currentTimeMillis();
for (int i = 0; i < size; i++)
UnicastRemoteObject.exportObject(objs[i],0);
long time = System.currentTimeMillis() - start;
for (int i = 0; i < size; i++)
UnicastRemoteObject.unexportObject(objs[i], true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject;
public class FloatArrayCalls implements Benchmark {
interface Server extends Remote {
public float[] call(float[] a) throws RemoteException;
public float[] call(float[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public float[] call(float[] a) throws RemoteException {
return a;
}
public ServerImpl() throws RemoteException {
}
public float[] call(float[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue float array calls.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
float[] array = new float[size];
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
float[] array = new float[size];
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject;
public class FloatCalls implements Benchmark {
interface Server extends Remote {
public float call(float val) throws RemoteException;
public float call(float val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public float call(float val) throws RemoteException {
return val;
}
public ServerImpl() throws RemoteException {
}
public float call(float val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue float calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call((float) 0.0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call((float) 0.0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject;
public class IntArrayCalls implements Benchmark {
interface Server extends Remote {
public int[] call(int[] a) throws RemoteException;
public int[] call(int[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public int[] call(int[] a) throws RemoteException {
return a;
}
public ServerImpl() throws RemoteException {
}
public int[] call(int[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue int array calls.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int[] array = new int[size];
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int[] array = new int[size];
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject;
public class IntCalls implements Benchmark {
interface Server extends Remote {
public int call(int val) throws RemoteException;
public int call(int val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public int call(int val) throws RemoteException {
return val;
}
public ServerImpl() throws RemoteException {
}
public int call(int val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue int calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call(0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call(0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject;
public class LongArrayCalls implements Benchmark {
interface Server extends Remote {
public long[] call(long[] a) throws RemoteException;
public long[] call(long[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public long[] call(long[] a) throws RemoteException {
return a;
}
public ServerImpl() throws RemoteException {
}
public long[] call(long[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue long array calls.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long[] array = new long[size];
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long[] array = new long[size];
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject;
public class LongCalls implements Benchmark {
interface Server extends Remote {
public long call(long val) throws RemoteException;
public long call(long val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public long call(long val) throws RemoteException {
return val;
}
public ServerImpl() throws RemoteException {
}
public long call(long val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue long calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call(0L);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call(0L);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -47,35 +47,35 @@ import java.rmi.server.RemoteObject;
import java.util.Timer;
import java.util.TimerTask;
/*
/*
* RMI/Serialization benchmark tests.
*/
public class Main {
/**
* RMI-specific benchmark harness.
*/
static class RMIHarness extends Harness {
/**
* Construct new RMI benchmark harness.
*/
RMIHarness(InputStream in) throws IOException, ConfigFormatException {
super(in);
}
/**
* Cleanup both client and server side in between each benchmark.
*/
protected void cleanup() {
System.gc();
if (Main.runmode == CLIENT) {
try {
Main.server.gc();
} catch (Exception e) {
System.err.println("Warning: server gc failed: " + e);
}
}
}
/**
* Construct new RMI benchmark harness.
*/
RMIHarness(InputStream in) throws IOException, ConfigFormatException {
super(in);
}
/**
* Cleanup both client and server side in between each benchmark.
*/
protected void cleanup() {
System.gc();
if (Main.runmode == CLIENT) {
try {
Main.server.gc();
} catch (Exception e) {
System.err.println("Warning: server gc failed: " + e);
}
}
}
}
static final String CONFFILE = "/bench/rmi/config";
@ -85,7 +85,7 @@ public class Main {
static final int SAMEVM = 0;
static final int CLIENT = 1;
static final int SERVER = 2;
static final int TEXT = 0;
static final int HTML = 1;
static final int XML = 2;
@ -111,7 +111,7 @@ public class Main {
* Returns reference to benchmark server.
*/
public static BenchServer getBenchServer() {
return server;
return server;
}
/**
@ -127,252 +127,252 @@ public class Main {
p.println(" -t <num hours> repeat benchmarks for specified number of hours");
p.println(" -o <file> specify output file");
p.println(" -c <file> specify (non-default) " +
"configuration file");
"configuration file");
p.println(" -html format output as html " +
"(default is text)");
"(default is text)");
p.println(" -xml format output as xml");
p.println(" -client <host:port> run benchmark client using server " +
"on specified host/port");
p.println(" -server <port> run benchmark server on given port");
p.println(" -client <host:port> run benchmark client using server " +
"on specified host/port");
p.println(" -server <port> run benchmark server on given port");
}
/**
* Print error message and exit.
*/
static void die(String mesg) {
System.err.println(mesg);
System.exit(1);
System.err.println(mesg);
System.exit(1);
}
/**
* Stop server and exit.
*/
public static void exit() {
switch (runmode) {
case CLIENT:
if (server != null) {
try {
server.terminate(0);
} catch (RemoteException re) {
// ignore
}
}
default:
System.exit(0);
}
switch (runmode) {
case CLIENT:
if (server != null) {
try {
server.terminate(0);
} catch (RemoteException re) {
// ignore
}
}
default:
System.exit(0);
}
}
/**
* Benchmark mainline.
*/
public static void main(String[] args) {
setupSecurity();
parseArgs(args);
setupStreams();
if (list) {
listConfig();
} else {
setupServer();
if (runmode != SERVER) {
setupHarness();
setupReporter();
if (exitOnTimer) {
setupTimer(testDurationSeconds);
while (true) {
runBenchmarks();
if (exitRequested) {
exit();
}
}
} else {
runBenchmarks();
exit();
}
}
}
setupSecurity();
parseArgs(args);
setupStreams();
if (list) {
listConfig();
} else {
setupServer();
if (runmode != SERVER) {
setupHarness();
setupReporter();
if (exitOnTimer) {
setupTimer(testDurationSeconds);
while (true) {
runBenchmarks();
if (exitRequested) {
exit();
}
}
} else {
runBenchmarks();
exit();
}
}
}
}
/**
* Parse command-line arguments.
*/
static void parseArgs(String[] args) {
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-h")) {
usage();
System.exit(0);
} else if (args[i].equals("-v")) {
verbose = true;
} else if (args[i].equals("-l")) {
list = true;
} else if (args[i].equals("-t")) {
if (++i >= args.length)
die("Error: no timeout value specified");
try {
exitOnTimer = true;
testDurationSeconds = Integer.parseInt(args[i]) * 3600;
} catch (Exception e) {
die("Error: unable to determine timeout value");
}
} else if (args[i].equals("-o")) {
if (++i >= args.length)
die("Error: no output file specified");
try {
repstr = new FileOutputStream(args[i]);
} catch (IOException e) {
die("Error: unable to open \"" + args[i] + "\"");
}
} else if (args[i].equals("-c")) {
if (++i >= args.length)
die("Error: no config file specified");
try {
confstr = new FileInputStream(args[i]);
} catch (IOException e) {
die("Error: unable to open \"" + args[i] + "\"");
}
} else if (args[i].equals("-html")) {
if (format != TEXT)
die("Error: conflicting formats");
format = HTML;
} else if (args[i].equals("-xml")) {
if (format != TEXT)
die("Error: conflicting formats");
format = XML;
} else if (args[i].equals("-client")) {
if (runmode == CLIENT)
die("Error: multiple -client options");
if (runmode == SERVER)
die("Error: -client and -server options conflict");
if (++i >= args.length)
die("Error: -client missing host/port");
try {
int sepi = args[i].indexOf(':');
host = args[i].substring(0, sepi);
port = Integer.parseInt(args[i].substring(sepi + 1));
} catch (Exception e) {
die("Error: illegal host/port specified for -client");
}
runmode = CLIENT;
} else if (args[i].equals("-server")) {
if (runmode == CLIENT)
die("Error: -client and -server options conflict");
if (runmode == SERVER)
die("Error: multiple -server options");
if (++i >= args.length)
die("Error: -server missing port");
try {
port = Integer.parseInt(args[i]);
} catch (Exception e) {
die("Error: illegal port specified for -server");
}
runmode = SERVER;
} else {
System.err.println("Illegal option: \"" + args[i] + "\"");
usage();
System.exit(1);
}
}
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-h")) {
usage();
System.exit(0);
} else if (args[i].equals("-v")) {
verbose = true;
} else if (args[i].equals("-l")) {
list = true;
} else if (args[i].equals("-t")) {
if (++i >= args.length)
die("Error: no timeout value specified");
try {
exitOnTimer = true;
testDurationSeconds = Integer.parseInt(args[i]) * 3600;
} catch (Exception e) {
die("Error: unable to determine timeout value");
}
} else if (args[i].equals("-o")) {
if (++i >= args.length)
die("Error: no output file specified");
try {
repstr = new FileOutputStream(args[i]);
} catch (IOException e) {
die("Error: unable to open \"" + args[i] + "\"");
}
} else if (args[i].equals("-c")) {
if (++i >= args.length)
die("Error: no config file specified");
try {
confstr = new FileInputStream(args[i]);
} catch (IOException e) {
die("Error: unable to open \"" + args[i] + "\"");
}
} else if (args[i].equals("-html")) {
if (format != TEXT)
die("Error: conflicting formats");
format = HTML;
} else if (args[i].equals("-xml")) {
if (format != TEXT)
die("Error: conflicting formats");
format = XML;
} else if (args[i].equals("-client")) {
if (runmode == CLIENT)
die("Error: multiple -client options");
if (runmode == SERVER)
die("Error: -client and -server options conflict");
if (++i >= args.length)
die("Error: -client missing host/port");
try {
int sepi = args[i].indexOf(':');
host = args[i].substring(0, sepi);
port = Integer.parseInt(args[i].substring(sepi + 1));
} catch (Exception e) {
die("Error: illegal host/port specified for -client");
}
runmode = CLIENT;
} else if (args[i].equals("-server")) {
if (runmode == CLIENT)
die("Error: -client and -server options conflict");
if (runmode == SERVER)
die("Error: multiple -server options");
if (++i >= args.length)
die("Error: -server missing port");
try {
port = Integer.parseInt(args[i]);
} catch (Exception e) {
die("Error: illegal port specified for -server");
}
runmode = SERVER;
} else {
System.err.println("Illegal option: \"" + args[i] + "\"");
usage();
System.exit(1);
}
}
}
/**
* Set up security manager and policy, if not set already.
*/
static void setupSecurity() {
if (System.getSecurityManager() != null)
return;
/* As of 1.4, it is too late to set the security policy
* file at this point so these line have been commented out.
*/
//System.setProperty("java.security.policy",
// Main.class.getResource("/bench/rmi/policy.all").toString());
System.setSecurityManager(new RMISecurityManager());
if (System.getSecurityManager() != null)
return;
/* As of 1.4, it is too late to set the security policy
* file at this point so these line have been commented out.
*/
//System.setProperty("java.security.policy",
// Main.class.getResource("/bench/rmi/policy.all").toString());
System.setSecurityManager(new RMISecurityManager());
}
/**
* Set up configuration file and report streams, if not set already.
*/
static void setupStreams() {
if (repstr == null)
repstr = System.out;
if (confstr == null)
confstr = (new Main()).getClass().getResourceAsStream(CONFFILE);
if (confstr == null)
die("Error: unable to find default config file");
if (repstr == null)
repstr = System.out;
if (confstr == null)
confstr = (new Main()).getClass().getResourceAsStream(CONFFILE);
if (confstr == null)
die("Error: unable to find default config file");
}
/**
* Print contents of configuration file to selected output stream.
*/
static void listConfig() {
try {
byte[] buf = new byte[256];
int len;
while ((len = confstr.read(buf)) != -1)
repstr.write(buf, 0, len);
} catch (IOException e) {
die("Error: failed to list config file");
}
try {
byte[] buf = new byte[256];
int len;
while ((len = confstr.read(buf)) != -1)
repstr.write(buf, 0, len);
} catch (IOException e) {
die("Error: failed to list config file");
}
}
/**
* Setup benchmark server.
*/
static void setupServer() {
switch (runmode) {
case SAMEVM:
try {
serverImpl = new BenchServerImpl();
server = (BenchServer) RemoteObject.toStub(serverImpl);
} catch (Exception e) {
die("Error: failed to create local server: " + e);
}
if (verbose)
System.out.println("Benchmark server created locally");
break;
case CLIENT:
try {
Registry reg = LocateRegistry.getRegistry(host, port);
server = (BenchServer) reg.lookup(REGNAME);
} catch (Exception e) {
die("Error: failed to connect to server: " + e);
}
if (server == null) {
die("Error: server not found");
}
if (verbose) {
System.out.println("Connected to benchmark server on " +
host + ":" + port);
}
break;
case SERVER:
try {
Registry reg = LocateRegistry.createRegistry(port);
serverImpl = new BenchServerImpl();
reg.bind(REGNAME, serverImpl);
} catch (Exception e) {
die("Error: failed to initialize server: " + e);
}
if (verbose) {
System.out.println("Benchmark server started on port " +
port);
}
break;
default:
throw new InternalError("illegal runmode");
}
switch (runmode) {
case SAMEVM:
try {
serverImpl = new BenchServerImpl();
server = (BenchServer) RemoteObject.toStub(serverImpl);
} catch (Exception e) {
die("Error: failed to create local server: " + e);
}
if (verbose)
System.out.println("Benchmark server created locally");
break;
case CLIENT:
try {
Registry reg = LocateRegistry.getRegistry(host, port);
server = (BenchServer) reg.lookup(REGNAME);
} catch (Exception e) {
die("Error: failed to connect to server: " + e);
}
if (server == null) {
die("Error: server not found");
}
if (verbose) {
System.out.println("Connected to benchmark server on " +
host + ":" + port);
}
break;
case SERVER:
try {
Registry reg = LocateRegistry.createRegistry(port);
serverImpl = new BenchServerImpl();
reg.bind(REGNAME, serverImpl);
} catch (Exception e) {
die("Error: failed to initialize server: " + e);
}
if (verbose) {
System.out.println("Benchmark server started on port " +
port);
}
break;
default:
throw new InternalError("illegal runmode");
}
}
/**
* Set up the timer to end the test.
*
* @param delay the amount of delay, in seconds, before requesting
* @param delay the amount of delay, in seconds, before requesting
* the process exit
*/
static void setupTimer(int delay) {
timer = new Timer(true);
timer = new Timer(true);
timer.schedule(
new TimerTask() {
public void run() {
@ -391,12 +391,12 @@ public class Main {
} catch (ConfigFormatException e) {
String errmsg = e.getMessage();
if (errmsg != null) {
die("Error parsing config file: " + errmsg);
} else {
die("Error parsing config file: " + errmsg);
} else {
die("Error: illegal config file syntax");
}
}
} catch (IOException e) {
die("Error: failed to read config file");
die("Error: failed to read config file");
}
}
@ -405,24 +405,24 @@ public class Main {
*/
static void setupReporter() {
String title = "RMI Benchmark, v" + VERSION;
switch (format) {
case TEXT:
reporter = new TextReporter(repstr, title);
break;
case HTML:
reporter = new HtmlReporter(repstr, title);
break;
switch (format) {
case TEXT:
reporter = new TextReporter(repstr, title);
break;
case XML:
reporter = new XmlReporter(repstr, title);
break;
default:
die("Error: unrecognized format type");
}
case HTML:
reporter = new HtmlReporter(repstr, title);
break;
case XML:
reporter = new XmlReporter(repstr, title);
break;
default:
die("Error: unrecognized format type");
}
}
/**
* Run benchmarks.
*/
@ -430,4 +430,3 @@ public class Main {
harness.runBenchmarks(reporter, verbose);
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,39 +38,38 @@ import java.rmi.server.UnicastRemoteObject;
public class NullCalls implements Benchmark {
interface Server extends Remote {
public void call() throws RemoteException;
public void call() throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public void call() throws RemoteException {
}
public ServerImpl() throws RemoteException {
}
public void call() throws RemoteException {
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue null calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int reps = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int reps = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call();
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call();
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -41,16 +41,16 @@ public class ObjArrayCalls implements Benchmark {
static class Node implements Serializable {
boolean z;
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -61,44 +61,43 @@ public class ObjArrayCalls implements Benchmark {
}
interface Server extends Remote {
public Node[] call(Node[] a) throws RemoteException;
public Node[] call(Node[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public ServerImpl() throws RemoteException {
}
public Node[] call(Node[] a) throws RemoteException {
return a;
}
public Node[] call(Node[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue calls using arrays of objects as parameters/return values.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Node[] nodes = new Node[size];
for (int i = 0; i < size; i++)
nodes[i] = new Node(null, 0);
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Node[] nodes = new Node[size];
for (int i = 0; i < size; i++)
nodes[i] = new Node(null, 0);
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(nodes);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(nodes);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -41,16 +41,16 @@ public class ObjTreeCalls implements Benchmark {
static class Node implements Serializable {
boolean z;
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -61,42 +61,41 @@ public class ObjTreeCalls implements Benchmark {
}
interface Server extends Remote {
public Node call(Node val) throws RemoteException;
public Node call(Node val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public ServerImpl() throws RemoteException {
}
public Node call(Node val) throws RemoteException {
return val;
}
public Node call(Node val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue calls using trees of objects as parameters/return values.
* Arguments: <tree depth> <# calls>
*/
public long run(String[] args) throws Exception {
int depth = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Node node = new Node(null, depth);
int depth = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Node node = new Node(null, depth);
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(node);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(node);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -44,52 +44,52 @@ import java.rmi.server.UnicastRemoteObject;
public class ProxyArrayCalls implements Benchmark {
static class DummyHandler implements InvocationHandler, Serializable {
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
return null;
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
return null;
}
}
public static interface DummyInterface {
public void foo();
public void foo();
}
interface Server extends Remote {
public Proxy[] call(Proxy[] a) throws RemoteException;
public Proxy[] call(Proxy[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public ServerImpl() throws RemoteException {
}
public Proxy[] call(Proxy[] a) throws RemoteException {
return a;
}
public Proxy[] call(Proxy[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Generate proxy object array of the given size.
*/
Proxy[] genProxies(int size) throws Exception {
Class proxyClass =
Proxy.getProxyClass(DummyInterface.class.getClassLoader(),
new Class[] { DummyInterface.class });
Constructor proxyCons =
proxyClass.getConstructor(new Class[] { InvocationHandler.class });
Object[] consArgs = new Object[] { new DummyHandler() };
Proxy[] proxies = new Proxy[size];
Class proxyClass =
Proxy.getProxyClass(DummyInterface.class.getClassLoader(),
new Class[] { DummyInterface.class });
Constructor proxyCons =
proxyClass.getConstructor(new Class[] { InvocationHandler.class });
Object[] consArgs = new Object[] { new DummyHandler() };
Proxy[] proxies = new Proxy[size];
for (int i = 0; i < size; i++)
proxies[i] = (Proxy) proxyCons.newInstance(consArgs);
for (int i = 0; i < size; i++)
proxies[i] = (Proxy) proxyCons.newInstance(consArgs);
return proxies;
return proxies;
}
/**
@ -97,19 +97,18 @@ public class ProxyArrayCalls implements Benchmark {
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Proxy[] proxies = genProxies(size);
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Proxy[] proxies = genProxies(size);
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(proxies);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(proxies);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,49 +39,48 @@ import java.rmi.server.UnicastRemoteObject;
public class RemoteObjArrayCalls implements Benchmark {
static class RemoteObj extends UnicastRemoteObject implements Remote {
RemoteObj() throws RemoteException {
}
RemoteObj() throws RemoteException {
}
}
interface Server extends Remote {
public Remote[] call(Remote[] a) throws RemoteException;
public Remote[] call(Remote[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public ServerImpl() throws RemoteException {
}
public Remote[] call(Remote[] a) throws RemoteException {
return a;
}
public Remote[] call(Remote[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue calls using arrays of remote objects as parameters/return values.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Remote[] objs = new Remote[size];
for (int i = 0; i < size; i++)
objs[i] = new RemoteObj();
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Remote[] objs = new Remote[size];
for (int i = 0; i < size; i++)
objs[i] = new RemoteObj();
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(objs);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(objs);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -20,7 +20,7 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
*
*/
@ -39,42 +39,41 @@ import java.rmi.server.UnicastRemoteObject;
public class ShortArrayCalls implements Benchmark {
interface Server extends Remote {
public short[] call(short[] a) throws RemoteException;
public short[] call(short[] a) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public short[] call(short[] a) throws RemoteException {
return a;
}
public ServerImpl() throws RemoteException {
}
public short[] call(short[] a) throws RemoteException {
return a;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue short array calls.
* Arguments: <array size> <# calls>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
short[] array = new short[size];
int size = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
short[] array = new short[size];
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(array);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,40 +38,39 @@ import java.rmi.server.UnicastRemoteObject;
public class ShortCalls implements Benchmark {
interface Server extends Remote {
public short call(short val) throws RemoteException;
public short call(short val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public short call(short val) throws RemoteException {
return val;
}
public ServerImpl() throws RemoteException {
}
public short call(short val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue short calls.
* Arguments: <# calls>
*/
public long run(String[] args) throws Exception {
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
int cycles = Integer.parseInt(args[0]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call((short) 0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < cycles; i++)
stub.call((short) 0);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -41,7 +41,7 @@ public class SmallObjTreeCalls implements Benchmark {
static class Node implements Serializable {
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -52,42 +52,41 @@ public class SmallObjTreeCalls implements Benchmark {
}
interface Server extends Remote {
public Node call(Node val) throws RemoteException;
public Node call(Node val) throws RemoteException;
}
static class ServerImpl extends UnicastRemoteObject implements Server {
public ServerImpl() throws RemoteException {
}
public ServerImpl() throws RemoteException {
}
public Node call(Node val) throws RemoteException {
return val;
}
public Node call(Node val) throws RemoteException {
return val;
}
}
static class ServerFactory implements BenchServer.RemoteObjectFactory {
public Remote create() throws RemoteException {
return new ServerImpl();
}
public Remote create() throws RemoteException {
return new ServerImpl();
}
}
/**
* Issue calls using trees of small objects as parameters/return values.
* Arguments: <tree depth> <# calls>
*/
public long run(String[] args) throws Exception {
int depth = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Node node = new Node(null, depth);
int depth = Integer.parseInt(args[0]);
int reps = Integer.parseInt(args[1]);
BenchServer bsrv = Main.getBenchServer();
Server stub = (Server) bsrv.create(new ServerFactory());
Node node = new Node(null, depth);
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(node);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
long start = System.currentTimeMillis();
for (int i = 0; i < reps; i++)
stub.call(node);
long time = System.currentTimeMillis() - start;
bsrv.unexport(stub, true);
return time;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of boolean array reads/writes.
*/
public class BooleanArrays implements Benchmark {
/**
* Write and read boolean arrays to/from a stream. The benchmark is run in
* batches, with each batch consisting of a fixed number of read/write
@ -44,44 +44,42 @@ public class BooleanArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
boolean[][] arrays = new boolean[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
boolean[][] arrays = new boolean[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, boolean[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, boolean[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of boolean reads/writes.
*/
public class Booleans implements Benchmark {
/**
* Write and read boolean values to/from a stream. The benchmark is run in
* batches: each "batch" consists of a fixed number of read/write cycles,
@ -44,40 +44,38 @@ public class Booleans implements Benchmark {
* Arguments: <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, 1, ncycles); // warmup
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
doReps(oout, oin, sbuf, 1, ncycles); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeBoolean(false);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readBoolean();
}
}
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeBoolean(false);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readBoolean();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of byte array reads/writes.
*/
public class ByteArrays implements Benchmark {
/**
* Write and read byte arrays to/from a stream. The benchmark is run in
* batches, with each batch consisting of a fixed number of read/write
@ -44,44 +44,42 @@ public class ByteArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
byte[][] arrays = new byte[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
byte[][] arrays = new byte[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, byte[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, byte[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of byte reads/writes.
*/
public class Bytes implements Benchmark {
/**
* Write and read byte values to/from a stream. The benchmark is run in
* batches: each "batch" consists of a fixed number of read/write cycles,
@ -44,39 +44,38 @@ public class Bytes implements Benchmark {
* Arguments: <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, 1, ncycles); // warmup
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
doReps(oout, oin, sbuf, 1, ncycles); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeByte(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readByte();
}
}
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeByte(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readByte();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of char array reads/writes.
*/
public class CharArrays implements Benchmark {
/**
* Write and read char arrays to/from a stream. The benchmark is run in
* batches, with each batch consisting of a fixed number of read/write
@ -44,44 +44,42 @@ public class CharArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
char[][] arrays = new char[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
char[][] arrays = new char[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, char[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, char[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of char reads/writes.
*/
public class Chars implements Benchmark {
/**
* Write and read char values to/from a stream. The benchmark is run in
* batches: each "batch" consists of a fixed number of read/write cycles,
@ -44,39 +44,38 @@ public class Chars implements Benchmark {
* Arguments: <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, 1, ncycles); // warmup
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
doReps(oout, oin, sbuf, 1, ncycles); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeChar('0');
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readChar();
}
}
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeChar('0');
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readChar();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -89,41 +89,40 @@ public class ClassDesc implements Benchmark {
static class Dummy48 extends Dummy47 { Dummy48 i48; }
static class Dummy49 extends Dummy48 { Dummy49 i49; }
static class Dummy50 extends Dummy49 { Dummy50 i50; }
/**
* Write and read class descriptors to/from a stream.
* Arguments: <# cycles>
*/
public long run(String[] args) throws Exception {
int ncycles = Integer.parseInt(args[0]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
ObjectStreamClass desc = ObjectStreamClass.lookup(Dummy50.class);
doReps(oout, oin, sbuf, desc, 1); // warmup
int ncycles = Integer.parseInt(args[0]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
ObjectStreamClass desc = ObjectStreamClass.lookup(Dummy50.class);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, desc, ncycles);
doReps(oout, oin, sbuf, desc, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, desc, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of cycles.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, ObjectStreamClass desc, int ncycles)
throws Exception
StreamBuffer sbuf, ObjectStreamClass desc, int ncycles)
throws Exception
{
for (int i = 0; i < ncycles; i++) {
sbuf.reset();
oout.reset();
oout.writeObject(desc);
oout.flush();
oin.readObject();
}
for (int i = 0; i < ncycles; i++) {
sbuf.reset();
oout.reset();
oout.writeObject(desc);
oout.flush();
oin.readObject();
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -53,29 +53,28 @@ public class Cons implements Benchmark {
public long run(String[] args) throws Exception {
int reps = Integer.parseInt(args[0]);
Dummy dummy = new Dummy();
StreamBuffer sbuf = new StreamBuffer();
doReps(sbuf, dummy, 1); // warmup
StreamBuffer sbuf = new StreamBuffer();
long start = System.currentTimeMillis();
doReps(sbuf, dummy, reps);
doReps(sbuf, dummy, 1); // warmup
long start = System.currentTimeMillis();
doReps(sbuf, dummy, reps);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of cycles.
*/
void doReps(StreamBuffer sbuf, Dummy dummy, int reps) throws Exception {
OutputStream out = sbuf.getOutputStream();
InputStream in = sbuf.getInputStream();
for (int i = 0; i < reps; i++) {
sbuf.reset();
ObjectOutputStream oout = new ObjectOutputStream(out);
oout.writeObject(dummy);
oout.flush();
ObjectInputStream oin = new ObjectInputStream(in);
oin.readObject();
}
OutputStream out = sbuf.getOutputStream();
InputStream in = sbuf.getInputStream();
for (int i = 0; i < reps; i++) {
sbuf.reset();
ObjectOutputStream oout = new ObjectOutputStream(out);
oout.writeObject(dummy);
oout.flush();
ObjectInputStream oin = new ObjectInputStream(in);
oin.readObject();
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,19 +39,19 @@ import java.io.Serializable;
* defaultWriteObject() and defaultReadObject().
*/
public class CustomDefaultObjTrees implements Benchmark {
static class Node implements Serializable {
boolean z;
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -61,13 +61,13 @@ public class CustomDefaultObjTrees implements Benchmark {
}
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.defaultWriteObject();
}
private void readObject(ObjectInputStream in)
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
in.defaultReadObject();
in.defaultReadObject();
}
}
@ -79,20 +79,20 @@ public class CustomDefaultObjTrees implements Benchmark {
* Arguments: <tree depth> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, trees, 1); // warmup
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
doReps(oout, oin, sbuf, trees, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
return System.currentTimeMillis() - start;
}
@ -100,33 +100,32 @@ public class CustomDefaultObjTrees implements Benchmark {
* Generate object trees.
*/
Node[] genTrees(int depth, int ntrees) {
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
}
/**
* Run benchmark for given number of batches, with each batch containing
* Run benchmark for given number of batches, with each batch containing
* the given number of cycles.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
{
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,19 +38,19 @@ import java.io.Serializable;
* nodes contain custom writeObject() and readObject() methods.
*/
public class CustomObjTrees implements Benchmark {
static class Node implements Serializable {
boolean z;
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -60,35 +60,35 @@ public class CustomObjTrees implements Benchmark {
}
private void writeObject(ObjectOutputStream out) throws IOException {
out.writeBoolean(z);
out.writeByte(b);
out.writeChar(c);
out.writeShort(s);
out.writeInt(i);
out.writeFloat(f);
out.writeLong(j);
out.writeDouble(d);
out.writeObject(str);
out.writeObject(parent);
out.writeObject(left);
out.writeObject(right);
out.writeBoolean(z);
out.writeByte(b);
out.writeChar(c);
out.writeShort(s);
out.writeInt(i);
out.writeFloat(f);
out.writeLong(j);
out.writeDouble(d);
out.writeObject(str);
out.writeObject(parent);
out.writeObject(left);
out.writeObject(right);
}
private void readObject(ObjectInputStream in)
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
}
@ -100,20 +100,20 @@ public class CustomObjTrees implements Benchmark {
* Arguments: <tree depth> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, trees, 1); // warmup
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
doReps(oout, oin, sbuf, trees, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
return System.currentTimeMillis() - start;
}
@ -121,33 +121,32 @@ public class CustomObjTrees implements Benchmark {
* Generate object trees.
*/
Node[] genTrees(int depth, int ntrees) {
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
}
/**
* Run benchmark for given number of batches, with each batch containing
* Run benchmark for given number of batches, with each batch containing
* the given number of cycles.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
{
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of double array reads/writes.
*/
public class DoubleArrays implements Benchmark {
/**
* Write and read double arrays to/from a stream. The benchmark is run in
* batches, with each batch consisting of a fixed number of read/write
@ -44,44 +44,42 @@ public class DoubleArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
double[][] arrays = new double[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
double[][] arrays = new double[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, double[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, double[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of double reads/writes.
*/
public class Doubles implements Benchmark {
/**
* Write and read double values to/from a stream. The benchmark is run in
* batches: each "batch" consists of a fixed number of read/write cycles,
@ -44,39 +44,38 @@ public class Doubles implements Benchmark {
* Arguments: <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, 1, ncycles); // warmup
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
doReps(oout, oin, sbuf, 1, ncycles); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeDouble(0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readDouble();
}
}
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeDouble(0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readDouble();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -40,19 +40,19 @@ import java.io.ObjectOutputStream;
* objects.
*/
public class ExternObjTrees implements Benchmark {
static class Node implements Externalizable {
boolean z;
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -61,40 +61,40 @@ public class ExternObjTrees implements Benchmark {
}
}
public Node() {
}
public void writeExternal(ObjectOutput out) throws IOException {
out.writeBoolean(z);
out.writeByte(b);
out.writeChar(c);
out.writeShort(s);
out.writeInt(i);
out.writeFloat(f);
out.writeLong(j);
out.writeDouble(d);
out.writeObject(str);
out.writeObject(parent);
out.writeObject(left);
out.writeObject(right);
}
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
public Node() {
}
public void writeExternal(ObjectOutput out) throws IOException {
out.writeBoolean(z);
out.writeByte(b);
out.writeChar(c);
out.writeShort(s);
out.writeInt(i);
out.writeFloat(f);
out.writeLong(j);
out.writeDouble(d);
out.writeObject(str);
out.writeObject(parent);
out.writeObject(left);
out.writeObject(right);
}
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
}
/**
@ -105,20 +105,20 @@ public class ExternObjTrees implements Benchmark {
* Arguments: <tree depth> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, trees, 1); // warmup
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
doReps(oout, oin, sbuf, trees, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
return System.currentTimeMillis() - start;
}
@ -126,33 +126,32 @@ public class ExternObjTrees implements Benchmark {
* Generate object trees.
*/
Node[] genTrees(int depth, int ntrees) {
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
}
/**
* Run benchmark for given number of batches, with each batch containing
* Run benchmark for given number of batches, with each batch containing
* the given number of cycles.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
{
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of float array reads/writes.
*/
public class FloatArrays implements Benchmark {
/**
* Write and read float arrays to/from a stream. The benchmark is run in
* batches, with each batch consisting of a fixed number of read/write
@ -44,44 +44,42 @@ public class FloatArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
float[][] arrays = new float[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
float[][] arrays = new float[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, float[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, float[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of float reads/writes.
*/
public class Floats implements Benchmark {
/**
* Write and read float values to/from a stream. The benchmark is run in
* batches: each "batch" consists of a fixed number of read/write cycles,
@ -44,39 +44,38 @@ public class Floats implements Benchmark {
* Arguments: <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, 1, ncycles); // warmup
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
doReps(oout, oin, sbuf, 1, ncycles); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeFloat((float) 0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readFloat();
}
}
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeFloat((float) 0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readFloat();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,19 +39,19 @@ import java.io.Serializable;
* GetField()/PutField() API.
*/
public class GetPutFieldTrees implements Benchmark {
static class Node implements Serializable {
boolean z;
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -76,19 +76,19 @@ public class GetPutFieldTrees implements Benchmark {
fields.put("right", right);
out.writeFields();
}
private void readObject(ObjectInputStream in)
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
ObjectInputStream.GetField fields = in.readFields();
z = fields.get("z", false);
b = fields.get("b", (byte) 0);
c = fields.get("c", (char) 0);
s = fields.get("s", (short) 0);
i = fields.get("i", (int) 0);
f = fields.get("f", (float) 0.0);
j = fields.get("j", (long) 0);
d = fields.get("d", (double) 0.0);
z = fields.get("z", false);
b = fields.get("b", (byte) 0);
c = fields.get("c", (char) 0);
s = fields.get("s", (short) 0);
i = fields.get("i", (int) 0);
f = fields.get("f", (float) 0.0);
j = fields.get("j", (long) 0);
d = fields.get("d", (double) 0.0);
str = (String) fields.get("str", null);
parent = fields.get("parent", null);
left = fields.get("left", null);
@ -104,20 +104,20 @@ public class GetPutFieldTrees implements Benchmark {
* Arguments: <tree depth> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, trees, 1); // warmup
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
doReps(oout, oin, sbuf, trees, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
return System.currentTimeMillis() - start;
}
@ -125,33 +125,32 @@ public class GetPutFieldTrees implements Benchmark {
* Generate object trees.
*/
Node[] genTrees(int depth, int ntrees) {
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
}
/**
* Run benchmark for given number of batches, with each batch containing
* Run benchmark for given number of batches, with each batch containing
* the given number of cycles.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
{
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of int array reads/writes.
*/
public class IntArrays implements Benchmark {
/**
* Write and read int arrays to/from a stream. The benchmark is run in
* batches, with each batch consisting of a fixed number of read/write
@ -44,44 +44,42 @@ public class IntArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
int[][] arrays = new int[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
int[][] arrays = new int[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, int[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of int reads/writes.
*/
public class Ints implements Benchmark {
/**
* Write and read int values to/from a stream. The benchmark is run in
* batches: each "batch" consists of a fixed number of read/write cycles,
@ -44,39 +44,38 @@ public class Ints implements Benchmark {
* Arguments: <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, 1, ncycles); // warmup
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
doReps(oout, oin, sbuf, 1, ncycles); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeInt(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readInt();
}
}
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeInt(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readInt();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of long array reads/writes.
*/
public class LongArrays implements Benchmark {
/**
* Write and read long arrays to/from a stream. The benchmark is run in
* batches, with each batch consisting of a fixed number of read/write
@ -44,44 +44,42 @@ public class LongArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
long[][] arrays = new long[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
long[][] arrays = new long[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, long[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, long[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of long reads/writes.
*/
public class Longs implements Benchmark {
/**
* Write and read long values to/from a stream. The benchmark is run in
* batches: each "batch" consists of a fixed number of read/write cycles,
@ -44,39 +44,38 @@ public class Longs implements Benchmark {
* Arguments: <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, 1, ncycles); // warmup
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
doReps(oout, oin, sbuf, 1, ncycles); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeLong(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readLong();
}
}
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeLong(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readLong();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -46,7 +46,7 @@ import java.util.TimerTask;
* Object serialization benchmark mainline.
*/
public class Main {
static final String CONFFILE = "/bench/serial/config";
static final String VERSION = "1.3";
@ -80,55 +80,55 @@ public class Main {
p.println(" -o <file> specify output file");
p.println(" -c <file> specify (non-default) configuration file");
p.println(" -html format output as html (default is text)");
p.println(" -xml format output as xml");
p.println(" -xml format output as xml");
}
/**
* Print error message and exit.
*/
static void die(String mesg) {
System.err.println(mesg);
System.exit(1);
System.err.println(mesg);
System.exit(1);
}
/**
* Mainline parses command line, then hands off to benchmark harness.
*/
public static void main(String[] args) {
parseArgs(args);
setupStreams();
if (list) {
listConfig();
} else {
setupHarness();
setupReporter();
if (exitOnTimer) {
setupTimer(testDurationSeconds);
while (true) {
runBenchmarks();
if (exitRequested) {
System.exit(0);
}
}
} else {
runBenchmarks();
System.exit(0);
}
}
parseArgs(args);
setupStreams();
if (list) {
listConfig();
} else {
setupHarness();
setupReporter();
if (exitOnTimer) {
setupTimer(testDurationSeconds);
while (true) {
runBenchmarks();
if (exitRequested) {
System.exit(0);
}
}
} else {
runBenchmarks();
System.exit(0);
}
}
}
/**
* Parse command-line arguments.
*/
static void parseArgs(String[] args) {
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-h")) {
usage();
System.exit(0);
} else if (args[i].equals("-v")) {
verbose = true;
} else if (args[i].equals("-l")) {
list = true;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-h")) {
usage();
System.exit(0);
} else if (args[i].equals("-v")) {
verbose = true;
} else if (args[i].equals("-l")) {
list = true;
} else if (args[i].equals("-t")) {
if (++i >= args.length)
die("Error: no timeout value specified");
@ -138,64 +138,64 @@ public class Main {
} catch (Exception e) {
die("Error: unable to determine timeout value");
}
} else if (args[i].equals("-o")) {
if (++i >= args.length)
die("Error: no output file specified");
try {
repstr = new FileOutputStream(args[i]);
} catch (IOException e) {
die("Error: unable to open \"" + args[i] + "\"");
}
} else if (args[i].equals("-c")) {
if (++i >= args.length)
die("Error: no config file specified");
try {
confstr = new FileInputStream(args[i]);
} catch (IOException e) {
die("Error: unable to open \"" + args[i] + "\"");
}
} else if (args[i].equals("-html")) {
if (format != TEXT)
die("Error: conflicting formats");
format = HTML;
} else if (args[i].equals("-xml")) {
if (format != TEXT)
die("Error: conflicting formats");
format = XML;
} else {
System.err.println("Illegal option: \"" + args[i] + "\"");
usage();
System.exit(1);
}
}
} else if (args[i].equals("-o")) {
if (++i >= args.length)
die("Error: no output file specified");
try {
repstr = new FileOutputStream(args[i]);
} catch (IOException e) {
die("Error: unable to open \"" + args[i] + "\"");
}
} else if (args[i].equals("-c")) {
if (++i >= args.length)
die("Error: no config file specified");
try {
confstr = new FileInputStream(args[i]);
} catch (IOException e) {
die("Error: unable to open \"" + args[i] + "\"");
}
} else if (args[i].equals("-html")) {
if (format != TEXT)
die("Error: conflicting formats");
format = HTML;
} else if (args[i].equals("-xml")) {
if (format != TEXT)
die("Error: conflicting formats");
format = XML;
} else {
System.err.println("Illegal option: \"" + args[i] + "\"");
usage();
System.exit(1);
}
}
}
/**
* Set up configuration file and report streams, if not set already.
*/
static void setupStreams() {
if (repstr == null)
repstr = System.out;
if (confstr == null)
confstr = (new Main()).getClass().getResourceAsStream(CONFFILE);
if (confstr == null)
die("Error: unable to find default config file");
if (repstr == null)
repstr = System.out;
if (confstr == null)
confstr = (new Main()).getClass().getResourceAsStream(CONFFILE);
if (confstr == null)
die("Error: unable to find default config file");
}
/**
* Print contents of configuration file to selected output stream.
*/
static void listConfig() {
try {
byte[] buf = new byte[256];
int len;
while ((len = confstr.read(buf)) != -1)
repstr.write(buf, 0, len);
} catch (IOException e) {
die("Error: failed to list config file");
}
try {
byte[] buf = new byte[256];
int len;
while ((len = confstr.read(buf)) != -1)
repstr.write(buf, 0, len);
} catch (IOException e) {
die("Error: failed to list config file");
}
}
/**
* Set up the timer to end the test.
*
@ -222,12 +222,12 @@ public class Main {
} catch (ConfigFormatException e) {
String errmsg = e.getMessage();
if (errmsg != null) {
die("Error parsing config file: " + errmsg);
} else {
die("Error parsing config file: " + errmsg);
} else {
die("Error: illegal config file syntax");
}
}
} catch (IOException e) {
die("Error: failed to read config file");
die("Error: failed to read config file");
}
}
@ -236,22 +236,22 @@ public class Main {
*/
static void setupReporter() {
String title = "Object Serialization Benchmark, v" + VERSION;
switch (format) {
case TEXT:
reporter = new TextReporter(repstr, title);
break;
case HTML:
reporter = new HtmlReporter(repstr, title);
break;
switch (format) {
case TEXT:
reporter = new TextReporter(repstr, title);
break;
case XML:
reporter = new XmlReporter(repstr, title);
break;
default:
die("Error: unrecognized format type");
}
case HTML:
reporter = new HtmlReporter(repstr, title);
break;
case XML:
reporter = new XmlReporter(repstr, title);
break;
default:
die("Error: unrecognized format type");
}
}
/**
@ -261,4 +261,3 @@ public class Main {
harness.runBenchmarks(reporter, verbose);
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -39,16 +39,16 @@ public class ObjArrays implements Benchmark {
static class Node implements Serializable {
boolean z;
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -57,7 +57,7 @@ public class ObjArrays implements Benchmark {
}
}
}
/**
* Write and read object arrays to/from a stream. The benchmark is run in
* batches, with each batch consisting of a fixed number of read/write
@ -66,34 +66,34 @@ public class ObjArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[][] arrays = genArrays(size, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[][] arrays = genArrays(size, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Generate object arrays.
*/
Node[][] genArrays(int size, int narrays) {
Node[][] arrays = new Node[narrays][size];
for (int i = 0; i < narrays; i++) {
for (int j = 0; j < size; j++) {
arrays[i][j] = new Node(null, 0);
}
}
return arrays;
Node[][] arrays = new Node[narrays][size];
for (int i = 0; i < narrays; i++) {
for (int j = 0; j < size; j++) {
arrays[i][j] = new Node(null, 0);
}
}
return arrays;
}
/**
@ -101,22 +101,20 @@ public class ObjArrays implements Benchmark {
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Node[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, Node[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -36,19 +36,19 @@ import java.io.Serializable;
* Benchmark for testing speed of writes and reads of an object tree.
*/
public class ObjTrees implements Benchmark {
static class Node implements Serializable {
boolean z;
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
byte b;
char c;
short s;
int i;
float f;
long j;
double d;
String str = "bodega";
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -66,20 +66,20 @@ public class ObjTrees implements Benchmark {
* Arguments: <tree depth> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, trees, 1); // warmup
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
doReps(oout, oin, sbuf, trees, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
return System.currentTimeMillis() - start;
}
@ -87,33 +87,32 @@ public class ObjTrees implements Benchmark {
* Generate object trees.
*/
Node[] genTrees(int depth, int ntrees) {
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
}
/**
* Run benchmark for given number of batches, with each batch containing
* Run benchmark for given number of batches, with each batch containing
* the given number of cycles.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
{
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -42,15 +42,15 @@ import java.lang.reflect.Proxy;
public class ProxyArrays implements Benchmark {
static class DummyHandler implements InvocationHandler, Serializable {
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
return null;
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
return null;
}
}
static interface DummyInterface {
public void foo();
public void foo();
}
/**
@ -61,40 +61,40 @@ public class ProxyArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Proxy[][] arrays = genArrays(size, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Proxy[][] arrays = genArrays(size, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Generate proxy arrays.
*/
Proxy[][] genArrays(int size, int narrays) throws Exception {
Class proxyClass =
Proxy.getProxyClass(DummyInterface.class.getClassLoader(),
new Class[] { DummyInterface.class });
Constructor proxyCons =
proxyClass.getConstructor(new Class[] { InvocationHandler.class });
Object[] consArgs = new Object[] { new DummyHandler() };
Proxy[][] arrays = new Proxy[narrays][size];
for (int i = 0; i < narrays; i++) {
for (int j = 0; j < size; j++) {
arrays[i][j] = (Proxy) proxyCons.newInstance(consArgs);
}
}
return arrays;
Class proxyClass =
Proxy.getProxyClass(DummyInterface.class.getClassLoader(),
new Class[] { DummyInterface.class });
Constructor proxyCons =
proxyClass.getConstructor(new Class[] { InvocationHandler.class });
Object[] consArgs = new Object[] { new DummyHandler() };
Proxy[][] arrays = new Proxy[narrays][size];
for (int i = 0; i < narrays; i++) {
for (int j = 0; j < size; j++) {
arrays[i][j] = (Proxy) proxyCons.newInstance(consArgs);
}
}
return arrays;
}
/**
@ -102,22 +102,20 @@ public class ProxyArrays implements Benchmark {
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Proxy[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, Proxy[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -38,7 +38,7 @@ import java.lang.reflect.Proxy;
* Benchmark for testing speed of proxy class descriptor reads/writes.
*/
public class ProxyClassDesc implements Benchmark {
static interface A1 {};
static interface A2 {};
static interface A3 {};
@ -54,75 +54,74 @@ public class ProxyClassDesc implements Benchmark {
static interface C3 {};
static interface C4 {};
static interface C5 {};
/**
* Write and read proxy class descriptors to/from a stream.
* Arguments: <# cycles>
*/
public long run(String[] args) throws Exception {
int ncycles = Integer.parseInt(args[0]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
ObjectStreamClass[] descs = genDescs();
int ncycles = Integer.parseInt(args[0]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
ObjectStreamClass[] descs = genDescs();
doReps(oout, oin, sbuf, descs, 1); // warmup
doReps(oout, oin, sbuf, descs, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, descs, ncycles);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, descs, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Generate proxy class descriptors.
*/
ObjectStreamClass[] genDescs() {
ClassLoader ldr = ProxyClassDesc.class.getClassLoader();
Class[] ifaces = new Class[3];
Class[] a =
new Class[] { A1.class, A2.class, A3.class, A4.class, A5.class };
Class[] b =
new Class[] { B1.class, B2.class, B3.class, B4.class, B5.class };
Class[] c =
new Class[] { C1.class, C2.class, C3.class, C4.class, C5.class };
ObjectStreamClass[] descs =
new ObjectStreamClass[a.length * b.length * c.length];
int n = 0;
for (int i = 0; i < a.length; i++) {
ifaces[0] = a[i];
for (int j = 0; j < b.length; j++) {
ifaces[1] = b[j];
for (int k = 0; k < c.length; k++) {
ifaces[2] = c[k];
Class proxyClass = Proxy.getProxyClass(ldr, ifaces);
descs[n++] = ObjectStreamClass.lookup(proxyClass);
}
}
}
return descs;
ClassLoader ldr = ProxyClassDesc.class.getClassLoader();
Class[] ifaces = new Class[3];
Class[] a =
new Class[] { A1.class, A2.class, A3.class, A4.class, A5.class };
Class[] b =
new Class[] { B1.class, B2.class, B3.class, B4.class, B5.class };
Class[] c =
new Class[] { C1.class, C2.class, C3.class, C4.class, C5.class };
ObjectStreamClass[] descs =
new ObjectStreamClass[a.length * b.length * c.length];
int n = 0;
for (int i = 0; i < a.length; i++) {
ifaces[0] = a[i];
for (int j = 0; j < b.length; j++) {
ifaces[1] = b[j];
for (int k = 0; k < c.length; k++) {
ifaces[2] = c[k];
Class proxyClass = Proxy.getProxyClass(ldr, ifaces);
descs[n++] = ObjectStreamClass.lookup(proxyClass);
}
}
}
return descs;
}
/**
* Run benchmark for given number of cycles.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, ObjectStreamClass[] descs, int ncycles)
throws Exception
StreamBuffer sbuf, ObjectStreamClass[] descs, int ncycles)
throws Exception
{
int ndescs = descs.length;
for (int i = 0; i < ncycles; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ndescs; j++) {
oout.writeObject(descs[j]);
}
oout.flush();
for (int j = 0; j < ndescs; j++) {
oin.readObject();
}
}
int ndescs = descs.length;
for (int i = 0; i < ncycles; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ndescs; j++) {
oout.writeObject(descs[j]);
}
oout.flush();
for (int j = 0; j < ndescs; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -36,7 +36,7 @@ import java.io.Serializable;
* Benchmark for testing speed of reads/writes of repeated objects.
*/
public class RepeatObjs implements Benchmark {
static class Node implements Serializable {
}
@ -49,50 +49,49 @@ public class RepeatObjs implements Benchmark {
* Arguments: <# objects> <# cycles>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
Node[] objs = genObjs(size);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, objs, 1); // warmup
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
Node[] objs = genObjs(size);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, objs, nbatches);
doReps(oout, oin, sbuf, objs, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, objs, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Generate objects.
*/
Node[] genObjs(int nobjs) {
Node[] objs = new Node[nobjs];
for (int i = 0; i < nobjs; i++)
objs[i] = new Node();
return objs;
Node[] objs = new Node[nobjs];
for (int i = 0; i < nobjs; i++)
objs[i] = new Node();
return objs;
}
/**
* Run benchmark for given number of batches.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Node[] objs, int nbatches)
throws Exception
StreamBuffer sbuf, Node[] objs, int nbatches)
throws Exception
{
int nobjs = objs.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < nobjs; j++) {
oout.writeObject(objs[j]);
}
oout.flush();
for (int j = 0; j < nobjs; j++) {
oin.readObject();
}
}
int nobjs = objs.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < nobjs; j++) {
oout.writeObject(objs[j]);
}
oout.flush();
for (int j = 0; j < nobjs; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -37,15 +37,15 @@ import java.io.Serializable;
* objects.
*/
public class ReplaceTrees implements Benchmark {
static class Node implements Serializable {
Object parent, left, right;
Node(Object parent, Object left, Object right) {
this.parent = parent;
this.left = left;
this.right = right;
}
Node(Object parent, Object left, Object right) {
this.parent = parent;
this.left = left;
this.right = right;
}
Node(Object parent, int depth) {
this.parent = parent;
@ -54,26 +54,26 @@ public class ReplaceTrees implements Benchmark {
right = new Node(this, depth - 1);
}
}
Object writeReplace() {
return new RepNode(parent, left, right);
}
Object writeReplace() {
return new RepNode(parent, left, right);
}
}
static class RepNode implements Serializable {
Object parent, left, right;
RepNode(Object parent, Object left, Object right) {
this.parent = parent;
this.left = left;
this.right = right;
}
Object readResolve() {
return new Node(parent, left, right);
}
Object parent, left, right;
RepNode(Object parent, Object left, Object right) {
this.parent = parent;
this.left = left;
this.right = right;
}
Object readResolve() {
return new Node(parent, left, right);
}
}
/**
* Write and read a tree of replaceable objects from a stream. The
* benchmark is run in batches: each "batch" consists of a fixed number of
@ -82,20 +82,20 @@ public class ReplaceTrees implements Benchmark {
* Arguments: <tree depth> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, trees, 1); // warmup
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
doReps(oout, oin, sbuf, trees, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
return System.currentTimeMillis() - start;
}
@ -103,11 +103,11 @@ public class ReplaceTrees implements Benchmark {
* Generate object trees.
*/
Node[] genTrees(int depth, int ntrees) {
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
}
/**
@ -115,21 +115,20 @@ public class ReplaceTrees implements Benchmark {
* the given number of cycles.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
{
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of short array reads/writes.
*/
public class ShortArrays implements Benchmark {
/**
* Write and read short arrays to/from a stream. The benchmark is run in
* batches, with each batch consisting of a fixed number of read/write
@ -44,44 +44,42 @@ public class ShortArrays implements Benchmark {
* Arguments: <array size> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
short[][] arrays = new short[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
int size = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
short[][] arrays = new short[ncycles][size];
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, arrays, 1); // warmup
doReps(oout, oin, sbuf, arrays, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, arrays, nbatches);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, short[][] arrays, int nbatches)
throws Exception
StreamBuffer sbuf, short[][] arrays, int nbatches)
throws Exception
{
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = arrays.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(arrays[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -35,7 +35,7 @@ import java.io.ObjectOutputStream;
* Benchmark for testing speed of short reads/writes.
*/
public class Shorts implements Benchmark {
/**
* Write and read short values to/from a stream. The benchmark is run in
* batches: each "batch" consists of a fixed number of read/write cycles,
@ -44,39 +44,38 @@ public class Shorts implements Benchmark {
* Arguments: <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, 1, ncycles); // warmup
int nbatches = Integer.parseInt(args[0]);
int ncycles = Integer.parseInt(args[1]);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
doReps(oout, oin, sbuf, 1, ncycles); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
/**
* Run benchmark for given number of batches, with given number of cycles
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
StreamBuffer sbuf, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeShort(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readShort();
}
}
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeShort(0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readShort();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -36,10 +36,10 @@ import java.io.Serializable;
* Benchmark for testing speed of writes and reads of a tree of small objects.
*/
public class SmallObjTrees implements Benchmark {
static class Node implements Serializable {
Object parent, left, right;
Node(Object parent, int depth) {
this.parent = parent;
if (depth > 0) {
@ -57,20 +57,20 @@ public class SmallObjTrees implements Benchmark {
* Arguments: <tree depth> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, trees, 1); // warmup
int depth = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
Node[] trees = genTrees(depth, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
doReps(oout, oin, sbuf, trees, 1); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, trees, nbatches);
return System.currentTimeMillis() - start;
}
@ -78,11 +78,11 @@ public class SmallObjTrees implements Benchmark {
* Generate object trees.
*/
Node[] genTrees(int depth, int ntrees) {
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
Node[] trees = new Node[ntrees];
for (int i = 0; i < ntrees; i++) {
trees[i] = new Node(null, depth);
}
return trees;
}
/**
@ -90,21 +90,20 @@ public class SmallObjTrees implements Benchmark {
* given number of cycles.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
StreamBuffer sbuf, Node[] trees, int nbatches)
throws Exception
{
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
int ncycles = trees.length;
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(trees[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -47,85 +47,85 @@ import java.io.IOException;
* StreamBufferInputStream.read().
*/
public class StreamBuffer {
/**
* Output stream for writing to stream buffer.
*/
private class StreamBufferOutputStream extends OutputStream {
private int pos;
public void write(int b) throws IOException {
if (mode != WRITE_MODE)
throw new IOException();
while (pos >= buf.length)
grow();
buf[pos++] = (byte) b;
}
public void write(byte[] b, int off, int len) throws IOException {
if (mode != WRITE_MODE)
throw new IOException();
while (pos + len > buf.length)
grow();
System.arraycopy(b, off, buf, pos, len);
pos += len;
}
public void close() throws IOException {
if (mode != WRITE_MODE)
throw new IOException();
mode = READ_MODE;
}
private int pos;
public void write(int b) throws IOException {
if (mode != WRITE_MODE)
throw new IOException();
while (pos >= buf.length)
grow();
buf[pos++] = (byte) b;
}
public void write(byte[] b, int off, int len) throws IOException {
if (mode != WRITE_MODE)
throw new IOException();
while (pos + len > buf.length)
grow();
System.arraycopy(b, off, buf, pos, len);
pos += len;
}
public void close() throws IOException {
if (mode != WRITE_MODE)
throw new IOException();
mode = READ_MODE;
}
}
/**
* Input stream for reading from stream buffer.
*/
private class StreamBufferInputStream extends InputStream {
private int pos;
public int read() throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = READ_MODE;
return (pos < out.pos) ? (buf[pos++] & 0xFF) : -1;
}
public int read(byte[] b, int off, int len) throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = READ_MODE;
int avail = out.pos - pos;
int rlen = (avail < len) ? avail : len;
System.arraycopy(buf, pos, b, off, rlen);
pos += rlen;
return rlen;
}
public long skip(long len) throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = READ_MODE;
int avail = out.pos - pos;
long slen = (avail < len) ? avail : len;
pos += slen;
return slen;
}
private int pos;
public int available() throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = READ_MODE;
return out.pos - pos;
}
public void close() throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = CLOSED_MODE;
}
public int read() throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = READ_MODE;
return (pos < out.pos) ? (buf[pos++] & 0xFF) : -1;
}
public int read(byte[] b, int off, int len) throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = READ_MODE;
int avail = out.pos - pos;
int rlen = (avail < len) ? avail : len;
System.arraycopy(buf, pos, b, off, rlen);
pos += rlen;
return rlen;
}
public long skip(long len) throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = READ_MODE;
int avail = out.pos - pos;
long slen = (avail < len) ? avail : len;
pos += slen;
return slen;
}
public int available() throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = READ_MODE;
return out.pos - pos;
}
public void close() throws IOException {
if (mode == CLOSED_MODE)
throw new IOException();
mode = CLOSED_MODE;
}
}
private static final int START_BUFSIZE = 256;
@ -140,30 +140,29 @@ public class StreamBuffer {
private int mode = WRITE_MODE;
public StreamBuffer() {
this(START_BUFSIZE);
this(START_BUFSIZE);
}
public StreamBuffer(int size) {
buf = new byte[size];
buf = new byte[size];
}
public OutputStream getOutputStream() {
return out;
return out;
}
public InputStream getInputStream() {
return in;
return in;
}
public void reset() {
in.pos = out.pos = 0;
mode = WRITE_MODE;
in.pos = out.pos = 0;
mode = WRITE_MODE;
}
private void grow() {
byte[] newbuf = new byte[buf.length * GROW_FACTOR];
System.arraycopy(buf, 0, newbuf, 0, buf.length);
buf = newbuf;
byte[] newbuf = new byte[buf.length * GROW_FACTOR];
System.arraycopy(buf, 0, newbuf, 0, buf.length);
buf = newbuf;
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -45,20 +45,20 @@ public class Strings implements Benchmark {
* Arguments: <string length> <# batches> <# cycles per batch>
*/
public long run(String[] args) throws Exception {
int slen = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
String[] strs = genStrings(slen, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
doReps(oout, oin, sbuf, strs, 1, ncycles); // warmup
int slen = Integer.parseInt(args[0]);
int nbatches = Integer.parseInt(args[1]);
int ncycles = Integer.parseInt(args[2]);
String[] strs = genStrings(slen, ncycles);
StreamBuffer sbuf = new StreamBuffer();
ObjectOutputStream oout =
new ObjectOutputStream(sbuf.getOutputStream());
ObjectInputStream oin =
new ObjectInputStream(sbuf.getInputStream());
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, strs, nbatches, ncycles);
doReps(oout, oin, sbuf, strs, 1, ncycles); // warmup
long start = System.currentTimeMillis();
doReps(oout, oin, sbuf, strs, nbatches, ncycles);
return System.currentTimeMillis() - start;
}
@ -66,16 +66,16 @@ public class Strings implements Benchmark {
* Generate nstrings random strings, each of length len.
*/
String[] genStrings(int len, int nstrings) {
String[] strs = new String[nstrings];
char[] ca = new char[len];
Random rand = new Random(System.currentTimeMillis());
for (int i = 0; i < nstrings; i++) {
for (int j = 0; j < len; j++) {
ca[j] = (char) rand.nextInt();
}
strs[i] = new String(ca);
}
return strs;
String[] strs = new String[nstrings];
char[] ca = new char[len];
Random rand = new Random(System.currentTimeMillis());
for (int i = 0; i < nstrings; i++) {
for (int j = 0; j < len; j++) {
ca[j] = (char) rand.nextInt();
}
strs[i] = new String(ca);
}
return strs;
}
/**
@ -83,20 +83,19 @@ public class Strings implements Benchmark {
* for each batch.
*/
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
StreamBuffer sbuf, String[] strs, int nbatches, int ncycles)
throws Exception
StreamBuffer sbuf, String[] strs, int nbatches, int ncycles)
throws Exception
{
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(strs[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
for (int i = 0; i < nbatches; i++) {
sbuf.reset();
oout.reset();
for (int j = 0; j < ncycles; j++) {
oout.writeObject(strs[j]);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readObject();
}
}
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -25,7 +25,7 @@ import java.rmi.Remote;
import java.rmi.RemoteException;
/**
* A remote factory for Orange instances. This interface also
* A remote factory for Orange instances. This interface also
* includes a method to test object array serialization.
*/
public interface Apple extends Remote {

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -26,7 +26,7 @@ import java.util.Date;
/**
* The AppleEvent class is simply an object to be passed to a
* remote object exported by an applet. The intent is to verify
* remote object exported by an applet. The intent is to verify
* proper object serialization of arrays.
*/
public class AppleEvent implements Serializable {
@ -39,24 +39,24 @@ public class AppleEvent implements Serializable {
private final Date when;
public AppleEvent(int what) {
this.what = what;
this.when = new Date();
this.what = what;
this.when = new Date();
}
public String toString() {
String desc = "[";
switch (what) {
case BUY:
desc += "BUY";
break;
case EAT:
desc += "EAT";
break;
case THROW:
desc += "THROW";
break;
}
desc += " @ " + when + "]";
return desc;
String desc = "[";
switch (what) {
case BUY:
desc += "BUY";
break;
case EAT:
desc += "EAT";
break;
case THROW:
desc += "THROW";
break;
}
desc += " @ " + when + "]";
return desc;
}
}

Some files were not shown because too many files have changed in this diff Show More