summaryrefslogtreecommitdiff
path: root/libjava/classpath/java/rmi
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/classpath/java/rmi
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libjava/classpath/java/rmi')
-rw-r--r--libjava/classpath/java/rmi/AccessException.java77
-rw-r--r--libjava/classpath/java/rmi/AlreadyBoundException.java74
-rw-r--r--libjava/classpath/java/rmi/ConnectException.java74
-rw-r--r--libjava/classpath/java/rmi/ConnectIOException.java74
-rw-r--r--libjava/classpath/java/rmi/MarshalException.java76
-rw-r--r--libjava/classpath/java/rmi/MarshalledObject.java154
-rw-r--r--libjava/classpath/java/rmi/Naming.java234
-rw-r--r--libjava/classpath/java/rmi/NoSuchObjectException.java69
-rw-r--r--libjava/classpath/java/rmi/NotBoundException.java76
-rw-r--r--libjava/classpath/java/rmi/RMISecurityException.java79
-rw-r--r--libjava/classpath/java/rmi/RMISecurityManager.java48
-rw-r--r--libjava/classpath/java/rmi/Remote.java58
-rw-r--r--libjava/classpath/java/rmi/RemoteException.java128
-rw-r--r--libjava/classpath/java/rmi/ServerError.java64
-rw-r--r--libjava/classpath/java/rmi/ServerException.java74
-rw-r--r--libjava/classpath/java/rmi/ServerRuntimeException.java67
-rw-r--r--libjava/classpath/java/rmi/StubNotFoundException.java78
-rw-r--r--libjava/classpath/java/rmi/UnexpectedException.java75
-rw-r--r--libjava/classpath/java/rmi/UnknownHostException.java75
-rw-r--r--libjava/classpath/java/rmi/UnmarshalException.java88
-rw-r--r--libjava/classpath/java/rmi/activation/Activatable.java531
-rw-r--r--libjava/classpath/java/rmi/activation/ActivateFailedException.java76
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationDesc.java254
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationException.java122
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationGroup.java340
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationGroupDesc.java433
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationGroupID.java122
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java110
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationID.java199
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationInstantiator.java73
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationMonitor.java87
-rw-r--r--libjava/classpath/java/rmi/activation/ActivationSystem.java206
-rw-r--r--libjava/classpath/java/rmi/activation/Activator.java72
-rw-r--r--libjava/classpath/java/rmi/activation/UnknownGroupException.java69
-rw-r--r--libjava/classpath/java/rmi/activation/UnknownObjectException.java69
-rw-r--r--libjava/classpath/java/rmi/activation/package.html73
-rw-r--r--libjava/classpath/java/rmi/dgc/DGC.java80
-rw-r--r--libjava/classpath/java/rmi/dgc/Lease.java100
-rw-r--r--libjava/classpath/java/rmi/dgc/VMID.java191
-rw-r--r--libjava/classpath/java/rmi/dgc/package.html52
-rw-r--r--libjava/classpath/java/rmi/package.html46
-rw-r--r--libjava/classpath/java/rmi/registry/LocateRegistry.java87
-rw-r--r--libjava/classpath/java/rmi/registry/Registry.java87
-rw-r--r--libjava/classpath/java/rmi/registry/RegistryHandler.java58
-rw-r--r--libjava/classpath/java/rmi/registry/package.html46
-rw-r--r--libjava/classpath/java/rmi/server/ExportException.java78
-rw-r--r--libjava/classpath/java/rmi/server/LoaderHandler.java71
-rw-r--r--libjava/classpath/java/rmi/server/LogStream.java146
-rw-r--r--libjava/classpath/java/rmi/server/ObjID.java197
-rw-r--r--libjava/classpath/java/rmi/server/Operation.java78
-rw-r--r--libjava/classpath/java/rmi/server/RMIClassLoader.java204
-rw-r--r--libjava/classpath/java/rmi/server/RMIClassLoaderSpi.java64
-rw-r--r--libjava/classpath/java/rmi/server/RMIClientSocketFactory.java47
-rw-r--r--libjava/classpath/java/rmi/server/RMIFailureHandler.java46
-rw-r--r--libjava/classpath/java/rmi/server/RMIServerSocketFactory.java47
-rw-r--r--libjava/classpath/java/rmi/server/RMISocketFactory.java108
-rw-r--r--libjava/classpath/java/rmi/server/RemoteCall.java86
-rw-r--r--libjava/classpath/java/rmi/server/RemoteObject.java202
-rw-r--r--libjava/classpath/java/rmi/server/RemoteObjectInvocationHandler.java229
-rw-r--r--libjava/classpath/java/rmi/server/RemoteRef.java137
-rw-r--r--libjava/classpath/java/rmi/server/RemoteServer.java115
-rw-r--r--libjava/classpath/java/rmi/server/RemoteStub.java80
-rw-r--r--libjava/classpath/java/rmi/server/ServerCloneException.java117
-rw-r--r--libjava/classpath/java/rmi/server/ServerNotActiveException.java72
-rw-r--r--libjava/classpath/java/rmi/server/ServerRef.java51
-rw-r--r--libjava/classpath/java/rmi/server/Skeleton.java57
-rw-r--r--libjava/classpath/java/rmi/server/SkeletonMismatchException.java68
-rw-r--r--libjava/classpath/java/rmi/server/SkeletonNotFoundException.java79
-rw-r--r--libjava/classpath/java/rmi/server/SocketSecurityException.java75
-rw-r--r--libjava/classpath/java/rmi/server/UID.java225
-rw-r--r--libjava/classpath/java/rmi/server/UnicastRemoteObject.java251
-rw-r--r--libjava/classpath/java/rmi/server/Unreferenced.java43
-rw-r--r--libjava/classpath/java/rmi/server/package.html46
73 files changed, 8344 insertions, 0 deletions
diff --git a/libjava/classpath/java/rmi/AccessException.java b/libjava/classpath/java/rmi/AccessException.java
new file mode 100644
index 000000000..c14b87675
--- /dev/null
+++ b/libjava/classpath/java/rmi/AccessException.java
@@ -0,0 +1,77 @@
+/* AccessException.java -- thrown if the caller does not have access
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown to indicate that the caller does not have permission to access
+ * certain data, such as <code>bind</code> in an ActivationSystem.
+ *
+ * @author unknown
+ * @see Naming
+ * @see java.rmi.activation.ActivationSystem
+ * @since 1.1
+ */
+public class AccessException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 6314925228044966088l;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public AccessException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public AccessException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/AlreadyBoundException.java b/libjava/classpath/java/rmi/AlreadyBoundException.java
new file mode 100644
index 000000000..c56a4ee85
--- /dev/null
+++ b/libjava/classpath/java/rmi/AlreadyBoundException.java
@@ -0,0 +1,74 @@
+/* AlreadyBoundException.java -- thrown if a binding is already bound
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown on an attempt to bind an object in the registry that is already
+ * bound.
+ *
+ * @author unknown
+ * @see java.rmi.Naming#bind(String, Remote)
+ * @see java.rmi.registry.Registry#bind(String, Remote)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class AlreadyBoundException extends Exception
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 9218657361741657110L;
+
+ /**
+ * Create an exception with no message.
+ */
+ public AlreadyBoundException()
+ {
+ }
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public AlreadyBoundException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/libjava/classpath/java/rmi/ConnectException.java b/libjava/classpath/java/rmi/ConnectException.java
new file mode 100644
index 000000000..dc3abd197
--- /dev/null
+++ b/libjava/classpath/java/rmi/ConnectException.java
@@ -0,0 +1,74 @@
+/* ConnectException.java -- thrown if a connection is refused
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if a connection is refused for a remote call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ConnectException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 4863550261346652506L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ConnectException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ConnectException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/ConnectIOException.java b/libjava/classpath/java/rmi/ConnectIOException.java
new file mode 100644
index 000000000..dde753ad5
--- /dev/null
+++ b/libjava/classpath/java/rmi/ConnectIOException.java
@@ -0,0 +1,74 @@
+/* ConnectIOException.java -- thrown if an IO exception occurs during connect
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Wraps an I/O Exception thrown while connecting for a remote call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ConnectIOException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -8087809532704668744L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ConnectIOException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ConnectIOException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/MarshalException.java b/libjava/classpath/java/rmi/MarshalException.java
new file mode 100644
index 000000000..e5c10a4bf
--- /dev/null
+++ b/libjava/classpath/java/rmi/MarshalException.java
@@ -0,0 +1,76 @@
+/* MarshalException.java -- wraps error while marshalling parameters
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if an exception occurs while marshalling data to send in a remote
+ * call. The call may not be retransmitted, if the "at most once" semantics
+ * are to be preserved.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class MarshalException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 6223554758134037936L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public MarshalException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public MarshalException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/MarshalledObject.java b/libjava/classpath/java/rmi/MarshalledObject.java
new file mode 100644
index 000000000..a48e4c009
--- /dev/null
+++ b/libjava/classpath/java/rmi/MarshalledObject.java
@@ -0,0 +1,154 @@
+/* MarshalledObject.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi;
+
+import gnu.java.rmi.RMIMarshalledObjectInputStream;
+import gnu.java.rmi.RMIMarshalledObjectOutputStream;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * A <code>MarshalledObject</code> consists of a serialized object which is
+ * marshalled according to the RMI specification.
+ * <p>
+ * An object passed to the constructor is serialized and tagged with the needed
+ * URL to retrieve its class definition for remote usage. If the object is a
+ * remote reference its stub is serialized instead. The instance of this
+ * marshalled object can be later retrieved by its <code>get()</code> method.
+ * </p>
+ *
+ * @author unknown
+ */
+public final class MarshalledObject<T>
+ implements Serializable
+{
+ // The following fields are from Java API Documentation "Serialized form"
+ private static final long serialVersionUID = 8988374069173025854L;
+
+ byte[] objBytes;
+ byte[] locBytes;
+ int hash;
+
+ /**
+ * Constructs a <code>MarshalledObject</code> from the given object.
+ *
+ * @param obj the object to marshal
+ * @throws IOException if an I/O error during serialization occurs.
+ */
+ public MarshalledObject(T obj) throws IOException
+ {
+ ByteArrayOutputStream objStream = new ByteArrayOutputStream();
+ RMIMarshalledObjectOutputStream stream =
+ new RMIMarshalledObjectOutputStream(objStream);
+ stream.writeObject(obj);
+ stream.flush();
+ objBytes = objStream.toByteArray();
+ locBytes = stream.getLocBytes();
+
+ // The following algorithm of calculating hashCode is similar to String
+ hash = 0;
+ for (int i = 0; i < objBytes.length; i++)
+ hash = hash * 31 + objBytes[i];
+
+ if (locBytes != null)
+ for (int i = 0; i < locBytes.length; i++)
+ hash = hash * 31 + locBytes[i];
+ }
+
+ /**
+ * Checks if the given object is equal to this marshalled object.
+ *
+ * <p>Marshalled objects are considered equal if they contain the
+ * same serialized object. Codebase annotations where the class
+ * definition can be downloaded are ignored in the equals test.</p>
+ *
+ * @param obj the object to compare.
+ * @return <code>true</code> if equal, <code>false</code> otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (! (obj instanceof MarshalledObject))
+ return false;
+
+ // hashCode even differs, don't do the time-consuming comparisons
+ if (obj.hashCode() != hash)
+ return false;
+
+ MarshalledObject aobj = (MarshalledObject) obj;
+ if (objBytes == null || aobj.objBytes == null)
+ return objBytes == aobj.objBytes;
+ if (objBytes.length != aobj.objBytes.length)
+ return false;
+ for (int i = 0; i < objBytes.length; i++)
+ {
+ if (objBytes[i] != aobj.objBytes[i])
+ return false;
+ }
+ // Ignore comparison of locBytes(annotation)
+ return true;
+ }
+
+ /**
+ * Constructs and returns a copy of the internal serialized object.
+ *
+ * @return The deserialized object.
+ *
+ * @throws IOException if an I/O exception occurs during deserialization.
+ * @throws ClassNotFoundException if the class of the deserialized object
+ * cannot be found.
+ */
+ public T get() throws IOException, ClassNotFoundException
+ {
+ if (objBytes == null)
+ return null;
+
+ RMIMarshalledObjectInputStream stream =
+ new RMIMarshalledObjectInputStream(objBytes, locBytes);
+ return (T) stream.readObject();
+ }
+
+ public int hashCode()
+ {
+ return hash;
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/Naming.java b/libjava/classpath/java/rmi/Naming.java
new file mode 100644
index 000000000..7f74add7a
--- /dev/null
+++ b/libjava/classpath/java/rmi/Naming.java
@@ -0,0 +1,234 @@
+/* Naming.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+/**
+ * <p>
+ * The <code>Naming</code> class handles interactions with RMI registries.
+ * Each method takes a URL in <code>String</code> form, which points to
+ * the RMI registry. The scheme of the URL is irrelevant. The relevant
+ * part is:
+ * </p>
+ * <p>
+ * <code>//host:port/name</code>
+ * </p>
+ * <p>
+ * which tells the method how to locate and access the registry. The host
+ * and port are both optional, and default to `localhost' and the standard
+ * RMI registry port (1099) respectively. The name is simply a string
+ * used to refer to a particular service hosted by the registry. The
+ * registry does not attempt to interpret this further.
+ * </p>
+ * <p>
+ * RMI services are registered using one of these names, and the same name
+ * is later used by the client to lookup the service and access its methods.
+ * Registries can be shared by multiple services, or a service can create
+ * its own registry using <code>createRegistry()</code>.
+ * </p>
+ *
+ * @author Original author unknown.
+ * @author Ingo Proetel (proetel@aicas.com)
+ * @author Guilhem Lavaux (guilhem@kaffe.org)
+ * @author Jeroen Frijters (jeroen@frijters.net)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @since 1.1
+ */
+public final class Naming
+{
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private Naming()
+ {
+ }
+
+ /**
+ * Looks for the remote object that is associated with the named service.
+ * Name and location is given in form of a URL without a scheme:
+ *
+ * <pre>
+ * //host:port/service-name
+ * </pre>
+ *
+ * The port is optional.
+ *
+ * @param name the service name and location
+ * @return Remote-object that implements the named service
+ * @throws NotBoundException if no object implements the service
+ * @throws MalformedURLException
+ * @throws RemoteException
+ */
+ public static Remote lookup(String name) throws NotBoundException,
+ MalformedURLException, RemoteException
+ {
+ URL u = parseURL(name);
+ String serviceName = getName(u);
+ return (getRegistry(u).lookup(serviceName));
+ }
+
+ /**
+ * Try to bind the given object to the given service name.
+ *
+ * @param name
+ * @param obj
+ * @throws AlreadyBoundException
+ * @throws MalformedURLException
+ * @throws RemoteException
+ */
+ public static void bind(String name, Remote obj)
+ throws AlreadyBoundException, MalformedURLException, RemoteException
+ {
+ URL u = parseURL(name);
+ String serviceName = getName(u);
+ getRegistry(u).bind(serviceName, obj);
+ }
+
+ /**
+ * Remove a binding for a given service name.
+ *
+ * @param name
+ * @throws RemoteException
+ * @throws NotBoundException
+ * @throws MalformedURLException
+ */
+ public static void unbind(String name) throws RemoteException,
+ NotBoundException, MalformedURLException
+ {
+ URL u = parseURL(name);
+ String serviceName = getName(u);
+ getRegistry(u).unbind(serviceName);
+ }
+
+ /**
+ * Forces the binding between the given Remote-object and the given service
+ * name, even if there was already an object bound to this name.
+ *
+ * @param name
+ * @param obj
+ * @throws RemoteException
+ * @throws MalformedURLException
+ */
+ public static void rebind(String name, Remote obj) throws RemoteException,
+ MalformedURLException
+ {
+ URL u = parseURL(name);
+ String serviceName = getName(u);
+ getRegistry(u).rebind(serviceName, obj);
+ }
+
+ /**
+ * Lists all services at the named registry.
+ *
+ * @param name url that specifies the registry
+ * @return list of services at the name registry
+ * @throws RemoteException
+ * @throws MalformedURLException
+ */
+ public static String[] list(String name) throws RemoteException,
+ MalformedURLException
+ {
+ return (getRegistry(parseURL(name)).list());
+ }
+
+ private static Registry getRegistry(URL u) throws RemoteException
+ {
+ if (u.getPort() == - 1)
+ {
+ return (LocateRegistry.getRegistry(u.getHost()));
+ }
+ else
+ {
+ return (LocateRegistry.getRegistry(u.getHost(), u.getPort()));
+ }
+ }
+
+ /**
+ * Parses the supplied URL and converts it to use the HTTP protocol. From an
+ * RMI perspective, the scheme is irrelevant and we want to be able to create
+ * a URL for which a handler is available.
+ *
+ * @param name the URL in String form.
+ * @throws MalformedURLException if the URL is invalid.
+ */
+ private static URL parseURL(String name) throws MalformedURLException
+ {
+ try
+ {
+ URI uri = new URI(name);
+ String host = uri.getHost();
+ int port = uri.getPort();
+ String query = uri.getQuery();
+ String path = uri.getPath();
+ return new URL("http", (host == null ? "localhost" : host),
+ (port == - 1 ? 1099 : port), uri.getPath()
+ + (query == null ? "" : query));
+ }
+ catch (URISyntaxException e)
+ {
+ throw new MalformedURLException("The URL syntax was invalid: "
+ + e.getMessage());
+ }
+ }
+
+ /**
+ * Checks that the URL contains a name, and removes any leading slashes.
+ *
+ * @param url the URL to check.
+ * @throws MalformedURLException if no name is specified.
+ */
+ private static String getName(URL url) throws MalformedURLException
+ {
+ String filename = url.getFile();
+ if (filename.length() == 0)
+ throw new MalformedURLException("No path specified: " + url);
+ // If the filename begins with a slash we must cut it for
+ // name resolution.
+ if (filename.charAt(0) == '/')
+ return filename.substring(1);
+ return filename;
+ }
+}
diff --git a/libjava/classpath/java/rmi/NoSuchObjectException.java b/libjava/classpath/java/rmi/NoSuchObjectException.java
new file mode 100644
index 000000000..a2af433c9
--- /dev/null
+++ b/libjava/classpath/java/rmi/NoSuchObjectException.java
@@ -0,0 +1,69 @@
+/* NoSuchObjectException.java -- thrown if the remote object no longer exists
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown on an attempt to invoke a call on an object that no longer exists
+ * in the remote Virtual Machine. The call may be retransmitted and still
+ * obey the semantics of "at most once".
+ *
+ * @author unknown
+ * @see java.rmi.server.RemoteObject#toStub(Remote)
+ * @see java.rmi.server.UnicastRemoteObject#unexportObject(Remote, boolean)
+ * @see java.rmi.activation.Activatable#unexportObject(Remote, boolean)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class NoSuchObjectException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 6619395951570472985L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public NoSuchObjectException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/libjava/classpath/java/rmi/NotBoundException.java b/libjava/classpath/java/rmi/NotBoundException.java
new file mode 100644
index 000000000..fdd646857
--- /dev/null
+++ b/libjava/classpath/java/rmi/NotBoundException.java
@@ -0,0 +1,76 @@
+/* NotBoundException.java -- attempt to use a registry name with no binding
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown on an attempt to lookup or unbind a registry name that has no
+ * associated binding.
+ *
+ * @author unknown
+ * @see java.rmi.Naming#lookup(String)
+ * @see java.rmi.Naming#unbind(String)
+ * @see java.rmi.registry.Registry#lookup(String)
+ * @see java.rmi.registry.Registry#unbind(String)
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class NotBoundException extends Exception
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -1857741824849069317l;
+
+ /**
+ * Create an exception with no message.
+ */
+ public NotBoundException()
+ {
+ }
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public NotBoundException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/libjava/classpath/java/rmi/RMISecurityException.java b/libjava/classpath/java/rmi/RMISecurityException.java
new file mode 100644
index 000000000..7a2d214a3
--- /dev/null
+++ b/libjava/classpath/java/rmi/RMISecurityException.java
@@ -0,0 +1,79 @@
+/* RMISecurityException.java -- deprecated version of SecurityException
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Never thrown, but originally intended to wrap a
+ * {@link java.lang.SecurityException} in the case of RMI.
+ *
+ * @author unknown
+ * @since 1.1
+ * @deprecated use {@link java.lang.SecurityException} instead
+ * @status updated to 1.4
+ */
+public class RMISecurityException extends SecurityException
+{
+ /**
+ * Compatible with JDK 1.1.
+ */
+ private static final long serialVersionUID = -8433406075740433514L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param n the message
+ * @deprecated no longer needed
+ */
+ public RMISecurityException(String n)
+ {
+ super(n);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param n the message
+ * @param a the cause (ignored)
+ * @deprecated no longer needed
+ */
+ public RMISecurityException(String n, String a)
+ {
+ super(n);
+ }
+}
diff --git a/libjava/classpath/java/rmi/RMISecurityManager.java b/libjava/classpath/java/rmi/RMISecurityManager.java
new file mode 100644
index 000000000..3f7e1fbcf
--- /dev/null
+++ b/libjava/classpath/java/rmi/RMISecurityManager.java
@@ -0,0 +1,48 @@
+/* RMISecurityManager.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * @since 1.1
+ */
+public class RMISecurityManager extends SecurityManager
+{
+ public RMISecurityManager()
+ {
+ }
+}
diff --git a/libjava/classpath/java/rmi/Remote.java b/libjava/classpath/java/rmi/Remote.java
new file mode 100644
index 000000000..8c2720e42
--- /dev/null
+++ b/libjava/classpath/java/rmi/Remote.java
@@ -0,0 +1,58 @@
+/* Remote.java
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Marker interface for interfaces which methods are invokable
+ * from outside of this virtual machine through remote method calls.
+ * <p>
+ * Remote invokable methods of remote object implementations are specified
+ * as the methods defined in the implemented remote interfaces. Typically
+ * remote object implementations are subclasses of the convenience classes
+ * {@link java.rmi.server.UnicastRemoteObject} or
+ * {@link java.rmi.activation.Activatable} implementing one or more remote
+ * interfaces indicating their remotely accessible methods. The convenience
+ * classes provide implementations for correct remote object creation,
+ * hash, equals and toString methods.
+ * </p>
+ *
+ * @author unknown
+ */
+public interface Remote {
+ // marker interface
+}
diff --git a/libjava/classpath/java/rmi/RemoteException.java b/libjava/classpath/java/rmi/RemoteException.java
new file mode 100644
index 000000000..276aa3774
--- /dev/null
+++ b/libjava/classpath/java/rmi/RemoteException.java
@@ -0,0 +1,128 @@
+/* RemoteException.java -- common superclass for exceptions in java.rmi
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+import java.io.IOException;
+
+/**
+ * The superclass of exceptions related to RMI (remote method invocation).
+ * Classes that implement <code>java.rmi.Remote</code> should list this
+ * exception in their throws clause.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class RemoteException extends IOException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -5148567311918794206l;
+
+ /**
+ * The cause of this exception. This pre-dates the exception chaining
+ * of Throwable; and although you can change this field, you are wiser
+ * to leave it alone.
+ *
+ * @serial the exception cause
+ */
+ public Throwable detail;
+
+ /**
+ * Create an exception with no message, and cause initialized to null.
+ */
+ public RemoteException()
+ {
+ this(null, null);
+ }
+
+ /**
+ * Create an exception with the given message, and cause initialized to null.
+ *
+ * @param s the message
+ */
+ public RemoteException(String s)
+ {
+ this(s, null);
+ }
+
+ /**
+ * Create an exception with the given message and cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public RemoteException(String s, Throwable e)
+ {
+ super(s);
+ initCause(e);
+ detail = e;
+ }
+
+ /**
+ * This method returns a message indicating what went wrong, in this
+ * format:
+ * <code>super.getMessage() + (detail == null ? ""
+ * : "; nested exception is:\n\t" + detail)</code>.
+ *
+ * @return the chained message
+ */
+ public String getMessage()
+ {
+ if (detail == this || detail == null)
+ return super.getMessage();
+ return super.getMessage() + "; nested exception is:\n\t" + detail;
+ }
+
+ /**
+ * Returns the cause of this exception. Note that this may not be the
+ * original cause, thanks to the <code>detail</code> field being public
+ * and non-final (yuck). However, to avoid violating the contract of
+ * Throwable.getCause(), this returns null if <code>detail == this</code>,
+ * as no exception can be its own cause.
+ *
+ * @return the cause
+ * @since 1.4
+ */
+ public Throwable getCause()
+ {
+ return detail == this ? null : detail;
+ }
+}
diff --git a/libjava/classpath/java/rmi/ServerError.java b/libjava/classpath/java/rmi/ServerError.java
new file mode 100644
index 000000000..b1a15b02e
--- /dev/null
+++ b/libjava/classpath/java/rmi/ServerError.java
@@ -0,0 +1,64 @@
+/* ServerError.java -- wraps an error while creating the server
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Wraps any error thrown while processing the server of a remote call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ServerError extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 8455284893909696482L;
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ServerError(String s, Error e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/ServerException.java b/libjava/classpath/java/rmi/ServerException.java
new file mode 100644
index 000000000..5170aa7b0
--- /dev/null
+++ b/libjava/classpath/java/rmi/ServerException.java
@@ -0,0 +1,74 @@
+/* ServerException.java -- wraps an exception while creating the server
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Wraps any exception thrown while processing the server of a remote call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ServerException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -4775845313121906682l;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ServerException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ServerException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/ServerRuntimeException.java b/libjava/classpath/java/rmi/ServerRuntimeException.java
new file mode 100644
index 000000000..1f0813739
--- /dev/null
+++ b/libjava/classpath/java/rmi/ServerRuntimeException.java
@@ -0,0 +1,67 @@
+/* ServerRuntimeException.java -- wraps an exception while creating the server
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Wraps any runtime exception thrown while processing the server of a
+ * remote call. Note, this exception is no longer used.
+ *
+ * @author unknown
+ * @since 1.1
+ * @deprecated no replacement
+ * @status updated to 1.4
+ */
+public class ServerRuntimeException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1.
+ */
+ private static final long serialVersionUID = 7054464920481467219L;
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ * @deprecated no longer needed
+ */
+ public ServerRuntimeException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/StubNotFoundException.java b/libjava/classpath/java/rmi/StubNotFoundException.java
new file mode 100644
index 000000000..992df1217
--- /dev/null
+++ b/libjava/classpath/java/rmi/StubNotFoundException.java
@@ -0,0 +1,78 @@
+/* StubNotFoundException.java -- thrown if a valid stub is not found
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if a valid stub class is not found for an object when it is exported.
+ *
+ * @author unknown
+ * @see java.rmi.server.UnicastRemoteObject
+ * @see java.rmi.activation.Activatable
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class StubNotFoundException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -7088199405468872373L;
+
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public StubNotFoundException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public StubNotFoundException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/UnexpectedException.java b/libjava/classpath/java/rmi/UnexpectedException.java
new file mode 100644
index 000000000..e9e0d6a9d
--- /dev/null
+++ b/libjava/classpath/java/rmi/UnexpectedException.java
@@ -0,0 +1,75 @@
+/* UnexpectedException.java -- an unexpected checked exception was received
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if an unexpected checked exception was received in a remote
+ * procedure call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class UnexpectedException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 1800467484195073863L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public UnexpectedException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public UnexpectedException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/UnknownHostException.java b/libjava/classpath/java/rmi/UnknownHostException.java
new file mode 100644
index 000000000..7e77dca31
--- /dev/null
+++ b/libjava/classpath/java/rmi/UnknownHostException.java
@@ -0,0 +1,75 @@
+/* UnknownHostException.java -- wraps java.net.UnknownHostException in RMI
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if a java.net.UnknownHostException occurs during a remote
+ * procedure call.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class UnknownHostException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -8152710247442114228L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public UnknownHostException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public UnknownHostException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/UnmarshalException.java b/libjava/classpath/java/rmi/UnmarshalException.java
new file mode 100644
index 000000000..6567062a5
--- /dev/null
+++ b/libjava/classpath/java/rmi/UnmarshalException.java
@@ -0,0 +1,88 @@
+/* UnmarshalException.java -- wraps error while unmarshalling parameters
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi;
+
+/**
+ * Thrown if an exception occurs while unmarshalling parameters or results
+ * of a remote method call. This includes:<br><ul>
+ * <li>if an exception occurs while unmarshalling the call header</li>
+ * <li>if the protocol for the return value is invalid</li>
+ * <li>if a java.io.IOException occurs unmarshalling parameters (on the
+ * server side) or the return value (on the client side).</li>
+ * <li>if a java.lang.ClassNotFoundException occurs during unmarshalling
+ * parameters or return values</li>
+ * <li>if no skeleton can be loaded on the server-side; note that skeletons
+ * are required in the 1.1 stub protocol, but not in the 1.2 stub
+ * protocol.</li>
+ * <li>if the method hash is invalid (i.e., missing method).</li>
+ * <li>if there is a failure to create a remote reference object for a remote
+ * object's stub when it is unmarshalled.</li>
+ * </ul>
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class UnmarshalException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 594380845140740218l;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public UnmarshalException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public UnmarshalException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/activation/Activatable.java b/libjava/classpath/java/rmi/activation/Activatable.java
new file mode 100644
index 000000000..9ec7cad48
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/Activatable.java
@@ -0,0 +1,531 @@
+/* Activatable.java -- A common ancestor for the activatable objects.
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import gnu.java.rmi.server.ActivatableServerRef;
+import gnu.java.rmi.server.UnicastServer;
+import gnu.java.rmi.server.UnicastServerRef;
+
+import java.lang.reflect.Field;
+import java.rmi.MarshalledObject;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.RemoteServer;
+import java.rmi.server.UnicastRemoteObject;
+
+/**
+ * A common ancestor for the implementations of the activatable objects. Such
+ * objects require persistent access over time and can be activated by the
+ * system. The derived classes also implements the needed interface of some
+ * remote object and usually have the two parameter constructor, the first
+ * parameter being the {@link ActivationID} and the second the
+ * {@link MarshalledObject}. Activatable is the main class that developers need
+ * to use to implement and manage activatable objects. It also contains methods
+ * for making activatable remote objects that are not derived from the
+ * Activatable class.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org) (from stub)
+ */
+public abstract class Activatable
+ extends RemoteServer
+{
+
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 3120617863591563455L;
+
+ /**
+ * The object activation id.
+ */
+ final ActivationID id;
+
+ /**
+ * This constructor is used to register export the object on the given port. A
+ * subclass of the Activatable class calls this constructor to register and
+ * export the object during initial construction. As a side-effect of
+ * activatable object construction, the remote object is both "registered"
+ * with the activation system and "exported" (on an anonymous port, if port is
+ * zero) to the RMI runtime so that it is available to accept incoming calls
+ * from clients.
+ *
+ * @param codebase the object code base url
+ * @param data the data, needed to activate the object.
+ * @param restart specifies reactivation mode after crash. If true, the object
+ * is activated when activator is restarted or the activation group
+ * is restarted. If false, the object is only activated on demand.
+ * This flag does has no effect during the normal operation (the
+ * object is normally activated on demand).
+ * @param port the port, on which the object will become available. The value
+ * 0 means anonymous port.
+ * @throws ActivationException if the activation failed
+ * @throws RemoteException if the remote call failed.
+ */
+ protected Activatable(String codebase, MarshalledObject<?> data,
+ boolean restart, int port) throws ActivationException,
+ RemoteException
+ {
+ ActivationDesc descriptor = new ActivationDesc(getClass().getName(),
+ codebase, data, restart);
+ id = obtainId(descriptor);
+ exportObject(this, id, port);
+ }
+
+ /**
+ * This constructor is used to register export the object on the given port,
+ * additionally specifying the socket factories. A subclass of the Activatable
+ * class calls this constructor to register and export the object during
+ * initial construction.
+ *
+ * @param codebase the object code base url
+ * @param data the data, needed to activate the object.
+ * @param restart specifies reactivation mode after crash. If true, the object
+ * is activated when activator is restarted or the activation group
+ * is restarted. If false, the object is only activated on demand.
+ * This flag does has no effect during the normal operation (the
+ * object is normally activated on demand).
+ * @param port the port, on which the object will become available. The value
+ * 0 means anonymous port.
+ * @param csf the client socket factory
+ * @param ssf the server socket factory
+ * @throws ActivationException if the activation failed
+ * @throws RemoteException if the remote call failed.
+ */
+ protected Activatable(String codebase, MarshalledObject<?> data,
+ boolean restart, int port, RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf) throws ActivationException,
+ RemoteException
+ {
+ ActivationDesc descriptor = new ActivationDesc(getClass().getName(),
+ codebase, data, restart);
+ id = obtainId(descriptor);
+ exportObject(this, id, port);
+ }
+
+ /**
+ * Creates the new instance of activatable with the given activation id and is
+ * listening at the given port. A subclass of the Activatable class calls this
+ * constructor when the object itself is activated via its special
+ * "activation" constructor with the two parameters ({@link ActivationID},
+ * {@link MarshalledObject}). As a side effect, the object is exported and is
+ * available to accept incoming calls.
+ *
+ * @param anId the activation id
+ * @param port the port, on which the activatable will be listening
+ * @throws RemoteException if the activation failed.
+ */
+ protected Activatable(ActivationID anId, int port) throws RemoteException
+ {
+ id = anId;
+ try
+ {
+ exportObject(this, anId, port);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ RemoteException acex =
+ new RemoteException("cannot export Activatable", e);
+ throw acex;
+ }
+ }
+
+ /**
+ * Creates the new instance of activatable with the given activation id and is
+ * listening at the given port, using the specified client and server sockets
+ * factories. A subclass of the Activatable class calls this
+ * constructor when the object itself is activated via its special
+ * "activation" constructor with the two parameters ({@link ActivationID},
+ * {@link MarshalledObject}). As a side effect, the object is exported and is
+ * available to accept incoming calls.
+ *
+ * @param anId the activation id
+ * @param port the port, on which the activatable will be listening
+ * @param csf the client socket factory
+ * @param ssf the server socket factory
+ *
+ * @throws RemoteException if the remote call failed
+ */
+ protected Activatable(ActivationID anId, int port, RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf) throws RemoteException
+ {
+ id = anId;
+ try
+ {
+ exportObject(this, anId, port, csf, ssf);
+ }
+ catch (Exception e)
+ {
+ RemoteException acex = new RemoteException();
+ acex.initCause(e);
+ throw acex;
+ }
+ }
+
+ /**
+ * Get the objects activation identifier.
+ *
+ * @return the object activation identifier
+ */
+ protected ActivationID getID()
+ {
+ return id;
+ }
+
+ /**
+ * Obtain the activation Id from the activation descriptor by registering
+ * within the current group.
+ */
+ static ActivationID obtainId(ActivationDesc descriptor)
+ throws RemoteException, UnknownGroupException, ActivationException
+ {
+ ActivationGroupID id = descriptor.getGroupID();
+ ActivationSystem system;
+
+ if (id != null)
+ system = id.getSystem();
+ else
+ system = ActivationGroup.currentGroupID().getSystem();
+ return system.registerObject(descriptor);
+ }
+
+ /**
+ * This method registers an activatable object. The object is expected to be
+ * on the anonymous port (null client and server socket factories).
+ *
+ * @param desc the object description.
+ * @return the remote stub for the activatable object (the first call on this
+ * stub will activate the object).
+ * @throws UnknownGroupException if the object group identifier is unknown
+ * @throws ActivationException if the activation system is not running
+ * @throws RemoteException if the remote call fails
+ */
+ public static Remote register(ActivationDesc desc)
+ throws UnknownGroupException, ActivationException, RemoteException
+ {
+ ActivationID id = obtainId(desc);
+ try
+ {
+ return toStub(
+ id,
+ Thread.currentThread().getContextClassLoader().loadClass(
+ desc.getClassName()));
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ActivationException("Class not found: "+desc.getClassName());
+ }
+ }
+
+ /**
+ * Inactivates and unexports the object. The subsequent calls will activate
+ * the object again. The object is not inactivated if it is currently
+ * executing calls.
+ *
+ * @param id the id of the object being inactivated
+ * @return true if the object has been inactivated, false if it has not been
+ * inactivated because of the running or pending calls.
+ * @throws UnknownObjectException if the object is unknown.
+ * @throws ActivationException if the object group is not active
+ * @throws RemoteException if the remote call fails
+ */
+ public static boolean inactive(ActivationID id)
+ throws UnknownObjectException, ActivationException, RemoteException
+ {
+ if (id.group!=null)
+ id.group.inactiveObject(id);
+ return UnicastRemoteObject.unexportObject(id.activate(false), false);
+ }
+
+ /**
+ * Unregister the object (the object will no longer be activable with that id)
+ *
+ * @param id the object id
+ * @throws UnknownObjectException if the id is unknown
+ * @throws ActivationException if the activation system is not running
+ * @throws RemoteException if the remote call fails.
+ */
+ public static void unregister(ActivationID id) throws UnknownObjectException,
+ ActivationException, RemoteException
+ {
+ ActivationGroup.currentGroupId.getSystem().unregisterObject(id);
+ UnicastServer.unregisterActivatable(id);
+ }
+
+ /**
+ * Register and export the object that activatable object that is not derived
+ * from the Activatable super class. It creates and registers the object
+ * activation descriptor. There is no need to call this method if the object
+ * extends Activable, as its work is done in the constructor
+ * {@link #Activatable(String, MarshalledObject, boolean, int)}.
+ *
+ * @param obj the object, that is exported, becoming available at the given
+ * port.
+ * @param location the object code location (codebase).
+ * @param data the data, needed to activate the object
+ * @param restart the restart mode
+ * @param port the port, where the object will be available
+ *
+ * @return the created object activation ID.
+ *
+ * @throws ActivationException if the activation group is not active
+ * @throws RemoteException if the registration or export fails
+ */
+ public static ActivationID exportObject(Remote obj, String location,
+ MarshalledObject<?> data,
+ boolean restart, int port)
+ throws ActivationException, RemoteException
+ {
+ ActivationDesc descriptor = new ActivationDesc(obj.getClass().getName(),
+ location, data, restart);
+ ActivationID id = obtainId(descriptor);
+ Remote stub = exportObject(obj, id, port);
+ return id;
+ }
+
+ /**
+ * Register and export the object that activatable object that is not derived
+ * from the Activatable super class. It creates and registers the object
+ * activation descriptor. There is no need to call this method if the object
+ * extends Activable, as its work is done in the constructor
+ * {@link #Activatable(String, MarshalledObject, boolean, int, RMIClientSocketFactory, RMIServerSocketFactory)}
+ *
+ * @param obj the object, that is exported, becoming available at the given
+ * port.
+ * @param location the object code location (codebase).
+ * @param data the data, needed to activate the object
+ * @param restart the restart mode
+ * @param port the port, where the object will be available
+ * @param csf the client socket factory
+ * @param ssf the server socket factory
+ *
+ * @return the created object activation ID.
+ *
+ * @throws ActivationException if the activation group is not active
+ * @throws RemoteException if the registration or export fails
+ */
+ public static ActivationID exportObject(Remote obj, String location,
+ MarshalledObject data,
+ boolean restart, int port,
+ RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf)
+ throws ActivationException, RemoteException
+ {
+ ActivationDesc descriptor = new ActivationDesc(obj.getClass().getName(),
+ location, data, restart);
+ ActivationID id = obtainId(descriptor);
+ Remote stub = exportObject(obj, id, port, csf, ssf);
+ return id;
+
+ }
+
+ /**
+ * During activation, this exportObject method should be invoked explicitly by
+ * the activatable object, that does is not derived from the Activatable
+ * class. There is no need to call this method if the object extends
+ * Activable, as its work is done in the constructor
+ * {@link #Activatable(ActivationID, int)}
+ *
+ * @param obj the object
+ * @param id the known activation id
+ * @param port the object port
+ *
+ * @return the remote stub of the activatable object
+ *
+ * @throws RemoteException if the object export fails
+ */
+ public static Remote exportObject(Remote obj, ActivationID id, int port)
+ throws RemoteException
+ {
+ Remote stub = export(id, obj, port, null);
+ return stub;
+ }
+
+ /**
+ * During activation, this exportObject method should be invoked explicitly by
+ * the activatable object, that does is not derived from the Activatable
+ * class. There is no need to call this method if the object extends
+ * Activable, as its work is done in the constructor
+ * {@link #Activatable(ActivationID, int)}
+ *
+ * @param obj the object
+ * @param id the known activation id
+ * @param port the object port
+ * @param csf the client socket factory
+ * @param ssf the server socket factory
+ *
+ * @return the remote stub of the activatable object
+ *
+ * @throws RemoteException if the object export fails
+ */
+ public static Remote exportObject(Remote obj, ActivationID id, int port,
+ RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf)
+ throws RemoteException
+ {
+ Remote stub = export(id, obj, port, ssf);
+ return stub;
+
+ }
+
+ /**
+ * Make the remote object unavailable for incoming calls. This method also
+ * unregisters the object, so it cannot be activated again by incoming call
+ * (unless registered).
+ *
+ * @param obj the object to unexport
+ * @param force if true, cancel all pending or running calls to that object
+ * (if false, the object with such calls is not unexported and false
+ * is returned by this method).
+ * @return if the object was successfully unexported, false otherwise
+ * @throws NoSuchObjectException if such object is not known
+ */
+ public static boolean unexportObject(Remote obj, boolean force)
+ throws NoSuchObjectException
+ {
+ Object aref = UnicastServer.getExportedRef(obj);
+
+ // Unregister it also (otherwise will be activated during the subsequent
+ // call.
+ if (aref instanceof ActivatableServerRef)
+ {
+ ActivatableServerRef aar = (ActivatableServerRef) aref;
+ UnicastServer.unregisterActivatable(aar.actId);
+ }
+ return UnicastRemoteObject.unexportObject(obj, force);
+ }
+
+ static Remote exportObject(Remote obj, int port,
+ RMIServerSocketFactory serverSocketFactory)
+ throws RemoteException
+ {
+ UnicastServerRef sref = null;
+ if (obj instanceof RemoteObject)
+ sref = (UnicastServerRef) ((RemoteObject) obj).getRef();
+
+ if (sref == null)
+ sref = new UnicastServerRef(new ObjID(), port, serverSocketFactory);
+
+ Remote stub = sref.exportObject(obj);
+ // addStub(obj, stub);
+ // TODO Need to change the place of the stub repository
+ return stub;
+ }
+
+ /**
+ * Create and export the new remote object, making it available at the given
+ * port, using sockets, produced by the specified factories.
+ *
+ * @param port the port, on that the object should become available. Zero
+ * means anonymous port.
+ * @param serverSocketFactory the server socket factory
+ */
+ private static Remote export(ActivationID id, Remote obj, int port,
+ RMIServerSocketFactory serverSocketFactory)
+ throws RemoteException
+ {
+ ActivatableServerRef sref = null;
+ sref = new ActivatableServerRef(makeId(id), id, port, serverSocketFactory);
+ return sref.exportObject(obj);
+ }
+
+ /**
+ * Make the object ID from the activation ID. The same activation ID always
+ * produces the identical object id.
+ *
+ * @param aid the activation id
+ *
+ * @return the object id
+ */
+ private static ObjID makeId(ActivationID aid)
+ {
+ ObjID id = new ObjID(0);
+
+ // The fields of both ObjID and ActivationID must be package private,
+ // so we need to use the reflection to access them anyway.
+ // Probably other implementations use some very different approach.
+
+ try
+ {
+ Field idUid = ObjID.class.getDeclaredField("space");
+ Field aidUid = ActivationID.class.getDeclaredField("uid");
+
+ aidUid.setAccessible(true);
+ idUid.setAccessible(true);
+
+ idUid.set(id, aidUid.get(aid));
+ }
+ catch (Exception e)
+ {
+ InternalError ierr = new InternalError("Unable to set UID field");
+ ierr.initCause(e);
+ throw ierr;
+ }
+
+ return id;
+ }
+
+ /**
+ * Connect the object to the UnicastServer (export), but not activate it.
+ * The object will be activated on the first call.
+ */
+ static Remote toStub(ActivationID anId, Class stubFor)
+ {
+ try
+ {
+ ActivatableServerRef asr =
+ new ActivatableServerRef(makeId(anId), anId, 0, null);
+ UnicastServer.exportActivatableObject(asr);
+ return asr.exportClass(stubFor);
+ }
+ catch (RemoteException e)
+ {
+ InternalError ierr = new InternalError(
+ "Failed to obtain activatable stub");
+ ierr.initCause(e);
+ throw ierr;
+ }
+ }
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivateFailedException.java b/libjava/classpath/java/rmi/activation/ActivateFailedException.java
new file mode 100644
index 000000000..1c2e10ee3
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivateFailedException.java
@@ -0,0 +1,76 @@
+/* ActivateFailedException.java -- thrown when activation fails
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+import java.rmi.RemoteException;
+
+/**
+ * Thrown when activation fails on a remote call to an activatable object.
+ *
+ * @author unknown
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class ActivateFailedException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 4863550261346652506L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ActivateFailedException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param ex the cause
+ */
+ public ActivateFailedException(String s, Exception ex)
+ {
+ super(s, ex);
+ }
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationDesc.java b/libjava/classpath/java/rmi/activation/ActivationDesc.java
new file mode 100644
index 000000000..9970cd63b
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationDesc.java
@@ -0,0 +1,254 @@
+/* ActivationDesc.java -- record with info to activate an object
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+
+/**
+ * Contains the information, necessary to activate the object. This information
+ * includes:
+ * <ul>
+ * <li>the object class name</li>
+ * <li>the object group identifier</li>
+ * <li>the code location (codebase URL) that can be used to load the class
+ * remotely</li>
+ * <li>the object restart mode</li>
+ * <li>the object specific intialization information</li>
+ * </ul>
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org) (from stub)
+ */
+public final class ActivationDesc
+ implements Serializable
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = 7455834104417690957L;
+
+ /**
+ * The group id.
+ */
+ private ActivationGroupID groupid;
+
+ /**
+ * The class name.
+ */
+ private String classname;
+
+ /**
+ * The code location URL.
+ */
+ private String location;
+
+ /**
+ * The object specific intitalization data.
+ */
+ private MarshalledObject<?> data;
+
+ /**
+ * The start mode.
+ */
+ private boolean restart;
+
+ /**
+ * Create the new activation description, assuming the object group is the
+ * {@link ActivationGroup#currentGroupID()}.
+ *
+ * @param className the object fully qualified class name
+ * @param location the code base URL
+ * @param data the object initialization data, contained in a marshalled form
+ */
+ public ActivationDesc(String className, String location, MarshalledObject<?> data)
+ throws ActivationException
+ {
+ this(ActivationGroup.currentGroupID(), className, location, data, false);
+ }
+
+ /**
+ * Create the new activation description, assuming the object group is the
+ * {@link ActivationGroup#currentGroupID()}.
+ *
+ * @param className the object fully qualified class name
+ * @param location the code base URL
+ * @param data the object initialization data, contained in a marshalled form
+ * @param restart specifies reactivation mode after crash. If true, the object
+ * is activated when activator is restarted or the activation group
+ * is restarted. If false, the object is only activated on demand.
+ * This flag does has no effect during the normal operation (the
+ * object is normally activated on demand).
+ */
+ public ActivationDesc(String className, String location,
+ MarshalledObject<?> data, boolean restart)
+ throws ActivationException
+ {
+ this(ActivationGroup.currentGroupID(), className, location, data, restart);
+ }
+
+ /**
+ * Create the new activation description. Under crash, the object will only
+ * be reactivated on demand.
+ *
+ * @param groupID the object group id.
+ * @param className the object fully qualified class name
+ * @param location the code base URL
+ * @param data the object initialization data, contained in a marshalled form
+ */
+ public ActivationDesc(ActivationGroupID groupID, String className,
+ String location, MarshalledObject<?> data)
+ {
+ this(groupID, className, location, data, false);
+ }
+
+ /**
+ * Create the new activation description, providing full information.
+ *
+ * @param groupID the object group id.
+ * @param className the object fully qualified class name
+ * @param location the code base URL
+ * @param data the object initialization data, contained in a marshalled form
+ * @param restart specifies reactivation mode after crash. If true, the object
+ * is activated when activator is restarted or the activation group
+ * is restarted. If false, the object is only activated on demand.
+ * This flag does has no effect during the normal operation (the
+ * object is normally activated on demand).
+ */
+ public ActivationDesc(ActivationGroupID groupID, String className,
+ String location, MarshalledObject<?> data, boolean restart)
+ {
+ this.groupid = groupID;
+ this.classname = className;
+ this.location = location;
+ this.data = data;
+ this.restart = restart;
+ }
+
+ public ActivationGroupID getGroupID()
+ {
+ return groupid;
+ }
+
+ /**
+ * Get the class name of the object being activated
+ *
+ * @return the fully qualified class name of the object being activated
+ */
+ public String getClassName()
+ {
+ return classname;
+ }
+
+ /**
+ * Get the code location URL ("codebase") of the object being activated.
+ *
+ * @return the codebase of the object being activated.
+ */
+ public String getLocation()
+ {
+ return location;
+ }
+
+ public MarshalledObject<?> getData()
+ {
+ return data;
+ }
+
+ /**
+ * Get the object reactivation strategy after crash.
+ *
+ * @return true ir the object is activated when activator is restarted or the
+ * activation group is restarted. False if the object is only
+ * activated on demand. This flag does has no effect during the normal
+ * operation (the object is normally activated on demand).
+ */
+ public boolean getRestartMode()
+ {
+ return restart;
+ }
+
+ /**
+ * Compare this object with another activation description for equality.
+ *
+ * @return true if all fields have the equal values, false otherwise.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ActivationDesc)
+ {
+ ActivationDesc that = (ActivationDesc) obj;
+ return eq(groupid, that.groupid) &&
+ eq(classname, that.classname) &&
+ eq(location, that.location) &&
+ eq(data, that.data)
+ && restart == that.restart;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the hash code of this object (overridden to make the returned value
+ * consistent with .equals(..).
+ */
+ public int hashCode()
+ {
+ return hash(groupid) ^ hash(classname) ^
+ hash(location) ^ hash(data);
+ }
+
+ /**
+ * Get the hashcode of x or 0 if x == null.
+ */
+ static final int hash(Object x)
+ {
+ return x == null ? 0 : x.hashCode();
+ }
+
+ /**
+ * Compare by .equals if both a and b are not null, compare directly if at
+ * least one of them is null.
+ */
+ static final boolean eq(Object a, Object b)
+ {
+ if (a == null || b == null)
+ return a == b;
+ else
+ return a.equals(b);
+ }
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationException.java b/libjava/classpath/java/rmi/activation/ActivationException.java
new file mode 100644
index 000000000..418f43857
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationException.java
@@ -0,0 +1,122 @@
+/* ActivationException.java -- general Activation exception
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+/**
+ * General exception class for <code>java.rmi.activation</code>.
+ *
+ * @author unknown
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class ActivationException extends Exception
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = -4320118837291406071L;
+
+ /**
+ * The cause of this exception. This pre-dates the exception chaining
+ * of Throwable; and although you can change this field, you are wiser
+ * to leave it alone.
+ *
+ * @serial the exception cause
+ */
+ public Throwable detail;
+
+ /**
+ * Create an exception with no message, and cause initialized to null.
+ */
+ public ActivationException()
+ {
+ this(null, null);
+ }
+
+ /**
+ * Create an exception with the given message, and cause initialized to null.
+ *
+ * @param s the message
+ */
+ public ActivationException(String s)
+ {
+ this(s, null);
+ }
+
+ /**
+ * Create an exception with the given message and cause.
+ *
+ * @param s the message
+ * @param ex the cause
+ */
+ public ActivationException(String s, Throwable ex)
+ {
+ super(s, ex);
+ detail = ex;
+ }
+
+ /**
+ * This method returns a message indicating what went wrong, in this
+ * format:
+ * <code>super.getMessage() + (detail == null ? ""
+ * : "; nested exception is:\n\t" + detail)</code>.
+ *
+ * @return the chained message
+ */
+ public String getMessage()
+ {
+ if (detail == this || detail == null)
+ return super.getMessage();
+ return super.getMessage() + "; nested exception is:\n\t" + detail;
+ }
+
+ /**
+ * Returns the cause of this exception. Note that this may not be the
+ * original cause, thanks to the <code>detail</code> field being public
+ * and non-final (yuck). However, to avoid violating the contract of
+ * Throwable.getCause(), this returns null if <code>detail == this</code>,
+ * as no exception can be its own cause.
+ *
+ * @return the cause
+ * @since 1.4
+ */
+ public Throwable getCause()
+ {
+ return detail == this ? null : detail;
+ }
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationGroup.java b/libjava/classpath/java/rmi/activation/ActivationGroup.java
new file mode 100644
index 000000000..230c71455
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationGroup.java
@@ -0,0 +1,340 @@
+/* ActivationGroup.java -- the RMI activation group.
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import gnu.java.rmi.activation.DefaultActivationGroup;
+import gnu.java.rmi.activation.DefaultActivationSystem;
+
+import java.lang.reflect.Constructor;
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+/**
+ * The entity that receives the request to activate object and activates it.
+ * Frequently there is one activation group per virtual machine.
+ *
+ * @author Audrius Meskauskas (audriusa@Bioinformatics.org) (from stub)
+ */
+public abstract class ActivationGroup
+ extends UnicastRemoteObject
+ implements ActivationInstantiator
+{
+
+ /**
+ * Use the SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 7696947875314805420L;
+
+ /**
+ * The Id of the current group on this VM (null if none).
+ */
+ static ActivationGroupID currentGroupId = null;
+
+ /**
+ * The groups identifier.
+ */
+ final ActivationGroupID groupId;
+
+ /**
+ * The groups activation monitor.
+ */
+ ActivationMonitor monitor;
+
+ /**
+ * The groups incarnation number.
+ */
+ long incarnation;
+
+ /**
+ * The groups activation system.
+ */
+ static ActivationSystem system;
+
+ /**
+ * Used during the group creation (required constructor).
+ */
+ static final Class[] cConstructorTypes = new Class[]
+ {
+ ActivationGroupID.class,
+ MarshalledObject.class
+ };
+
+ /**
+ * Create the new activation group with the given group id.
+ *
+ * @param aGroupId the group Id.
+ *
+ * @throws RemoteException if the group export fails.
+ */
+ protected ActivationGroup(ActivationGroupID aGroupId) throws RemoteException
+ {
+ groupId = aGroupId;
+ }
+
+ /**
+ * The method is called when the object is exported. The group must notify
+ * the activation monitor, if this was not already done before.
+ *
+ * @param id the object activation id
+ * @param obj the remote object implementation
+ *
+ * @throws ActivationException if the group is inactive
+ * @throws UnknownObjectException if such object is not known
+ * @throws RemoteException if the call to monitor fails
+ */
+ public abstract void activeObject(ActivationID id, Remote obj)
+ throws ActivationException, UnknownObjectException, RemoteException;
+
+ /**
+ * Notifies the monitor about the object being inactivated.
+ *
+ * @param id the object being inactivated.
+ * @return true always (must be overridden to return other values).
+ * @throws ActivationException never
+ * @throws UnknownObjectException if the object is not known
+ * @throws RemoteException if the remote call to monitor fails
+ */
+ public boolean inactiveObject(ActivationID id) throws ActivationException,
+ UnknownObjectException, RemoteException
+ {
+ if (monitor != null)
+ monitor.inactiveObject(id);
+ return true;
+ }
+
+ /**
+ * Create the new instance of the activation group, using the class name and
+ * location information, stored in the passed descriptor. The method expects
+ * the group class to have the two parameter constructor, the first parameter
+ * being the {@link ActivationGroupID} and the second the
+ * {@link MarshalledObject}. The group must be first be registered with the
+ * ActivationSystem. Once a group is created, the currentGroupID method
+ * returns the identifier for this group until the group becomes inactive.
+ *
+ * @param id the activation group id
+ * @param desc the group descriptor, providing the information, necessary to
+ * create the group
+ * @param incarnation the incarnation number
+ * @return the created group instance
+ * @throws ActivationException if the activation fails due any reason
+ */
+ public static ActivationGroup createGroup(ActivationGroupID id,
+ ActivationGroupDesc desc,
+ long incarnation)
+ throws ActivationException
+ {
+ // If the activation system is not yet set, set it to the system.
+ // passed in the group id.
+ if (system == null)
+ system = id.system;
+
+ ActivationGroup group = null;
+
+ // TODO at the moment all groups are created on the current jre and the
+ // group class must be reachable via thread context class loader.
+ Class groupClass;
+
+ if (desc.className != null)
+ {
+ try
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ groupClass = loader.loadClass(desc.className);
+ }
+ catch (ClassNotFoundException e)
+ {
+ ActivationException acex = new ActivationException(
+ "Cannot load " + desc.className);
+ acex.detail = e;
+ throw acex;
+ }
+ }
+ else
+ groupClass = DefaultActivationGroup.class;
+
+ try
+ {
+ Constructor constructor = groupClass.getConstructor(cConstructorTypes);
+ group = (ActivationGroup) constructor.newInstance(
+ new Object[] { id, desc.data });
+ }
+ catch (Exception e)
+ {
+ ActivationException acex = new ActivationException(
+ "Cannot instantiate " + desc.className);
+ acex.detail = e;
+ throw acex;
+ }
+
+ currentGroupId = id;
+ try
+ {
+ group.monitor = getSystem().activeGroup(id, group, incarnation);
+ return group;
+ }
+ catch (RemoteException e)
+ {
+ ActivationException acex = new ActivationException("createGroup");
+ acex.detail = e;
+ throw acex;
+ }
+ }
+
+ /**
+ * Get the id of current activation group.
+ *
+ * @return the id of the current activation group or null if none exists.
+ */
+ public static ActivationGroupID currentGroupID()
+ {
+ try
+ {
+ if (currentGroupId==null)
+ {
+ // This will also assing the currentGroupId to the current
+ // (default) group of the default system.
+ setSystem(DefaultActivationSystem.get());
+ }
+ }
+ catch (ActivationException e)
+ {
+ InternalError ierr = new InternalError("Unable to activate AS");
+ ierr.initCause(e);
+ throw ierr;
+ }
+
+ return currentGroupId;
+ }
+
+ /**
+ * Set the activation system for this virtual machine. The system can only
+ * be set if no group is active.
+ *
+ * @param aSystem the system to set
+ *
+ * @throws ActivationException if some group is active now.
+ */
+ public static void setSystem(ActivationSystem aSystem)
+ throws ActivationException
+ {
+ if (currentGroupId!=null)
+ throw new ActivationException("Group active");
+ else
+ {
+ try
+ {
+ // Register the default transient activation system and group.
+ system = aSystem;
+ ActivationGroupDesc def = new ActivationGroupDesc(
+ DefaultActivationGroup.class.getName(),
+ "",
+ null,
+ null,
+ null);
+ currentGroupId = system.registerGroup(def);
+ }
+ catch (Exception ex)
+ {
+ InternalError ierr = new InternalError("Unable to start default AG");
+ ierr.initCause(ex);
+ throw ierr;
+ }
+ }
+ }
+
+ /**
+ * Get the current activation system. If the system is not set via
+ * {@link #setSystem} method, the default system for this virtual machine is
+ * returned. The default system is first searched by name
+ * "java.rmi.activation.ActivationSystem" on the activation registry port. The
+ * default value of the activation registry port is
+ * {@link ActivationSystem#SYSTEM_PORT}, but it can be changed by putting the
+ * system property java.rmi.activation.port. Both activation system and
+ * activation registry are provided by the RMI daemon tool, RMID, if it is
+ * running on the local host. If the RMID is not running, the internal
+ * transient activation system will be created and returned. This internal
+ * system is highly limited in in capabilities and is not intended to be used
+ * anywhere apart automated testing.
+ *
+ * @return the activation system for this virtual machine
+ * @throws ActivationException
+ */
+ public static ActivationSystem getSystem() throws ActivationException
+ {
+ if (system == null)
+ system = DefaultActivationSystem.get();
+ return system;
+ }
+
+ /**
+ * Makes the call back to the groups {@link ActivationMonitor}.
+ *
+ * @param id the id obj the object being activated
+ * @param mObject the marshalled object, contains the activated remote object
+ * stub.
+ * @throws ActivationException on activation error
+ * @throws UnknownObjectException if such object is not registered
+ * @throws RemoteException on remote call (to monitor) error
+ */
+ protected void activeObject(ActivationID id,
+ MarshalledObject<? extends Remote> mObject)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ if (monitor!=null)
+ monitor.activeObject(id, mObject);
+
+ id.group = this;
+ }
+
+ /**
+ * Makes the call back to the groups {@link ActivationMonitor} and sets
+ * the current group to null.
+ */
+ protected void inactiveGroup() throws UnknownGroupException, RemoteException
+ {
+ if (monitor!=null)
+ monitor.inactiveGroup(groupId, incarnation);
+
+ if (currentGroupId!=null && currentGroupId.equals(groupId))
+ currentGroupId = null;
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java b/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java
new file mode 100644
index 000000000..a0c88ec0a
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationGroupDesc.java
@@ -0,0 +1,433 @@
+/* ActivationGroupDesc.java -- the RMI activation group descriptor
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import gnu.java.rmi.activation.DefaultActivationGroup;
+
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.TreeSet;
+import java.util.zip.Adler32;
+
+/**
+ * Contains information, necessary to create of recreate the activation objects.
+ * The group descriptor contains:
+ * <ul>
+ * <li>The name of the group's class. This class is derived from the
+ * {@link ActivationGroup}.</li>
+ * <li>The group class code location.</li>
+ * <li>The marshalled object that contains the group specific initialization
+ * information</li>
+ * </ul>
+ * The groups are created by the {@link ActivationGroup#createGroup} method that
+ * expectes the group class to have the two parameter constructor, the first
+ * parameter being the {@link ActivationGroupID} and the second the
+ * {@link MarshalledObject}.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org) (from stub)
+ */
+public final class ActivationGroupDesc
+ implements Serializable
+{
+ /**
+ * Contains the startup options for the {@link ActivationGroup}
+ * implementations. Allows to override system properties and specify other
+ * options for the implementation groups.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org) (from stub)
+ */
+ public static class CommandEnvironment
+ implements Serializable
+ {
+
+ /**
+ * Use the SVUID for interoperability.
+ */
+ static final long serialVersionUID = 6165754737887770191L;
+
+ /**
+ * The zero size string array used as argv value when null is passed.
+ */
+ private static final String[] NO_ARGS = new String[0];
+
+ /**
+ * The path to the java executable (or null for using default jre).
+ */
+ final String command;
+
+ /**
+ * The extra parameters (may be empty array but never null).
+ */
+ final String[] options;
+
+ /**
+ * Create the new command environment.
+ *
+ * @param commandPatch the full path (and name) to the java executable of
+ * null for using the default executable.
+ * @param args extra options that will be used when creating the activation
+ * group. Null has the same effect as the empty list.
+ */
+ public CommandEnvironment(String commandPatch, String[] args)
+ {
+ command = commandPatch;
+ if (args != null)
+ options = args;
+ else
+ options = NO_ARGS;
+ }
+
+ /**
+ * Get the path to the java executable.
+ *
+ * @return the path to the java executable or null for using the default
+ * jre.
+ */
+ public String getCommandPath()
+ {
+ return command;
+ }
+
+ /**
+ * Get the additional command options.
+ *
+ * @return the command options array, may be empty string
+ */
+ public String[] getCommandOptions()
+ {
+ return options;
+ }
+
+ /**
+ * Compare for content equality.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof CommandEnvironment)
+ {
+ CommandEnvironment that = (CommandEnvironment) obj;
+
+ if (command == null || that.command == null)
+ {
+ // Use direct comparison if null is involved.
+ if (command != that.command)
+ return false;
+ }
+ else
+ {
+ // Use .equals if null is not involved.
+ if (! this.command.equals(that.command))
+ return false;
+ }
+
+ return Arrays.equals(options, that.options);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the hash code.
+ */
+ public int hashCode()
+ {
+ int h = command == null ? 0 : command.hashCode();
+ for (int i = 0; i < options.length; i++)
+ h ^= options[i].hashCode();
+
+ return h;
+ }
+ }
+
+ /**
+ * Use the SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 4936225423168276595L;
+
+ /**
+ * The group class name or null for the default group class implementation.
+ */
+ final String className;
+
+ /**
+ * The group class download location URL (codebase), ignored by the
+ * default implementation.
+ */
+ final String location;
+
+ /**
+ * The group initialization data.
+ */
+ final MarshalledObject<?> data;
+
+ /**
+ * The path to the group jre and the parameters of this jre, may be
+ * null for the default jre.
+ */
+ final ActivationGroupDesc.CommandEnvironment env;
+
+ /**
+ * The properties that override the system properties.
+ */
+ final Properties props;
+
+ /**
+ * The cached hash code.
+ */
+ transient long hash;
+
+ /**
+ * Create the new activation group descriptor that will use the default
+ * activation group implementation with the given properties and
+ * environment.
+ *
+ * @param aProperties the properties that override the system properties
+ * @param environment the command line (and parameters), indicating, where to
+ * find the jre executable and with that parameters to call it. May
+ * be null if the default executable should be used. In this case,
+ * the activation group with the null name (the system default group)
+ * will be created.
+ */
+ public ActivationGroupDesc(Properties aProperties,
+ ActivationGroupDesc.CommandEnvironment environment)
+ {
+ this(DefaultActivationGroup.class.getName(), null, null, aProperties,
+ environment);
+ }
+
+ /**
+ * Create the new activation group descriptor.
+ *
+ * @param aClassName the name of the group implementation class. The null
+ * value indicates the default implementation.
+ * @param aLocation the location, from where the group implementation class
+ * should be loaded (ignored for the system default implementation).
+ * @param aData the group intialization data
+ * @param aProperties the properties that will override the system properties
+ * of the new group. These properties will be translated into -D
+ * options.
+ * @param environment the record, containing path to the jre executable and
+ * start options for the jre or null for using the default jre and
+ * options.
+ */
+ public ActivationGroupDesc(String aClassName, String aLocation,
+ MarshalledObject<?> aData, Properties aProperties,
+ ActivationGroupDesc.CommandEnvironment environment)
+ {
+ className = aClassName;
+ location = aLocation;
+ data = aData;
+ props = aProperties;
+ env = environment;
+ }
+
+ /**
+ * Get the activation group class name.
+ *
+ * @return the activation group class name (null for default implementation)
+ */
+ public String getClassName()
+ {
+ return className;
+ }
+
+ /**
+ * Get the location, from where the group class will be loaded
+ *
+ * @return the location, from where the implementation should be loaded (null
+ * for the default implementation)
+ */
+ public String getLocation()
+ {
+ return location;
+ }
+
+ /**
+ * Get the group intialization data.
+ *
+ * @return the group intialization data in the marshalled form.
+ */
+ public MarshalledObject<?> getData()
+ {
+ return data;
+ }
+
+ /**
+ * Get the overridded system properties.
+ *
+ * @return the overridden group system properties.
+ */
+ public Properties getPropertyOverrides()
+ {
+ return props;
+ }
+
+ /**
+ * Get the group command environment, containing path to the jre executable
+ * and startup options.
+ *
+ * @return the command environment or null if the default environment should
+ * be used.
+ */
+ public ActivationGroupDesc.CommandEnvironment getCommandEnvironment()
+ {
+ return env;
+ }
+
+ /**
+ * Compare for the content equality.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ActivationGroupDesc)
+ {
+ ActivationGroupDesc that = (ActivationGroupDesc) obj;
+
+ // Ensure the hashcodes are computed.
+ if (hash == 0)
+ hashCode();
+ if (that.hash == 0)
+ that.hashCode();
+
+ // We compare the hash fields as they are type long rather than int.
+ if (hash != that.hash)
+ return false;
+
+ if (! eq(className, that.className))
+ return false;
+ if (! eq(data, that.data))
+ return false;
+ if (! eq(env, that.env))
+ return false;
+ if (! eq(location, that.location))
+ return false;
+
+ // Compare the properties.
+ if (eq(props, that.props))
+ return true;
+
+ if (props.size() != that.props.size())
+ return false;
+
+ Enumeration en = props.propertyNames();
+ Object key, value;
+
+ while (en.hasMoreElements())
+ {
+ key = en.nextElement();
+ if (! that.props.containsKey(key))
+ return false;
+ if (! eq(props.get(key), that.props.get(key)))
+ return false;
+ }
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Compare for direct equality if one or both parameters are null, otherwise
+ * call .equals.
+ */
+ static boolean eq(Object a, Object b)
+ {
+ if (a == null || b == null)
+ return a == b;
+ else
+ return a.equals(b);
+ }
+
+ /**
+ * Return the hashcode.
+ */
+ public int hashCode()
+ {
+ if (hash==0)
+ {
+ // Using Adler32 - the hashcode is cached, will be computed only
+ // once and due need to scan properties is the expensive operation
+ // anyway. Reliability is more important.
+ Adler32 adler = new Adler32();
+ if (className!=null)
+ adler.update(className.getBytes());
+ if (data!=null)
+ adler.update(data.hashCode());
+ if (env!=null)
+ adler.update(env.hashCode());
+ if (location!=null)
+ adler.update(location.getBytes());
+ if (props!=null)
+ {
+ Enumeration en = props.propertyNames();
+
+ // Using the intermediate sorted set to ensure that the
+ // properties are sorted.
+ TreeSet pr = new TreeSet();
+
+ Object key;
+ Object value;
+ while (en.hasMoreElements())
+ {
+ key = en.nextElement();
+ if (key!=null)
+ pr.add(key);
+ }
+
+ Iterator it = pr.iterator();
+ while (it.hasNext())
+ {
+ key = it.next();
+ value = props.get(key);
+ adler.update(key.hashCode());
+ if (value!=null)
+ adler.update(value.hashCode());
+ }
+ }
+ hash = adler.getValue();
+ }
+ return (int) hash;
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationGroupID.java b/libjava/classpath/java/rmi/activation/ActivationGroupID.java
new file mode 100644
index 000000000..77fa4fba1
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationGroupID.java
@@ -0,0 +1,122 @@
+/* ActivationGroupID.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.io.Serializable;
+import java.rmi.server.UID;
+
+/**
+ * This identifier identifies the activation group inside the scope of its
+ * activation system. It also contains (and can provide) the reference to the
+ * groups activation system.
+ *
+ * @see ActivationSystem#registerGroup(ActivationGroupDesc)
+ */
+public class ActivationGroupID
+ implements Serializable
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 1648432278909740833L;
+
+ /**
+ * The associated activation system.
+ */
+ final ActivationSystem system;
+
+ /**
+ * The object identifier, making the ID unique.
+ */
+ final UID uid;
+
+ /**
+ * Create the new activation group id in the scope of the given activation
+ * system
+ *
+ * @param aSystem the activation system
+ */
+ public ActivationGroupID(ActivationSystem aSystem)
+ {
+ system = aSystem;
+ uid = new UID();
+ }
+
+ /**
+ * Get the associated activation system
+ *
+ * @return the associated activation system
+ */
+ public ActivationSystem getSystem()
+ {
+ return system;
+ }
+
+ /**
+ * Get the hash code of the associated activation system.
+ */
+ public int hashCode()
+ {
+ return uid.hashCode();
+ }
+
+ /**
+ * Copmare for equality, returns true if the passed object is also the
+ * activation group id and its activation system is the same.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ActivationGroupID)
+ {
+ ActivationGroupID that = (ActivationGroupID) obj;
+ return uid.equals(that.uid);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the string representation
+ */
+ public String toString()
+ {
+ return uid.toString();
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java b/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java
new file mode 100644
index 000000000..fb55e5fd9
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationGroup_Stub.java
@@ -0,0 +1,110 @@
+/* ActivationGroup_Stub.java -- Stub class for ActivationGroup impls.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.lang.reflect.Method;
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+
+/**
+ * A stub class for {@link ActivationGroup} implementations.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public final class ActivationGroup_Stub extends RemoteStub
+ implements ActivationInstantiator, Remote
+{
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * Creates a new instance of ActivationGroup_Stub.
+ *
+ * @param ref the remote reference
+ */
+ public ActivationGroup_Stub(RemoteRef ref)
+ {
+ super(ref);
+ }
+
+ /**
+ * Stub method for <code>ActivationGroup.newInstance()</code>.
+ *
+ * @param id the activation ID
+ * @param desc the activation description
+ *
+ * @return the return value of the invocation
+ *
+ * @throws RemoteException if the invocation throws a RemoteException
+ * @throws ActivationException if the invocation throws an
+ * ActivationException
+ */
+ public MarshalledObject newInstance(ActivationID id, ActivationDesc desc)
+ throws RemoteException, ActivationException
+ {
+ try
+ {
+ Method method = ActivationGroup_Stub.class.getDeclaredMethod
+ ("newInstance", new Class[]{ ActivationID.class,
+ ActivationDesc.class });
+ return (MarshalledObject) ref.invoke(this, method,
+ new Object[]{id, desc},
+ -5274445189091581345L);
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (RemoteException ex)
+ {
+ throw ex;
+ }
+ catch (ActivationException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new UnexpectedException("Unexpected exception", ex);
+ }
+ }
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationID.java b/libjava/classpath/java/rmi/activation/ActivationID.java
new file mode 100644
index 000000000..f89a0edf8
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationID.java
@@ -0,0 +1,199 @@
+/* ActivationID.java -- the object activation identifier
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.UID;
+
+/**
+ * Denotes the object that can be activated over time. The instance of the
+ * ActivationID for the given object can be obtained in the following ways:
+ * <ul>
+ * <li>via {@link Activatable#register(ActivationDesc)}</li>
+ * <li>via Activatable constructor</li>
+ * <li>via Activatable.exportObject
+ * <li>
+ * </ul>
+ * An instance of the ActivationID has the {@link UID} as its component and
+ * hence is globally unique.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org) (from stub)
+ */
+public class ActivationID
+ implements Serializable
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = - 4608673054848209235L;
+
+ /**
+ * The activator.
+ */
+ transient Activator activator;
+
+ /**
+ * The UID, making this instance unique.
+ */
+ transient UID uid;
+
+ /**
+ * The activation group that has activated the object with this
+ * activation id. The field is filled in inside the group and is used
+ * to notify the group about the request to inactivated the object.
+ */
+ transient ActivationGroup group;
+
+ /**
+ * Create a new instance with the given activator.
+ *
+ * @param an_activator tha activator that should activate the object.
+ */
+ public ActivationID(Activator an_activator)
+ {
+ activator = an_activator;
+ uid = new UID();
+ }
+
+ /**
+ * Activate the object.
+ *
+ * @param force if true, always contact the group. Otherwise, the cached value
+ * may be returned.
+ * @return the activated object
+ * @throws UnknownObjectException if the object is unknown
+ * @throws ActivationException if the activation has failed
+ * @throws RemoteException if the remote call has failed
+ */
+ public Remote activate(boolean force) throws ActivationException,
+ UnknownObjectException, RemoteException
+ {
+ try
+ {
+ return (Remote) activator.activate(this, force).get();
+ }
+ catch (IOException e)
+ {
+ ActivationException acex = new ActivationException("id "+uid, e);
+ throw acex;
+ }
+ catch (ClassNotFoundException e)
+ {
+ ActivationException acex = new ActivationException("id "+uid, e);
+ throw acex;
+ }
+ }
+
+ /**
+ * Returns the hash code of the activator.
+ */
+ public int hashCode()
+ {
+ return uid == null ? 0 : uid.hashCode();
+ }
+
+ /**
+ * Compares the activators for equality.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ActivationID)
+ {
+ ActivationID that = (ActivationID) obj;
+ return eq(uid, that.uid);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Read the object from the input stream.
+ *
+ * @param in the stream to read from
+ *
+ * @throws IOException if thrown by the stream
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream in) throws IOException,
+ ClassNotFoundException
+ {
+ uid = (UID) in.readObject();
+ activator = (Activator) in.readObject();
+ }
+
+ /**
+ * Write the object to the output stream.
+ *
+ * @param out the stream to write int
+ * @throws IOException if thrown by the stream
+ * @throws ClassNotFoundException
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException,
+ ClassNotFoundException
+ {
+ out.writeObject(uid);
+ out.writeObject(activator);
+ }
+
+ /**
+ * Compare by .equals if both a and b are not null, compare directly if at
+ * least one of them is null.
+ */
+ static final boolean eq(Object a, Object b)
+ {
+ if (a == null || b == null)
+ return a == b;
+ else
+ return a.equals(b);
+ }
+
+ /**
+ * Return the content based string representation.
+ */
+ public String toString()
+ {
+ return uid.toString();
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationInstantiator.java b/libjava/classpath/java/rmi/activation/ActivationInstantiator.java
new file mode 100644
index 000000000..e4ea54151
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationInstantiator.java
@@ -0,0 +1,73 @@
+/* ActivationInstantiator.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * The implementation of this interface creates (instantiates) the new remote
+ * objects in response to the activation request. The instantiator is returned
+ * by the {@link ActivationGroup} that calls
+ * {@link ActivationSystem#activeGroup(ActivationGroupID, ActivationInstantiator, long)}.
+ */
+public interface ActivationInstantiator
+ extends Remote
+{
+ /**
+ * Creates and instantiate a new remote object. This method performs the
+ * following tasks:
+ * <ul>
+ * <li>Finds and loads (if not already loaded) the class of the object being
+ * instantiated</li>
+ * <li>Creates an instance of the object using its special two parameter
+ * activation constructor, the first parameter being the {@link ActivationID}
+ * and the second the {@link MarshalledObject}.</li>
+ *
+ * @param id the id of the object being instantiated
+ * @param desc the activation descriptor being instantiated
+ * @return the MarshalledObject, containing the stub to the newly created
+ * object.
+ * @throws ActivationException if the activation fails
+ * @throws RemoteException if the remote call fails
+ */
+ MarshalledObject<? extends Remote> newInstance (ActivationID id, ActivationDesc desc)
+ throws ActivationException, RemoteException;
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationMonitor.java b/libjava/classpath/java/rmi/activation/ActivationMonitor.java
new file mode 100644
index 000000000..7c4c17144
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationMonitor.java
@@ -0,0 +1,87 @@
+/* ActivationMonitor.java -- the RMI activation/inactivation event listener
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * The activation and inactivation event listener. The group obtains this
+ * listener via {@link ActivationSystem#activeGroup} and must notify it
+ * when the group objects are activated or inactivated and also when the
+ * whole group becomes inactive.
+ * @author root.
+ */
+public interface ActivationMonitor extends Remote
+{
+ /**
+ * Informs that the object is now active.
+ *
+ * @param id the activation id of the object that is now active
+ * @throws UnknownObjectException is such object is not known in this group
+ * @throws RemoteException if remote call fails
+ */
+ void activeObject (ActivationID id, MarshalledObject<? extends Remote> obj)
+ throws UnknownObjectException, RemoteException;
+
+ /**
+ * Informs that the object is not inactive.
+ *
+ * @param id the activation id of the object that is now inactive
+ * @throws UnknownObjectException is such object is not known in this group
+ * @throws RemoteException if remote call fails
+ */
+ void inactiveObject (ActivationID id)
+ throws UnknownObjectException, RemoteException;
+
+ /**
+ * Informs that the whole group is now inactive because all group objects are
+ * inactive. The group will be recreated upon the later request to activate
+ * any object, belonging to the group.
+ *
+ * @param groupId the group id
+ * @param incarnation the group incarnation number
+ * @throws UnknownGroupException if the group id is not known
+ * @throws RemoteException if the remote call fails
+ */
+ void inactiveGroup (ActivationGroupID groupId, long incarnation)
+ throws UnknownGroupException, RemoteException;
+}
diff --git a/libjava/classpath/java/rmi/activation/ActivationSystem.java b/libjava/classpath/java/rmi/activation/ActivationSystem.java
new file mode 100644
index 000000000..090ce4815
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/ActivationSystem.java
@@ -0,0 +1,206 @@
+/* ActivationSystem.java -- registers groups and objects to be activated.
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * <p>
+ * The ActivationSystem registers groups and activatable objects to be activated
+ * within those groups. The ActivationSystem cooperates with both the Activator,
+ * which activates objects registered via the ActivationSystem, and the
+ * ActivationMonitor, which obtains information about active and inactive
+ * objects and inactive groups.
+ * </p>
+ * <p>
+ * The activation system if frequently a remote object. As a security mean, all
+ * methods in this interface throw {@link java.rmi.AccessException} if called
+ * from the client that is not reside on the same host as the activation system.
+ * </p>
+ * @see ActivationGroup#getSystem()
+ */
+public interface ActivationSystem
+ extends Remote
+{
+ /**
+ * The port, used by the activation system. The value is equal to 1098 by
+ * default, but it can be changed by putting the system property
+ * .
+ */
+ int SYSTEM_PORT = 1098;
+
+ /**
+ * Registers the activation descriptor and creates (and returns) its
+ * activation identifier. The map entry (identifier to descriptor) is stored
+ * in the stable map and used when the {@link Activator} receives the request
+ * to activate the object.
+ *
+ * @param desc the activation descriptor to register.
+ * @return the created activation identifier that is mapped to the passed
+ * descriptor.
+ * @throws ActivationException if the registration fails (database update
+ * problems, etc).
+ * @throws UnknownGroupException the if group, specified in decriptor, is
+ * unknown.
+ * @throws RemoteException if the remote call fails.
+ */
+ ActivationID registerObject(ActivationDesc desc) throws ActivationException,
+ UnknownGroupException, RemoteException;
+
+ /**
+ * Removes the stored identifier-description map entry. The object will no
+ * longer be activable using the passed activation id
+ *
+ * @param id the activation id to remove
+ * @throws ActivationException if the entry removing operation failed
+ * (database update problems, etc)
+ * @throws UnknownObjectException if the passed id is not known to the system
+ * @throws RemoteException if the remote call fails
+ */
+ void unregisterObject(ActivationID id) throws ActivationException,
+ UnknownObjectException, RemoteException;
+
+ /**
+ * Register the new activation group. For instance, it can be one activation
+ * group per virtual machine.
+ *
+ * @param groupDesc the activation group descriptor.
+ * @return the created activation group ID for the activation group
+ * @throws ActivationException if the group registration fails
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationGroupID registerGroup(ActivationGroupDesc groupDesc)
+ throws ActivationException, RemoteException;
+
+ /**
+ * This method is called from the {@link ActivationGroup} to inform the
+ * ActivatinSystem that the group is now active and there is the
+ * {@link ActivationInstantiator} for that group. This call is made internally
+ * from the {@link ActivationGroup#createGroup}.
+ *
+ * @param id the group id
+ * @param group the group activation instantiator
+ * @param incarnation the groups incarnatin number.
+ * @return the activation monitor that should be informed about the group
+ * state changes
+ * @throws UnknownGroupException if this group has not been registered
+ * @throws ActivationException if this group is already active
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationMonitor activeGroup(ActivationGroupID id,
+ ActivationInstantiator group, long incarnation)
+ throws UnknownGroupException, ActivationException, RemoteException;
+
+ /**
+ * Removes the activation group with the given identifier. The group calls
+ * back, informing the activator about the shutdown.
+ *
+ * @param id the group activation id.
+ * @throws ActivationException if the database update fails
+ * @throws UnknownGroupException if such group is not registered
+ * @throws RemoteException if the remote call fails
+ */
+ void unregisterGroup(ActivationGroupID id) throws ActivationException,
+ UnknownGroupException, RemoteException;
+
+ /**
+ * Shutdown the activation system and all associated activation groups
+ *
+ * @throws RemoteException if the remote call fails
+ */
+ void shutdown() throws RemoteException;
+
+ /**
+ * Replace the activation descriptor for the object with the given activation
+ * id.
+ *
+ * @param id the activation id
+ * @param desc the new activation descriptor
+ * @return the previous activation descriptor for that object.
+ * @throws ActivationException if the database update fails
+ * @throws UnknownObjectException if the object with such id is not known
+ * @throws UnknownGroupException if the activation group (in desc) is not
+ * known.
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationDesc setActivationDesc(ActivationID id, ActivationDesc desc)
+ throws ActivationException, UnknownObjectException,
+ UnknownGroupException, RemoteException;
+
+ /**
+ * Replaces the group descriptor for the group with the given group activation
+ * id.
+ *
+ * @param groupId the group id
+ * @param groupDesc the new group descriptor
+ * @return the previous group descriptor
+ * @throws ActivationException if the database update fails
+ * @throws UnknownGroupException if such group is not known
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationGroupDesc setActivationGroupDesc(ActivationGroupID groupId,
+ ActivationGroupDesc groupDesc)
+ throws ActivationException, UnknownGroupException, RemoteException;
+
+ /**
+ * Get the activation descriptor for the object with the given activation id.
+ *
+ * @param id the object activation id
+ * @return the activation descriptor for that object
+ * @throws ActivationException if the database access fails
+ * @throws UnknownObjectException if this object is not known
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationDesc getActivationDesc(ActivationID id) throws ActivationException,
+ UnknownObjectException, RemoteException;
+
+ /**
+ * Get the group descriptor for the group with the given id.
+ *
+ * @param groupId the group id
+ * @return the group descriptor
+ * @throws ActivationException if the database access fails
+ * @throws UnknownGroupException if the group with such id is not known
+ * @throws RemoteException if the remote call fails
+ */
+ ActivationGroupDesc getActivationGroupDesc(ActivationGroupID groupId)
+ throws ActivationException, UnknownGroupException, RemoteException;
+}
diff --git a/libjava/classpath/java/rmi/activation/Activator.java b/libjava/classpath/java/rmi/activation/Activator.java
new file mode 100644
index 000000000..fc66b2b63
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/Activator.java
@@ -0,0 +1,72 @@
+/* Activator.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.activation;
+
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Activates remote object, providing the live reference to the activable remote
+ * object. Usually there is only one activator per host.
+ *
+ * @see ActivationSystem
+ * @see ActivationMonitor
+ */
+public interface Activator
+ extends Remote
+{
+ /**
+ * Activate the object, associated with the given activation identifier. The
+ * activator looks for the {@link ActivationDesc}riptor for the passed
+ * identifier, determines the object activation group and initiates object
+ * recreation either via {@link ActivationInstantiator} or via
+ * {@link Class#newInstance()}.
+ *
+ * @param id the identifier of the object to activate.
+ * @param force if true, the activator always contacts the group to obtain the
+ * reference. If false, it may return the cached value.
+ * @return the activated remote object (its stub).
+ * @throws UnknownObjectException if the object with this id is unknown
+ * @throws ActivationException if the activation has failed due other reason
+ * @throws RemoteException if the remote call has failed.
+ */
+ MarshalledObject<? extends Remote> activate (ActivationID id, boolean force)
+ throws ActivationException, UnknownObjectException, RemoteException;
+}
diff --git a/libjava/classpath/java/rmi/activation/UnknownGroupException.java b/libjava/classpath/java/rmi/activation/UnknownGroupException.java
new file mode 100644
index 000000000..3c67aec0c
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/UnknownGroupException.java
@@ -0,0 +1,69 @@
+/* UnknownGroupException.java -- thrown on an invalid ActivationGroupID
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+/**
+ * Thrown when an <code>ActivationGroupID</code> parameter is invalid or
+ * unknown.
+ *
+ * @author unknown
+ * @see Activatable
+ * @see ActivationGroup
+ * @see ActivationID
+ * @see ActivationMonitor
+ * @see ActivationSystem
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class UnknownGroupException extends ActivationException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 7056094974750002460L;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public UnknownGroupException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/libjava/classpath/java/rmi/activation/UnknownObjectException.java b/libjava/classpath/java/rmi/activation/UnknownObjectException.java
new file mode 100644
index 000000000..8dbeb0e60
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/UnknownObjectException.java
@@ -0,0 +1,69 @@
+/* UnknownObjectException.java -- thrown on an invalid ActivationID
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.activation;
+
+/**
+ * Thrown when an <code>ActivationID</code> parameter is invalid or unknown.
+ *
+ * @author unknown
+ * @see Activatable
+ * @see ActivationGroup
+ * @see ActivationID
+ * @see ActivationMonitor
+ * @see ActivationSystem
+ * @see Activator
+ * @since 1.2
+ * @status updated to 1.4
+ */
+public class UnknownObjectException extends ActivationException
+{
+ /**
+ * Compatible with JDK 1.2+.
+ */
+ private static final long serialVersionUID = 3425547551622251430L;
+
+ /**
+ * Create an exception with an error message.
+ *
+ * @param s the message
+ */
+ public UnknownObjectException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/libjava/classpath/java/rmi/activation/package.html b/libjava/classpath/java/rmi/activation/package.html
new file mode 100644
index 000000000..9df518fed
--- /dev/null
+++ b/libjava/classpath/java/rmi/activation/package.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi.activation package.
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi.activation</title></head>
+
+<body>
+In the previous Classpath releases, an instance of a UnicastRemoteObject
+could be accessed from a server that:
+<ul>
+<li>has created an instance of that object<li>
+<li>has been running <i>all<i> the time</li>
+</ul>
+<p>The the activation system allows to activate and execute the object
+implementation on demand rather than running all time. If the activation
+system is persistent, the server can be terminated and then restarted.
+The clients, still holding remote references to the server side
+activatable objects, will activate those objects again. The server side
+objects will be reinstantiated (activated) during the first call of any
+remote method of such object.
+</p><p>
+The RMI client code for activatable objects is no different than the code for
+accessing non-activatable remote objects. Activation is a server-side feature.
+</p><p>
+In order for an object to be activated, the "activatable" object class
+(independently if it extends the {@link Activatable} class or not) defines a
+special public constructor that takes two arguments, its activation identifier
+({@link ActivationID}) and its activation data ({@link java.rmi.MarshalledObject}),
+supplied in the activation descriptor used during registration. When an
+activation group activates a remote object, it constructs the object via
+this special constructor. The remote object implementation may use the
+activation data to initialize itself in a needed manner. The remote object may
+also retain its activation identifier, so that it can inform the activation
+group when it becomes inactive (via a call to the Activatable.inactive method).
+</p>
+@author Audrius Meskauskas (audriusa@bioinformatics.org) (from empty)
+</body>
+</html>
diff --git a/libjava/classpath/java/rmi/dgc/DGC.java b/libjava/classpath/java/rmi/dgc/DGC.java
new file mode 100644
index 000000000..5ec874a5e
--- /dev/null
+++ b/libjava/classpath/java/rmi/dgc/DGC.java
@@ -0,0 +1,80 @@
+/* DGC.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.dgc;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.ObjID;
+
+/**
+ * The DGC implementation is used for the server side during the distributed
+ * garbage collection. This interface contains the two methods: dirty and clean.
+ * A dirty call is made when a remote reference is unmarshaled in a client. A
+ * corresponding clean call is made by client it no longer uses that remote
+ * reference. A reference to a remote object is also automatically released
+ * after so called lease period that starts after the dirty call is received. It
+ * is the client's responsibility to renew the leases, by making additional
+ * dirty calls before such leases expire.
+ */
+public interface DGC
+ extends Remote
+{
+ /**
+ * Mark the given objects referecnes as used on the client side.
+ *
+ * @param ids the ids of the used objects.
+ * @param sequenceNum the number of the call (used to detect and discard late
+ * calls).
+ * @param lease the requested lease
+ * @return the granted lease
+ */
+ Lease dirty(ObjID[] ids, long sequenceNum, Lease lease)
+ throws RemoteException;
+
+ /**
+ * Mark the given objects as no longer used on the client side.
+ *
+ * @param ids the ids of the objects that are no longer used.
+ * @param sequenceNum the number of the call (used to detect and discard late
+ * @param vmid the VMID of the client.
+ * @param strong make the "strong" clean call ("strong" calls are scheduled
+ * after the failed dirty calls).
+ */
+ void clean(ObjID[] ids, long sequenceNum, VMID vmid, boolean strong)
+ throws RemoteException;
+}
diff --git a/libjava/classpath/java/rmi/dgc/Lease.java b/libjava/classpath/java/rmi/dgc/Lease.java
new file mode 100644
index 000000000..58b82cf58
--- /dev/null
+++ b/libjava/classpath/java/rmi/dgc/Lease.java
@@ -0,0 +1,100 @@
+/* Lease.java
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.dgc;
+
+import java.io.Serializable;
+
+/**
+ * A lease object is used to request and grant leases for the remote objects. It
+ * contains the lease duration and the unique VM indentifier.
+ */
+public final class Lease
+ implements Serializable
+{
+
+ static final long serialVersionUID = - 5713411624328831948L;
+
+ private VMID vmid;
+
+ private long value;
+
+ /**
+ * Create the new lease with the given id and duration
+ *
+ * @param id the lease id
+ * @param duration the lease duration
+ */
+ public Lease(VMID id, long duration)
+ {
+ vmid = id;
+ value = duration;
+ }
+
+ /**
+ * Get the lease id.
+ *
+ * @return the lease id
+ */
+ public VMID getVMID()
+ {
+ return (vmid);
+ }
+
+ /**
+ * Get the lease duration
+ *
+ * @return the lease duration
+ */
+ public long getValue()
+ {
+ return (value);
+ }
+
+ /**
+ * Get the string representation of this lease
+ *
+ * @return the string represenation (lease id, followed by the lease
+ * duration).
+ */
+ public String toString()
+ {
+ return ("[" + vmid.toString() + ", " + Long.toString(value) + "]");
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/dgc/VMID.java b/libjava/classpath/java/rmi/dgc/VMID.java
new file mode 100644
index 000000000..925c1bfb1
--- /dev/null
+++ b/libjava/classpath/java/rmi/dgc/VMID.java
@@ -0,0 +1,191 @@
+/* VMID.java -- The object ID, unique between all virtual machines.
+ Copyright (c) 1996, 1997, 1998, 1999, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.dgc;
+
+import gnu.java.lang.CPStringBuilder;
+
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.rmi.server.UID;
+import java.util.Arrays;
+
+/**
+ * An identifier that is unique accross the all virtual machines. This class is
+ * used by distributed garbage collector to identify the virtual machine of
+ * the client, but may also be used in various other cases, when such identifier
+ * is required. This class separately stores and transfers the host IP
+ * address, but will try to do its best also for the case if it failed to
+ * determine it. The alternative algorithms are used in {@link UID} that is
+ * part of this class. The VMID's, created on the same host, but in the two
+ * separately (parallely) running virtual machines are different.
+ */
+public final class VMID implements Serializable
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ static final long serialVersionUID = -538642295484486218L;
+
+ /**
+ * If true, the IP of this host can ve reliably determined.
+ */
+ static boolean areWeUnique;
+
+ /**
+ * The IP address of the local host.
+ */
+ static byte[] localAddr;
+
+ /**
+ * The IP address of the local host.
+ */
+ private byte[] addr;
+
+ /**
+ * The cached hash code.
+ */
+ transient int hash;
+
+ /**
+ * The UID of this VMID.
+ */
+ private UID uid;
+
+ static
+ {
+ // This "local host" value usually indicates that the local
+ // IP address cannot be reliably determined.
+ byte[] localHost = new byte[] { 127, 0, 0, 1 };
+
+ try
+ {
+ localAddr = InetAddress.getLocalHost().getAddress();
+ areWeUnique = !Arrays.equals(localHost, localAddr);
+ }
+ catch (UnknownHostException uhex)
+ {
+ localAddr = localHost;
+ areWeUnique = false;
+ }
+ }
+
+ /**
+ * Create the new VMID. All VMID's are unique accross tha all virtual
+ * machines.
+ */
+ public VMID()
+ {
+ addr = localAddr;
+ uid = new UID();
+ }
+
+ /**
+ * Return true if it is possible to get the accurate address of this host.
+ * If false is returned, the created VMID's are less reliable, but the
+ * starting time and possibly the memory allocation are also taken into
+ * consideration in the incorporated UID. Hence the VMID's, created on the
+ * different virtual machines, still should be different.
+ *
+ * @deprecated VMID's are more or less always reliable.
+ *
+ * @return false if the local host ip address is 127.0.0.1 or unknown,
+ * true otherwise.
+ */
+ public static boolean isUnique ()
+ {
+ return areWeUnique;
+ }
+
+ /**
+ * Get the hash code of this VMID.
+ */
+ public int hashCode ()
+ {
+ if (hash==0)
+ {
+ for (int i = 0; i < localAddr.length; i++)
+ hash += addr[i];
+ hash = hash ^ uid.hashCode();
+ }
+ return hash;
+ }
+
+ /**
+ * Returns true if the passed parameter is also VMID and it is equal to this
+ * VMID. The VMID should only be equal to itself (also if the passed value is
+ * another instance, cloned by serialization).
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof VMID)
+ {
+ VMID other = (VMID) obj;
+
+ // The UID's are compared faster than arrays.
+ return uid.equals(other.uid) && Arrays.equals(addr, other.addr);
+ }
+ else
+ return false;
+
+ }
+
+ /**
+ * Get the string representation of this VMID.
+ */
+ public String toString ()
+ {
+ CPStringBuilder buf = new CPStringBuilder ("[VMID: ");
+
+ for (int i = 0; i < addr.length; i++)
+ {
+ if (i > 0)
+ {
+ buf.append (".");
+ }
+
+ buf.append (Integer.toString (addr [i]));
+ }
+
+ buf.append (" ");
+ buf.append (uid.toString ());
+ buf.append ("]");
+
+ return buf.toString();
+ }
+}
diff --git a/libjava/classpath/java/rmi/dgc/package.html b/libjava/classpath/java/rmi/dgc/package.html
new file mode 100644
index 000000000..7f0a2081c
--- /dev/null
+++ b/libjava/classpath/java/rmi/dgc/package.html
@@ -0,0 +1,52 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi.dgc package.
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi.dgc</title></head>
+
+<body>
+The Distributed Garbage Collector (DGC). The DGC is reponsible for keeping all
+locally created and exported remote objects as long as they are referenced
+by some remote clients. The client must periodically notify the server that
+it still wants to keep the remote object on the server side. The client
+notifies the server by calling methods, defined in the DGC interface.
+Other classes in this package define the parameters that are used in this
+interface. The DGC object of some host can be found and accessed by its
+object identifier (ObjID.DGC_ID), without involving the name service.
+</body>
+</html>
diff --git a/libjava/classpath/java/rmi/package.html b/libjava/classpath/java/rmi/package.html
new file mode 100644
index 000000000..1d36fe80a
--- /dev/null
+++ b/libjava/classpath/java/rmi/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi</title></head>
+
+<body>
+<p>Provides basic Remote Method Invocation (RMI) interfaces, classes and exceptions.</p>
+
+</body>
+</html>
diff --git a/libjava/classpath/java/rmi/registry/LocateRegistry.java b/libjava/classpath/java/rmi/registry/LocateRegistry.java
new file mode 100644
index 000000000..d0918e1b9
--- /dev/null
+++ b/libjava/classpath/java/rmi/registry/LocateRegistry.java
@@ -0,0 +1,87 @@
+/* LocateRegistry.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.registry;
+
+import gnu.java.rmi.registry.RegistryImpl;
+import gnu.java.rmi.registry.RegistryImpl_Stub;
+import gnu.java.rmi.server.UnicastRef;
+
+import java.rmi.RemoteException;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.RMISocketFactory;
+import java.rmi.server.RemoteRef;
+
+public final class LocateRegistry {
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private LocateRegistry() {}
+
+public static Registry getRegistry() throws RemoteException {
+ return (getRegistry("localhost", Registry.REGISTRY_PORT));
+}
+
+public static Registry getRegistry(int port) throws RemoteException {
+ return (getRegistry("localhost", port));
+}
+
+public static Registry getRegistry(String host) throws RemoteException {
+ return (getRegistry(host, Registry.REGISTRY_PORT));
+}
+
+public static Registry getRegistry(String host, int port) throws RemoteException {
+ return (getRegistry(host, port, RMISocketFactory.getSocketFactory()));
+}
+
+public static Registry getRegistry(String host, int port, RMIClientSocketFactory csf) throws RemoteException {
+ RemoteRef ref = new UnicastRef(new ObjID(ObjID.REGISTRY_ID), host, port, csf);
+ return (new RegistryImpl_Stub(ref));
+}
+
+public static Registry createRegistry(int port) throws RemoteException {
+ return (createRegistry(port, RMISocketFactory.getSocketFactory(), RMISocketFactory.getSocketFactory()));
+}
+
+public static Registry createRegistry(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException {
+ return (new RegistryImpl(port, csf, ssf));
+}
+
+}
diff --git a/libjava/classpath/java/rmi/registry/Registry.java b/libjava/classpath/java/rmi/registry/Registry.java
new file mode 100644
index 000000000..dabe6549c
--- /dev/null
+++ b/libjava/classpath/java/rmi/registry/Registry.java
@@ -0,0 +1,87 @@
+/* Registry.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.registry;
+
+import java.rmi.AccessException;
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface Registry extends Remote
+{
+ int REGISTRY_PORT = 1099;
+
+ /**
+ * Find and return the reference to the object that was previously bound
+ * to the registry by this name. For remote objects, this method returns
+ * the stub instances, containing the code for remote invocations.
+ *
+ * Since jdk 1.5 this method does not longer require the stub class
+ * (nameImpl_Stub) to be present. If such class is not found, the stub is
+ * replaced by the dynamically constructed proxy class. No attempt to find
+ * and load the stubs is made if the system property
+ * java.rmi.server.ignoreStubClasses is set to true (set to reduce the
+ * starting time if the stubs are surely not present and exclusively 1.2
+ * RMI is used).
+ *
+ * @param name the name of the object
+ *
+ * @return the reference to that object on that it is possible to invoke
+ * the (usually remote) object methods.
+ *
+ * @throws RemoteException
+ * @throws NotBoundException
+ * @throws AccessException
+ */
+ Remote lookup(String name)
+ throws RemoteException, NotBoundException, AccessException;
+
+ void bind(String name, Remote obj)
+ throws RemoteException, AlreadyBoundException, AccessException;
+
+ void unbind(String name)
+ throws RemoteException, NotBoundException, AccessException;
+
+ void rebind(String name, Remote obj)
+ throws RemoteException, AccessException;
+
+ String[] list()
+ throws RemoteException, AccessException;
+}
diff --git a/libjava/classpath/java/rmi/registry/RegistryHandler.java b/libjava/classpath/java/rmi/registry/RegistryHandler.java
new file mode 100644
index 000000000..19e8caa70
--- /dev/null
+++ b/libjava/classpath/java/rmi/registry/RegistryHandler.java
@@ -0,0 +1,58 @@
+/* RegistryHandler.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.registry;
+
+import java.rmi.RemoteException;
+import java.rmi.UnknownHostException;
+
+/**
+ * @deprecated
+ */
+public interface RegistryHandler
+{
+ /**
+ * @deprecated
+ */
+ Registry registryStub (String host, int port)
+ throws RemoteException, UnknownHostException;
+
+ /**
+ * @deprecated
+ */
+ Registry registryImpl (int port) throws RemoteException;
+}
diff --git a/libjava/classpath/java/rmi/registry/package.html b/libjava/classpath/java/rmi/registry/package.html
new file mode 100644
index 000000000..4e1667270
--- /dev/null
+++ b/libjava/classpath/java/rmi/registry/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi.registry package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi.registry</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
diff --git a/libjava/classpath/java/rmi/server/ExportException.java b/libjava/classpath/java/rmi/server/ExportException.java
new file mode 100644
index 000000000..b2d5bfca5
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/ExportException.java
@@ -0,0 +1,78 @@
+/* ExportException.java -- an export attempt failed
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.rmi.RemoteException;
+
+/**
+ * Thrown if an attempt to export a remote object fails.
+ *
+ * @author unknown
+ * @see UnicastRemoteObject
+ * @see Activatable
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ExportException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -9155485338494060170L;
+
+ /**
+ * Create an exception with the specified message.
+ *
+ * @param s the message
+ */
+ public ExportException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with the specified message and cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ExportException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/LoaderHandler.java b/libjava/classpath/java/rmi/server/LoaderHandler.java
new file mode 100644
index 000000000..de9d6532f
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/LoaderHandler.java
@@ -0,0 +1,71 @@
+/* LoaderHandler.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @deprecated
+ * @since 1.1
+ */
+public interface LoaderHandler
+{
+ /**
+ * For binary compatibility with the JDK, the string "sun.rmi.server".
+ * Not actually used for anything.
+ */
+ String packagePrefix = "sun.rmi.server";
+
+ /**
+ * @deprecated
+ */
+ Class<?> loadClass(String name)
+ throws MalformedURLException, ClassNotFoundException;
+
+ /**
+ * @deprecated
+ */
+ Class<?> loadClass(URL codebase, String name)
+ throws MalformedURLException, ClassNotFoundException;
+
+ /**
+ * @deprecated
+ */
+ Object getSecurityContext(ClassLoader loader);
+}
diff --git a/libjava/classpath/java/rmi/server/LogStream.java b/libjava/classpath/java/rmi/server/LogStream.java
new file mode 100644
index 000000000..a74ffb439
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/LogStream.java
@@ -0,0 +1,146 @@
+/* LogStream.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+/**
+ * @deprecated
+ */
+public class LogStream extends PrintStream
+{
+ public static final int SILENT = 0;
+ public static final int BRIEF = 10;
+ public static final int VERBOSE = 20;
+
+ private static PrintStream defStream;
+
+ private LogStream (OutputStream s)
+ {
+ super (s);
+ }
+
+ /**
+ * @deprecated
+ */
+ public static LogStream log (String name)
+ {
+ throw new Error ("Not implemented");
+ }
+
+ /**
+ * @deprecated
+ */
+ public static PrintStream getDefaultStream ()
+ {
+ return defStream;
+ }
+
+ /**
+ * @deprecated
+ */
+ public static void setDefaultStream (PrintStream s)
+ {
+ defStream = s;
+ }
+
+ /**
+ * @deprecated
+ */
+ public OutputStream getOutputStream ()
+ {
+ return out;
+ }
+
+ /**
+ * @deprecated
+ */
+ public void setOutputStream (OutputStream s)
+ {
+ out = s;
+ }
+
+ /**
+ * @deprecated
+ */
+ public void write (int buffer)
+ {
+ super.write (buffer);
+ }
+
+ /**
+ * @deprecated
+ */
+ public void write (byte[] buffer, int offset, int len)
+ {
+ super.write (buffer, offset, len);
+ }
+
+ /**
+ * @deprecated
+ */
+ public String toString ()
+ {
+ throw new Error ("Not implemented");
+ }
+
+ /**
+ * @deprecated
+ */
+ public static int parseLevel (String s)
+ {
+ if (s.equalsIgnoreCase ("silent"))
+ {
+ return SILENT;
+ }
+
+ if (s.equalsIgnoreCase ("brief"))
+ {
+ return BRIEF;
+ }
+
+ if (s.equalsIgnoreCase ("verbose"))
+ {
+ return VERBOSE;
+ }
+
+ return SILENT;
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/ObjID.java b/libjava/classpath/java/rmi/server/ObjID.java
new file mode 100644
index 000000000..2bdd44ae0
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/ObjID.java
@@ -0,0 +1,197 @@
+/* ObjID.java -- Unique object id with respect to the given host.
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+
+/**
+ * Represents the object identifier, unique for the host that generated it.
+ * The ObjID contains inside the integer object identifier that, if needed,
+ * may indicated that this is a reference to one of the well known objects
+ * on that host (registry, activator or dgc) and the {@link UID} that
+ * ensures uniqueness.
+ */
+public final class ObjID
+ implements Serializable
+{
+
+ /**
+ * Use serial version uid for interoperability.
+ */
+ static final long serialVersionUID = - 6386392263968365220L;
+
+ /**
+ * The object counter, which value is assigned when creating the ordinary
+ * objects without the known object id. The counter is incremented each time
+ * the new ObjID is constructed.
+ */
+ private static long next = 0x8000000000000000L;
+
+ /**
+ * The object to put the lock on when incrementing {@link #next}
+ */
+ private static final Object lock = ObjID.class;
+
+ /**
+ * Defines the ID of the naming service.
+ */
+ public static final int REGISTRY_ID = 0;
+
+ /**
+ * Defines the ID of the activator.
+ */
+ public static final int ACTIVATOR_ID = 1;
+
+ /**
+ * Defines the ID of the distributed garbage collector.
+ */
+ public static final int DGC_ID = 2;
+
+ /**
+ * The object Id (either well-known value or the value of the incrementing
+ * object counter.
+ */
+ long objNum;
+
+ /**
+ * The object unique identifier, generated individually for each object.
+ */
+ UID space;
+
+ /**
+ * Create the new object id, unique for this host.
+ */
+ public ObjID()
+ {
+ synchronized (lock)
+ {
+ objNum = next++;
+ }
+ space = new UID();
+ }
+
+ /**
+ * Create the new object id defining the well known remotely accessible
+ * object, present in this host. The well - known objects are:
+ * <ul>
+ * <li>{@link #REGISTRY_ID} - RMI naming service.</li>
+ * <li>{@link #ACTIVATOR_ID} - activator</li>
+ * <li>{@link #DGC_ID} - distributed garbage collector (grants lease
+ * durations to keep the object before it is garbage collected.</li>
+ * </ul>
+ *
+ * @param id the well known object id, one of the above.
+ */
+ public ObjID(int id)
+ {
+ objNum = (long) id;
+ space = new UID((short) 0);
+ }
+
+ /**
+ * Write object id as long, then the object {@link UID}.
+ */
+ public void write(ObjectOutput out) throws IOException
+ {
+ DataOutput dout = (DataOutput) out;
+ dout.writeLong(objNum);
+ space.write(dout);
+ }
+
+ /**
+ * Read object id (as long), then the object {@link UID}.
+ */
+ public static ObjID read(ObjectInput in) throws IOException
+ {
+ DataInput din = (DataInput) in;
+ ObjID id = new ObjID();
+ id.objNum = din.readLong();
+ id.space = UID.read(din);
+ return (id);
+ }
+
+ /**
+ * Get the hashcode.
+ */
+ public int hashCode()
+ {
+ return space == null ? (int) objNum : space.hashCode() ^ (int) objNum;
+ }
+
+ /**
+ * Compare for equality.
+ */
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ObjID)
+ {
+ ObjID that = (ObjID) obj;
+ return that.objNum == objNum && eq(that.space, space);
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Compare by .equals if both a and b are not null, compare directly if at
+ * least one of them is null.
+ */
+ static final boolean eq(Object a, Object b)
+ {
+ if (a == null || b == null)
+ return a == b;
+ else
+ return a.equals(b);
+ }
+
+ /**
+ * Get the string representation.
+ */
+ public String toString()
+ {
+ return (objNum + ":" + space);
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/server/Operation.java b/libjava/classpath/java/rmi/server/Operation.java
new file mode 100644
index 000000000..de30cd08a
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/Operation.java
@@ -0,0 +1,78 @@
+/* Operation.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * This class was used with jdk 1.1 stubs and skeletons. It is no longer
+ * needed since jdk 1.2 and higher.
+ *
+ * @deprecated
+ */
+public class Operation
+{
+ private String operation;
+
+ /**
+ * Create operation with the given name.
+ * @deprecated
+ */
+ public Operation (String op)
+ {
+ operation = op;
+ }
+
+ /**
+ * Get the name of the operation.
+ *
+ * @deprecated
+ */
+ public String getOperation ()
+ {
+ return operation;
+ }
+
+ /**
+ * Return the name of the operation.
+ *
+ * @deprecated
+ */
+ public String toString ()
+ {
+ return operation;
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/RMIClassLoader.java b/libjava/classpath/java/rmi/server/RMIClassLoader.java
new file mode 100644
index 000000000..f43a68c5b
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RMIClassLoader.java
@@ -0,0 +1,204 @@
+/* RMIClassLoader.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003, 2004
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import gnu.classpath.ServiceFactory;
+import gnu.classpath.SystemProperties;
+import gnu.java.rmi.server.RMIClassLoaderImpl;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+
+/**
+ * This class provides a set of public static utility methods for supporting
+ * network-based class loading in RMI. These methods are called by RMI's
+ * internal marshal streams to implement the dynamic class loading of types for
+ * RMI parameters and return values.
+ * @since 1.1
+ */
+public class RMIClassLoader
+{
+ /**
+ * This class isn't intended to be instantiated.
+ */
+ private RMIClassLoader() {}
+
+ /**
+ * @deprecated
+ */
+ public static Class<?> loadClass(String name)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ return loadClass("", name);
+ }
+
+ public static Class<?> loadClass(String codebase, String name)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codebase, name, null);
+ }
+
+ public static Class<?> loadClass(String codebase, String name,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codebase, name, defaultLoader);
+ }
+
+ public static Class<?> loadProxyClass (String codeBase, String[] interfaces,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadProxyClass(codeBase, interfaces, defaultLoader);
+ }
+
+ /**
+ * Loads a class from <code>codeBase</code>.
+ *
+ * This method delegates to
+ * {@link RMIClassLoaderSpi#loadClass(String, String, ClassLoader)} and
+ * passes <code>codeBase.toString()</code> as first argument,
+ * <code>name</code> as second argument and <code>null</code> as third
+ * argument.
+ *
+ * @param codeBase the code base from which to load the class
+ * @param name the name of the class
+ *
+ * @return the loaded class
+ *
+ * @throws MalformedURLException if the URL is not well formed
+ * @throws ClassNotFoundException if the requested class cannot be found
+ */
+ public static Class<?> loadClass(URL codeBase, String name)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.loadClass(codeBase.toString(), name, null);
+ }
+
+ /**
+ * Gets a classloader for the given codebase and with the current
+ * context classloader as parent.
+ *
+ * @param codebase
+ *
+ * @return a classloader for the given codebase
+ *
+ * @throws MalformedURLException if the codebase contains a malformed URL
+ */
+ public static ClassLoader getClassLoader(String codebase)
+ throws MalformedURLException
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.getClassLoader(codebase);
+ }
+
+ /**
+ * Returns a string representation of the network location where a remote
+ * endpoint can get the class-definition of the given class.
+ *
+ * @param cl
+ *
+ * @return a space seperated list of URLs where the class-definition
+ * of cl may be found
+ */
+ public static String getClassAnnotation(Class<?> cl)
+ {
+ RMIClassLoaderSpi spi = getProviderInstance();
+ if (spi == null)
+ spi = getDefaultProviderInstance();
+ return spi.getClassAnnotation(cl);
+ }
+
+ /**
+ * @deprecated
+ */
+ public static Object getSecurityContext (ClassLoader loader)
+ {
+ throw new Error ("Not implemented");
+ }
+
+ /**
+ * Returns the default service provider for <code>RMIClassLoader</code>.
+ *
+ * @return the default provider for <code>RMIClassLoader</code>
+ */
+ public static RMIClassLoaderSpi getDefaultProviderInstance()
+ {
+ return RMIClassLoaderImpl.getInstance();
+ }
+
+ /**
+ * Chooses, instantiates and returns a service provider.
+ *
+ * @return a service provider
+ */
+ private static RMIClassLoaderSpi getProviderInstance()
+ {
+ // If the user asked for the default, return it. We do a special
+ // check here because our standard service lookup function does not
+ // handle this -- nor should it.
+ String prop = SystemProperties.getProperty("java.rmi.server.RMIClassLoaderSpi");
+ if ("default".equals(prop))
+ return null;
+ Iterator it = ServiceFactory.lookupProviders(RMIClassLoaderSpi.class,
+ null);
+ if (it == null || ! it.hasNext())
+ return null;
+ // FIXME: the spec says we ought to throw an Error of some kind if
+ // the specified provider is not suitable for some reason. However
+ // our service factory simply logs the problem and moves on to the next
+ // provider in this situation.
+ return (RMIClassLoaderSpi) it.next();
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/RMIClassLoaderSpi.java b/libjava/classpath/java/rmi/server/RMIClassLoaderSpi.java
new file mode 100644
index 000000000..ec2c204f1
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RMIClassLoaderSpi.java
@@ -0,0 +1,64 @@
+/* RMIClassLoaderSpi.java --
+ Copyright (c) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.net.MalformedURLException;
+
+/**
+ * @author Michael Koch
+ * @since 1.4
+ */
+public abstract class RMIClassLoaderSpi
+{
+ public RMIClassLoaderSpi()
+ {
+ }
+
+ public abstract Class<?> loadClass (String codeBase, String name,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException;
+
+ public abstract Class<?> loadProxyClass (String codeBase, String[] interfaces,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException;
+
+ public abstract ClassLoader getClassLoader (String codebase)
+ throws MalformedURLException;
+
+ public abstract String getClassAnnotation (Class<?> cl);
+}
diff --git a/libjava/classpath/java/rmi/server/RMIClientSocketFactory.java b/libjava/classpath/java/rmi/server/RMIClientSocketFactory.java
new file mode 100644
index 000000000..ee829fb29
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RMIClientSocketFactory.java
@@ -0,0 +1,47 @@
+/* RMIClientSocketFactory.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.IOException;
+import java.net.Socket;
+
+public interface RMIClientSocketFactory
+{
+ Socket createSocket (String host, int port) throws IOException;
+}
diff --git a/libjava/classpath/java/rmi/server/RMIFailureHandler.java b/libjava/classpath/java/rmi/server/RMIFailureHandler.java
new file mode 100644
index 000000000..68a5706ed
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RMIFailureHandler.java
@@ -0,0 +1,46 @@
+/* RMIFailureHandler.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+public interface RMIFailureHandler
+{
+ /**
+ * @exception IOException If an error occurs
+ */
+ boolean failure (Exception ex);
+}
diff --git a/libjava/classpath/java/rmi/server/RMIServerSocketFactory.java b/libjava/classpath/java/rmi/server/RMIServerSocketFactory.java
new file mode 100644
index 000000000..7af8ef069
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RMIServerSocketFactory.java
@@ -0,0 +1,47 @@
+/* RMIServerSocketFactory.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+
+public interface RMIServerSocketFactory
+{
+ ServerSocket createServerSocket(int port) throws IOException;
+}
diff --git a/libjava/classpath/java/rmi/server/RMISocketFactory.java b/libjava/classpath/java/rmi/server/RMISocketFactory.java
new file mode 100644
index 000000000..af5a12072
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RMISocketFactory.java
@@ -0,0 +1,108 @@
+/* RMISocketFactory.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import gnu.java.rmi.server.RMIDefaultSocketFactory;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public abstract class RMISocketFactory
+ implements RMIClientSocketFactory, RMIServerSocketFactory
+{
+ private static RMISocketFactory defaultFactory;
+ private static RMISocketFactory currentFactory;
+ private static RMIFailureHandler currentHandler;
+
+ static
+ {
+ defaultFactory = new RMIDefaultSocketFactory();
+ currentFactory = defaultFactory;
+ }
+
+ public RMISocketFactory ()
+ {
+ }
+
+ /**
+ * @exception IOException If an error occurs
+ */
+ public abstract Socket createSocket (String host, int port)
+ throws IOException;
+
+ /**
+ * @exception IOException If an error occurs
+ */
+ public abstract ServerSocket createServerSocket (int port)
+ throws IOException;
+
+ /**
+ * @exception IOException If an error occurs
+ * @exception SecurityException FIXME
+ */
+ public static void setSocketFactory (RMISocketFactory fac)
+ throws IOException
+ {
+ currentFactory = fac;
+ }
+
+ public static RMISocketFactory getSocketFactory ()
+ {
+ return currentFactory;
+ }
+
+ public static RMISocketFactory getDefaultSocketFactory ()
+ {
+ return defaultFactory;
+ }
+
+ /**
+ * @exception SecurityException FIXME
+ */
+ public static void setFailureHandler (RMIFailureHandler fh)
+ {
+ currentHandler = fh;
+ }
+
+ public static RMIFailureHandler getFailureHandler ()
+ {
+ return currentHandler;
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/RemoteCall.java b/libjava/classpath/java/rmi/server/RemoteCall.java
new file mode 100644
index 000000000..cd4b004d8
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RemoteCall.java
@@ -0,0 +1,86 @@
+/* RemoteCall.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.StreamCorruptedException;
+
+/**
+ * @deprecated
+ */
+public interface RemoteCall
+{
+ /**
+ * @deprecated
+ */
+ ObjectOutput getOutputStream () throws IOException;
+
+ /**
+ * @deprecated
+ */
+ void releaseOutputStream () throws IOException;
+
+ /**
+ * @deprecated
+ */
+ ObjectInput getInputStream () throws IOException;
+
+ /**
+ * @deprecated
+ */
+ void releaseInputStream () throws IOException;
+
+ /**
+ * @deprecated
+ */
+ ObjectOutput getResultStream (boolean success)
+ throws IOException, StreamCorruptedException;
+
+ /**
+ * @deprecated
+ */
+ void executeCall () throws Exception;
+
+ /**
+ * @deprecated
+ */
+ void done () throws IOException;
+}
diff --git a/libjava/classpath/java/rmi/server/RemoteObject.java b/libjava/classpath/java/rmi/server/RemoteObject.java
new file mode 100644
index 000000000..220c1c95b
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RemoteObject.java
@@ -0,0 +1,202 @@
+/* RemoteObject.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.UnmarshalException;
+import java.util.WeakHashMap;
+
+public abstract class RemoteObject
+ implements Remote, Serializable {
+
+private static final long serialVersionUID = -3215090123894869218l;
+
+protected transient RemoteRef ref;
+
+private static final WeakHashMap stubs = new WeakHashMap();
+
+protected RemoteObject() {
+ this(null);
+}
+
+protected RemoteObject(RemoteRef newref) {
+ ref = newref;
+}
+
+public RemoteRef getRef() {
+ return (ref);
+}
+
+synchronized static void addStub(Remote obj, Remote stub)
+{
+ stubs.put(obj, stub);
+}
+
+synchronized static void deleteStub(Remote obj)
+{
+ stubs.remove(obj);
+}
+
+ public static Remote toStub(Remote obj) throws NoSuchObjectException
+ {
+ Remote stub = (Remote)stubs.get(obj);
+
+ if (stub == null)
+ throw new NoSuchObjectException(obj.getClass().getName());
+
+ return stub;
+ }
+
+public int hashCode() {
+ if (ref == null) {
+ return (0);
+ }
+ else {
+ return (ref.hashCode());
+ }
+}
+
+public boolean equals(Object obj) {
+ // We only compare references.
+ return (this == obj);
+}
+
+/**
+ * Get the string representation of this remote object.
+ */
+ public String toString()
+ {
+ if (ref == null)
+ return getClass ().toString ();
+ return (ref.toString ());
+ }
+
+ /**
+ * Read the remote object from the input stream. Expects the class name
+ * without package first. Then the method creates and assigns the {@link #ref}
+ * an instance of this class and calls its .readExternal method. The standard
+ * packageless class names are UnicastRef, UnicastRef2, UnicastServerRef,
+ * UnicastServerRef2, ActivatableRef or ActivatableServerRef.
+ *
+ * @param in the stream to read from
+ * @throws IOException if the IO exception occurs
+ * @throws ClassNotFoundException if the class with the given name is not
+ * present in the package gnu.java.rmi.server (for the case of the
+ * GNU Classpath.
+ */
+ private void readObject(ObjectInputStream in) throws IOException,
+ ClassNotFoundException
+ {
+ String cname = in.readUTF();
+ if (! cname.equals(""))
+ {
+ if (cname.equals("UnicastRef2"))
+ {
+ // hack for interoperating with JDK
+ cname = "UnicastRef";
+ in.read(); // some unknown UnicastRef2 field
+ }
+
+ // It would be nice to use RemoteRef.packagePrefix here, but for binary
+ // compatibility with the JDK that has to contain "sun.rmi.server"...
+ cname = "gnu.java.rmi.server." + cname;
+ try
+ {
+ Class cls = Class.forName(cname);
+ ref = (RemoteRef) cls.newInstance();
+ }
+ catch (InstantiationException e1)
+ {
+ throw new UnmarshalException("failed to create ref", e1);
+ }
+ catch (IllegalAccessException e2)
+ {
+ throw new UnmarshalException("failed to create ref", e2);
+ }
+ ref.readExternal(in);
+ }
+ else
+ {
+ ref = (RemoteRef) in.readObject();
+ }
+ }
+
+ /**
+ * Write the remote object to the output stream. This method first calls
+ * {@link RemoteRef#getRefClass(ObjectOutput)} on the {@link #ref} to get the
+ * class name without package, writes this name and then calls the
+ * ref.writeObject to write the data. The standard packageless class names are
+ * UnicastRef, UnicastRef2, UnicastServerRef, UnicastServerRef2,
+ * ActivatableRef or ActivatableServerRef. The empty string with the
+ * subsequently following serialized ref instance be written if the
+ * ref.getRefClass returns null.
+ *
+ * @param out the stream to write to
+ * @throws IOException if one occurs during writing
+ * @throws ClassNotFoundException never in this implementation (specified as
+ * part of the API standard)
+ * @throws UnmarshalException if the remote reference of this remote object is
+ * null.
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException,
+ ClassNotFoundException
+ {
+ if (ref == null)
+ {
+ throw new UnmarshalException("no ref to serialize");
+ }
+ String cname = ref.getRefClass(out);
+ if (cname != null && cname.length() > 0)
+ {
+ out.writeUTF(cname);
+ ref.writeExternal(out);
+ }
+ else
+ {
+ out.writeUTF("");
+ out.writeObject(ref);
+ }
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/server/RemoteObjectInvocationHandler.java b/libjava/classpath/java/rmi/server/RemoteObjectInvocationHandler.java
new file mode 100644
index 000000000..0cf4bca98
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RemoteObjectInvocationHandler.java
@@ -0,0 +1,229 @@
+/* RemoteObjectInvocationHandler.java -- RMI stub replacement.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package java.rmi.server;
+
+import gnu.java.rmi.server.RMIHashes;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.UnexpectedException;
+import java.rmi.registry.Registry;
+import java.rmi.server.RemoteObject;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Hashtable;
+
+/**
+ * Together with dynamic proxy instance, this class replaces the generated RMI
+ * stub (*_Stub) classes that (following 1.5 specification) should be no longer
+ * required. It is unusual to use the instances of this class directly in the
+ * user program. Such instances are automatically created and returned by
+ * {@link Registry} or {@link UnicastRemoteObject} methods if the remote
+ * reference is known but the corresponding stub class is not accessible.
+ *
+ * @see Registry#lookup
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class RemoteObjectInvocationHandler extends RemoteObject implements
+ InvocationHandler, Remote, Serializable
+{
+ /**
+ * Use the jdk 1.5 SUID for interoperability.
+ */
+ static final long serialVersionUID = 2L;
+
+ /**
+ * The RMI method hash codes, computed once as described in the section 8.3
+ * of the Java Remote Method Invocation (RMI) Specification.
+ */
+ static Hashtable methodHashCodes = new Hashtable();
+
+ /**
+ * The empty class array to define parameters of .hashCode and .toString.
+ */
+ static final Class[] noArgsC = new Class[0];
+
+ /**
+ * The class array to define parameters of .equals
+ */
+ static final Class[] anObjectC = new Class[] { Object.class };
+
+ /**
+ * The empty object array to replace null when no args are passed.
+ */
+ static final Object[] noArgs = new Object[0];
+
+ /**
+ * Construct the remote invocation handler that forwards calls to the given
+ * remote object.
+ *
+ * @param reference the reference to the remote object where the method
+ * calls should be forwarded.
+ */
+ public RemoteObjectInvocationHandler(RemoteRef reference)
+ {
+ super(reference);
+ }
+
+ /**
+ * Invoke the remote method. When the known method is invoked on a created RMI
+ * stub proxy class, the call is delivered to this method and then transferred
+ * to the {@link RemoteRef#invoke(Remote, Method, Object[], long)} of the
+ * remote reference that was passed in constructor. The methods are handled as
+ * following:
+ * <ul>
+ * <li> The toString() method is delegated to the passed proxy instance.</li>
+ * <li>The .equals method only returns true if the passed object is an
+ * instance of proxy class and its invocation handler is equal to this
+ * invocation handles.</li>
+ * <li>The .hashCode returns the hashCode of this invocation handler (if the.</li>
+ * <li>All other methods are converted to remote calls and forwarded to the
+ * remote reference. </li>
+ * </ul>
+ *
+ * @param proxyInstance
+ * the instance of the proxy stub
+ * @param method
+ * the method being invoked
+ * @param parameters
+ * the method parameters
+ * @return the method return value, returned by RemoteRef.invoke
+ * @throws IllegalAccessException
+ * if the passed proxy instance does not implement Remote interface.
+ * @throws UnexpectedException
+ * if remote call throws some exception, not listed in the
+ * <code>throws</code> clause of the method being called.
+ * @throws Throwable
+ * that is thrown by remote call, if that exception is listend in
+ * the <code>throws</code> clause of the method being called.
+ */
+ public Object invoke(Object proxyInstance, Method method, Object[] parameters)
+ throws Throwable
+ {
+ if (!(proxyInstance instanceof Remote))
+ {
+ String name = proxyInstance == null ? "null"
+ : proxyInstance.getClass().getName();
+ throw new IllegalAccessException(name + " does not implement "
+ + Remote.class.getName());
+ }
+
+ if (parameters == null)
+ parameters = noArgs;
+
+ String name = method.getName();
+ switch (name.charAt(0))
+ {
+ case 'e':
+ if (parameters.length == 1 && name.equals("equals")
+ && method.getParameterTypes()[0].equals(Object.class))
+ {
+ if (parameters[0] instanceof Proxy)
+ {
+ Object handler = Proxy.getInvocationHandler(parameters[0]);
+ if (handler == null)
+ return Boolean.FALSE;
+ else
+ return handler.equals(this) ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else
+ return Boolean.FALSE;
+ }
+ break;
+ case 'h':
+ if (parameters.length == 0 && name.equals("hashCode"))
+ {
+ int hashC = Proxy.getInvocationHandler(proxyInstance).hashCode();
+ return new Integer(hashC);
+ }
+ break;
+ case 't':
+ if (parameters.length == 0 && name.equals("toString"))
+ return "Proxy stub:"+ref.remoteToString();
+ break;
+ default:
+ break;
+ }
+
+ Long hash = (Long) methodHashCodes.get(method);
+ if (hash == null)
+ {
+ hash = new Long(RMIHashes.getMethodHash(method));
+ methodHashCodes.put(method, hash);
+ }
+
+ try
+ {
+ return getRef().invoke((Remote) proxyInstance, method, parameters,
+ hash.longValue());
+ }
+ catch (RuntimeException exception)
+ {
+ // RuntimeException is always supported.
+ throw exception;
+ }
+ catch (RemoteException exception)
+ {
+ // All remote methods can throw RemoteException.
+ throw exception;
+ }
+ catch (Error exception)
+ {
+ throw exception;
+ }
+ catch (Exception exception)
+ {
+ Class[] exceptions = method.getExceptionTypes();
+ Class exceptionClass = exception.getClass();
+
+ for (int i = 0; i < exceptions.length; i++)
+ {
+ if (exceptions[i].equals(exceptionClass))
+ throw exception;
+ }
+ throw new UnexpectedException(method.getName(), exception);
+ }
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/server/RemoteRef.java b/libjava/classpath/java/rmi/server/RemoteRef.java
new file mode 100644
index 000000000..e0488fb4c
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RemoteRef.java
@@ -0,0 +1,137 @@
+/* RemoteRef.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * Represents a handler to the remote object. Each instance of the
+ * {@link RemoteStub} contains such handler and uses it to invoke remote
+ * methods via {@link #invoke(Remote, Method, Object[], long)}.
+ */
+public interface RemoteRef extends Externalizable
+{
+ /**
+ * Indicates compatibility with JDK 1.1.*
+ */
+ long serialVersionUID = 3632638527362204081L;
+
+ /**
+ * For binary compatibility with the JDK, the string "sun.rmi.server".
+ * Not actually used for anything.
+ */
+ String packagePrefix = "sun.rmi.server";
+
+ /**
+ * @deprecated use {@link #invoke(Remote, Method, Object[], long)} instead.
+ */
+ void invoke (RemoteCall call) throws Exception;
+
+ /**
+ * Invoke a method. This method either returns the result of remote invocation
+ * or throws RemoteException if the remote call failed. Other exceptions may
+ * be thrown if some problem has occured in the application level.
+ *
+ * @param obj the object, containing the remote reference (for instance,
+ * remote stub, generated by rmic).
+ * @param method the method to invoke
+ * @param params the method parameters
+ * @param methodHash a persistent hash code that can be used to represent a
+ * method
+ * @return the result of the remote invocation
+ * @throws RemoteException if the remote call has failed
+ * @throws Exception if one is raised at the application level
+ */
+ Object invoke (Remote obj, Method method, Object[] params, long methodHash)
+ throws Exception;
+
+ /**
+ * @deprecated use {@link #invoke(Remote, Method, Object[], long)} instead.
+ */
+ RemoteCall newCall (RemoteObject obj, Operation[] op, int opnum, long hash)
+ throws RemoteException;
+
+ /**
+ * @deprecated use {@link #invoke(Remote, Method, Object[], long)} instead.
+ */
+ void done (RemoteCall call) throws RemoteException;
+
+ /**
+ * Compare two remote objects for equality. The references are equal if
+ * they point to the same remote object.
+ *
+ * @param ref the reference to compare.
+ *
+ * @return true if this and passed references both point to the same remote
+ * object, false otherwise.
+ */
+ boolean remoteEquals (RemoteRef ref);
+
+ /**
+ * Get the hashcode for a remote object. Two remote object stubs, referring
+ * to the same remote object, have the same hash code.
+ *
+ * @return the hashcode of the remote object
+ */
+ int remoteHashCode();
+
+
+ /**
+ * Returns the class name of the reference type that must be written to the
+ * given stream. When writing, this returned name is passed first, and
+ * the reference.writeExternal(out) writes the reference specific data.
+ *
+ * @param out the stream, where the data must be written
+ *
+ * @return the class name.
+ */
+ String getRefClass (ObjectOutput out);
+
+ /**
+ * Get the string representation of this remote reference.
+ *
+ * @return the string representation.
+ */
+ String remoteToString();
+}
diff --git a/libjava/classpath/java/rmi/server/RemoteServer.java b/libjava/classpath/java/rmi/server/RemoteServer.java
new file mode 100644
index 000000000..158c46439
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RemoteServer.java
@@ -0,0 +1,115 @@
+/* RemoteServer.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import gnu.java.rmi.server.RMIIncomingThread;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+/**
+ * A common superclass for the server implementations.
+ */
+public abstract class RemoteServer
+ extends RemoteObject
+{
+ private static final long serialVersionUID = - 4100238210092549637L;
+
+ /**
+ * Does nothing, delegates to super().
+ */
+ protected RemoteServer()
+ {
+ super();
+ }
+
+ /**
+ * Does nothing, delegates to super(ref).
+ */
+ protected RemoteServer(RemoteRef ref)
+ {
+ super(ref);
+ }
+
+ /**
+ * Get the host of the calling client. The current thread must be an instance
+ * of the {@link RMIIncomingThread}.
+ *
+ * @return the client host address
+ *
+ * @throws ServerNotActiveException if the current thread is not an instance
+ * of the RMIIncomingThread.
+ */
+ public static String getClientHost() throws ServerNotActiveException
+ {
+ Thread currThread = Thread.currentThread();
+ if (currThread instanceof RMIIncomingThread)
+ {
+ RMIIncomingThread incomingThread = (RMIIncomingThread) currThread;
+ return incomingThread.getClientHost();
+ }
+ else
+ {
+ throw new ServerNotActiveException(
+ "Unknown client host - current thread not instance of 'RMIIncomingThread'");
+ }
+ }
+
+ /**
+ * Set the stream for logging RMI calls.
+ *
+ * @param out the stream to set or null to turn the logging off.
+ */
+ public static void setLog(OutputStream out)
+ {
+ throw new Error("Not implemented");
+ }
+
+ /**
+ * Get the stream for logging RMI calls.
+ *
+ * @return the associated stream.
+ */
+ public static PrintStream getLog()
+ {
+ throw new Error("Not implemented");
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/server/RemoteStub.java b/libjava/classpath/java/rmi/server/RemoteStub.java
new file mode 100644
index 000000000..9fd5846ee
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/RemoteStub.java
@@ -0,0 +1,80 @@
+/* RemoteStub.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * This is a base class for the automatically generated RMI stubs.
+ */
+public abstract class RemoteStub extends RemoteObject
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ static final long serialVersionUID = -1585587260594494182l;
+
+ /**
+ * Constructs the remote stub with no reference set.
+ */
+ protected RemoteStub ()
+ {
+ super ();
+ }
+
+ /**
+ * Constructs the remote stub that uses given remote reference for the
+ * method invocations.
+ *
+ * @param ref the remote reference for the method invocation.
+ */
+ protected RemoteStub (RemoteRef ref)
+ {
+ super (ref);
+ }
+
+ /**
+ * Sets the given remote reference for the given stub. This method is
+ * deprecated. Pass the stub remote reference to the RemoteStub
+ * constructor instead.
+ *
+ * @deprecated
+ */
+ protected static void setRef (RemoteStub stub, RemoteRef ref)
+ {
+ stub.ref = ref;
+ }
+} // class RemoteSub
diff --git a/libjava/classpath/java/rmi/server/ServerCloneException.java b/libjava/classpath/java/rmi/server/ServerCloneException.java
new file mode 100644
index 000000000..bda41b3ce
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/ServerCloneException.java
@@ -0,0 +1,117 @@
+/* ServerCloneException.java -- a UnicastRemoteObject could not be cloned
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * Thrown if a remote exception occurs during the cloning process of a
+ * <code>UnicastRemoteObject</code>.
+ *
+ * @author unknown
+ * @see UnicastRemoteObject#clone()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ServerCloneException extends CloneNotSupportedException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 6617456357664815945L;
+
+ /**
+ * The cause of this exception. This pre-dates the exception chaining
+ * of Throwable; and although you can change this field, you are wiser
+ * to leave it alone.
+ *
+ * @serial the exception cause
+ */
+ public Exception detail;
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ServerCloneException(String s)
+ {
+ this(s, null);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public ServerCloneException(String s, Exception e)
+ {
+ super(s);
+ initCause(e);
+ detail = e;
+ }
+
+ /**
+ * This method returns a message indicating what went wrong, in this
+ * format:
+ * <code>super.getMessage() + (detail == null ? ""
+ * : "; nested exception is:\n\t" + detail)</code>.
+ *
+ * @return the chained message
+ */
+ public String getMessage()
+ {
+ if (detail == this || detail == null)
+ return super.getMessage();
+ return super.getMessage() + "; nested exception is:\n\t" + detail;
+ }
+
+ /**
+ * Returns the cause of this exception. Note that this may not be the
+ * original cause, thanks to the <code>detail</code> field being public
+ * and non-final (yuck). However, to avoid violating the contract of
+ * Throwable.getCause(), this returns null if <code>detail == this</code>,
+ * as no exception can be its own cause.
+ *
+ * @return the cause
+ * @since 1.4
+ */
+ public Throwable getCause()
+ {
+ return detail == this ? null : detail;
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/ServerNotActiveException.java b/libjava/classpath/java/rmi/server/ServerNotActiveException.java
new file mode 100644
index 000000000..0581b63bc
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/ServerNotActiveException.java
@@ -0,0 +1,72 @@
+/* ServerNotActiveException.java -- the method is not servicing a remote call
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * Thrown during <code>RemoteServer.getClientHost</code> if the host is
+ * not servicing a remote method call.
+ *
+ * @author unknown
+ * @see RemoteServer#getClientHost()
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class ServerNotActiveException extends Exception
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = 4687940720827538231L;
+
+ /**
+ * Create an exception with no message.
+ */
+ public ServerNotActiveException()
+ {
+ }
+
+ /**
+ * Create an exception with a message.
+ *
+ * @param s the message
+ */
+ public ServerNotActiveException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/ServerRef.java b/libjava/classpath/java/rmi/server/ServerRef.java
new file mode 100644
index 000000000..5d34ef2e2
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/ServerRef.java
@@ -0,0 +1,51 @@
+/* ServerRef.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+public interface ServerRef extends RemoteRef
+{
+ long serialVersionUID = -4557750989390278438L;
+
+ RemoteStub exportObject(Remote obj, Object data) throws RemoteException;
+
+ String getClientHost() throws ServerNotActiveException;
+}
diff --git a/libjava/classpath/java/rmi/server/Skeleton.java b/libjava/classpath/java/rmi/server/Skeleton.java
new file mode 100644
index 000000000..94d57986b
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/Skeleton.java
@@ -0,0 +1,57 @@
+/* Skeleton.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.rmi.Remote;
+
+/**
+ * @deprecated
+ */
+public interface Skeleton
+{
+ /**
+ * @deprecated
+ */
+ void dispatch (Remote obj, RemoteCall theCall, int opnum, long hash)
+ throws Exception;
+
+ /**
+ * @deprecated
+ */
+ Operation[] getOperations();
+}
diff --git a/libjava/classpath/java/rmi/server/SkeletonMismatchException.java b/libjava/classpath/java/rmi/server/SkeletonMismatchException.java
new file mode 100644
index 000000000..9c0206ab3
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/SkeletonMismatchException.java
@@ -0,0 +1,68 @@
+/* SkeletonMismatchException.java -- thrown when stub class versions mismatch
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+import java.rmi.RemoteException;
+
+/**
+ * Thrown if a call is received that does not match a Skeleton. Note that
+ * Skeletons are no longer required.
+ *
+ * @author unknown
+ * @since 1.1
+ * @deprecated no replacement. Skeletons are no longer required.
+ * @status updated to 1.4
+ */
+public class SkeletonMismatchException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1.
+ */
+ private static final long serialVersionUID = -7780460454818859281l;
+
+ /**
+ * Create an exception with the specified message.
+ *
+ * @param s the message
+ * @deprecated no longer needed
+ */
+ public SkeletonMismatchException(String s)
+ {
+ super(s);
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/SkeletonNotFoundException.java b/libjava/classpath/java/rmi/server/SkeletonNotFoundException.java
new file mode 100644
index 000000000..596aae154
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/SkeletonNotFoundException.java
@@ -0,0 +1,79 @@
+/* SkeletonNotFoundException.java -- thrown if a Skeleton is not found
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.rmi.RemoteException;
+
+/**
+ * Thrown if a Skeleton corresponding to the remote object is not found.
+ * Note that Skeletons are no longer required.
+ *
+ * @author unknown
+ * @since 1.1
+ * @deprecated no replacement. Skeletons are no longer required.
+ * @status updated to 1.4
+ */
+public class SkeletonNotFoundException extends RemoteException
+{
+ /**
+ * Compatible with JDK 1.1.
+ */
+ private static final long serialVersionUID = -7860299673822761231L;
+
+ /**
+ * Create an exception with the specified message.
+ *
+ * @param s the message
+ */
+ public SkeletonNotFoundException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with the specified message and cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public SkeletonNotFoundException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/SocketSecurityException.java b/libjava/classpath/java/rmi/server/SocketSecurityException.java
new file mode 100644
index 000000000..aaf7698f4
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/SocketSecurityException.java
@@ -0,0 +1,75 @@
+/* SocketSecurityException.java -- the socket could not be created
+ Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+/**
+ * Thrown during remote object export if the code does not have permission
+ * to create a <code>java.net.ServerSocket</code> on the specified port.
+ *
+ * @author unknown
+ * @since 1.1
+ * @status updated to 1.4
+ */
+public class SocketSecurityException extends ExportException
+{
+ /**
+ * Compatible with JDK 1.1+.
+ */
+ private static final long serialVersionUID = -7622072999407781979L;
+
+ /**
+ * Create an exception with the specified message.
+ *
+ * @param s the message
+ */
+ public SocketSecurityException(String s)
+ {
+ super(s);
+ }
+
+ /**
+ * Create an exception with the specified message and cause.
+ *
+ * @param s the message
+ * @param e the cause
+ */
+ public SocketSecurityException(String s, Exception e)
+ {
+ super(s, e);
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/UID.java b/libjava/classpath/java/rmi/server/UID.java
new file mode 100644
index 000000000..464d3d860
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/UID.java
@@ -0,0 +1,225 @@
+/* UID.java -- The unique object Id
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.InetAddress;
+
+/**
+ * Represents the unique identifier over time for the host which has generated
+ * it. It contains time (when created), counter (the number of the UID
+ * creation order) and virtual machine id components. The UID can also be
+ * constructed specifying a "well known" identifier in the for of short:
+ * this identifier defines the UID uniqueness alone.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public final class UID
+ implements Serializable
+{
+ /**
+ * Use the serial version uid for interoperability.
+ */
+ private static final long serialVersionUID = 1086053664494604050L;
+
+ /**
+ * The UID counter (the ordinary number in the sequence of number of UID's,
+ * created during the recent millisecond). In the next millisecond, it
+ * starts from the minimal value again. In the unlikely case of creating
+ * more than 65536 uids per millisecond the process pauses till the next
+ * ms.
+ */
+ private static short uidCounter = Short.MIN_VALUE;
+
+ /**
+ * The time, when the last UID has been created.
+ */
+ private static long last;
+
+ /**
+ * This constant tries to be the unique identifier of the virtual machine.
+ */
+ private static final int machineId = getMachineId();
+
+ /**
+ * The UID number in the UID creation sequence.
+ */
+ private short count;
+
+ /**
+ * Always gets the uniqueNr value.
+ */
+ private int unique;
+
+ /**
+ * The time stamp, when the UID was created.
+ */
+ private long time;
+
+ /**
+ * Create the new UID that would have the described features of the
+ * uniqueness.
+ */
+ public UID()
+ {
+ synchronized (UID.class)
+ {
+ time = System.currentTimeMillis();
+ unique = machineId;
+ if (time > last)
+ {
+ last = time;
+ count = uidCounter = Short.MIN_VALUE;
+ }
+ else
+ {
+ if (uidCounter == Short.MAX_VALUE)
+ {
+ // Make a 2 ms pause if the counter has reached the maximal
+ // value. This should seldom happen.
+ try
+ {
+ Thread.sleep(2);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ uidCounter = Short.MIN_VALUE;
+ time = last = System.currentTimeMillis();
+ }
+ count = ++uidCounter;
+ }
+ }
+ }
+
+ /**
+ * Create the new UID with the well known id (number). All UIDs, creates
+ * with the this constructor having the same parameter are equal to each
+ * other (regardless to the host and time where they were created.
+ *
+ * @param wellKnownId the well known UID.
+ */
+ public UID(short wellKnownId)
+ {
+ unique = wellKnownId;
+ }
+
+ /**
+ * Get the hashCode of this UID.
+ */
+ public int hashCode()
+ {
+ return (int) (unique ^ time ^ count);
+ }
+
+ /**
+ * Compare this UID with another UID for equality (not equal to other types of
+ * objects).
+ */
+ public boolean equals(Object other)
+ {
+ if (other instanceof UID)
+ {
+ UID ui = (UID) other;
+ return unique == ui.unique && time == ui.time && count == ui.count;
+ }
+ else
+ return false;
+ }
+
+ public static UID read(DataInput in) throws IOException
+ {
+ UID uid = new UID();
+ uid.unique = in.readInt();
+ uid.time = in.readLong();
+ uid.count = in.readShort();
+ return (uid);
+ }
+
+ public void write(DataOutput out) throws IOException
+ {
+ out.writeInt(unique);
+ out.writeLong(time);
+ out.writeShort(count);
+ }
+
+ /**
+ * Do our best to get the Id of this virtual machine.
+ */
+ static int getMachineId()
+ {
+ int hostIpHash;
+
+ try
+ {
+ // Try to get the host IP.
+ String host = InetAddress.getLocalHost().toString();
+ // This hash is content - based, not the address based.
+ hostIpHash = host.hashCode();
+ }
+ catch (Exception e)
+ {
+ // Failed due some reason.
+ hostIpHash = 0;
+ }
+
+ // Should be the unque address if hashcodes are addresses.
+ // Additionally, add the time when the RMI system was probably started
+ // (this class was first instantiated).
+ return new Object().hashCode() ^ (int) System.currentTimeMillis()
+ ^ hostIpHash;
+ }
+
+ /**
+ * Get the string representation of this UID.
+ *
+ * @return a string, uniquely identifying this id.
+ */
+ public String toString()
+ {
+ int max = Character.MAX_RADIX;
+ // Translate into object count, counting from 0.
+ long lc = (count - Short.MIN_VALUE) & 0xFFFF;
+ return Long.toString(unique, max) + ":" + Long.toString(time, max) + "."
+ + Long.toString(lc, max);
+ }
+}
diff --git a/libjava/classpath/java/rmi/server/UnicastRemoteObject.java b/libjava/classpath/java/rmi/server/UnicastRemoteObject.java
new file mode 100644
index 000000000..b6a972126
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/UnicastRemoteObject.java
@@ -0,0 +1,251 @@
+/* UnicastRemoteObject.java --
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.rmi.server;
+
+import gnu.java.rmi.server.UnicastServerRef;
+
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * This class obtains stub that communicates with the remote object.
+ */
+public class UnicastRemoteObject extends RemoteServer
+{
+ /**
+ * Use SVUID for interoperability.
+ */
+ private static final long serialVersionUID = 4974527148936298033L;
+
+ //The following serialized fields are from Java API Documentation
+ // "Serialized form"
+
+ /**
+ * The port, on that the created remote object becomes available,
+ * zero meaning the anonymous port.
+ */
+ private int port;
+
+ /**
+ * The client socket factory for producing client sockets, used by this
+ * object.
+ */
+ private RMIClientSocketFactory csf;
+
+ /**
+ * The server socket factory for producing server sockets, used by this
+ * object.
+ */
+ private RMIServerSocketFactory ssf;
+
+ /**
+ * Create and export new remote object without specifying the port value.
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ protected UnicastRemoteObject()
+ throws RemoteException
+ {
+ this(0);
+ }
+
+ /**
+ * Create and export the new remote object, making it available at the
+ * given port, local host.
+ *
+ * @param port the port, on that the object should become available.
+ * Zero means anonymous port.
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ protected UnicastRemoteObject(int port)
+ throws RemoteException
+ {
+ this(port, RMISocketFactory.getSocketFactory(),
+ RMISocketFactory.getSocketFactory());
+ }
+
+ /**
+ * Create and export the new remote object, making it available at the
+ * given port, using sockets, produced by the specified factories.
+ *
+ * @param port the port, on that the object should become available.
+ * Zero means anonymous port.
+ *
+ * @param clientSocketFactory the client socket factory
+ * @param serverSocketFactory the server socket factory
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ protected UnicastRemoteObject(int port,
+ RMIClientSocketFactory clientSocketFactory,
+ RMIServerSocketFactory serverSocketFactory)
+ throws RemoteException
+ {
+ this.port = port;
+ //Is RMIXXXSocketFactory serializable
+ //this.csf = csf;
+ //this.ssf = ssf;
+ this.ref = new UnicastServerRef(new ObjID(), port, serverSocketFactory);
+ exportObject(this, port);
+ }
+
+ protected UnicastRemoteObject(RemoteRef ref)
+ throws RemoteException
+ {
+ super((UnicastServerRef) ref);
+ exportObject(this, 0);
+ }
+
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ throw new Error("Not implemented");
+ }
+
+ /**
+ * Export object, making it available for the remote calls at the
+ * anonymous port.
+ *
+ * This method returns the instance of the abstract class, not an interface.
+ * Hence it will not work with the proxy stubs that are supported since
+ * jdk 1.5 (such stubs cannot be derived from the RemoteStub). Only use
+ * this method if you are sure that the stub class will be accessible.
+ *
+ * @param obj the object being exported.
+ *
+ * @return the remote object stub
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ public static RemoteStub exportObject(Remote obj)
+ throws RemoteException
+ {
+ return (RemoteStub) exportObject(obj, 0);
+ }
+
+ /**
+ * Export object, making it available for the remote calls at the
+ * specified port.
+ *
+ * Since jdk 1.5 this method does not longer require the stub class to be
+ * present. If such class is not found, the stub is replaced by the
+ * dynamically constructed proxy class. No attempt to find and load the stubs
+ * is made if the system property java.rmi.server.ignoreStubClasses
+ * is set to true (set to reduce the starting time if the stubs are
+ * surely not present and exclusively 1.2 RMI is used).
+ *
+ * @param obj the object being exported.
+ * @param port the remote object port
+ *
+ * @return the remote object stub
+ *
+ * @throws RemoteException if the attempt to export the object failed.
+ */
+ public static Remote exportObject(Remote obj, int port)
+ throws RemoteException
+ {
+ return exportObject(obj, port, null);
+ }
+
+ /**
+ * Create and export the new remote object, making it available at the
+ * given port, using sockets, produced by the specified factories.
+ *
+ * Since jdk 1.5 this method does not longer require the stub class to be
+ * present. If such class is not found, the stub is replaced by the
+ * dynamically constructed proxy class. No attempt to find and load the stubs
+ * is made if the system property java.rmi.server.ignoreStubClasses
+ * is set to true (set to reduce the starting time if the stubs are
+ * surely not present and exclusively 1.2 RMI is used).
+ *
+ * @param port the port, on that the object should become available.
+ * Zero means anonymous port.
+ *
+ * @param serverSocketFactory the server socket factory
+ */
+ static Remote exportObject(Remote obj, int port,
+ RMIServerSocketFactory serverSocketFactory)
+ throws RemoteException
+ {
+ UnicastServerRef sref = null;
+ if (obj instanceof RemoteObject)
+ sref = (UnicastServerRef) ((RemoteObject) obj).getRef();
+
+ if (sref == null)
+ sref = new UnicastServerRef(new ObjID(), port, serverSocketFactory);
+
+ Remote stub = sref.exportObject(obj);
+ addStub(obj, stub);
+ return stub;
+ }
+
+ /**
+ * FIXME
+ */
+ public static Remote exportObject(Remote obj, int port,
+ RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf)
+ throws RemoteException
+ {
+ return (exportObject(obj, port, ssf));
+ }
+
+ public static boolean unexportObject(Remote obj, boolean force)
+ throws NoSuchObjectException
+ {
+ if (obj instanceof RemoteObject)
+ {
+ deleteStub(obj);
+ UnicastServerRef sref =
+ (UnicastServerRef) ((RemoteObject) obj).getRef();
+ return sref.unexportObject(obj, force);
+ }
+ // FIXME
+ /* else
+ {
+ ;
+ }
+ */
+ return true;
+ }
+
+}
diff --git a/libjava/classpath/java/rmi/server/Unreferenced.java b/libjava/classpath/java/rmi/server/Unreferenced.java
new file mode 100644
index 000000000..6d4df48bc
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/Unreferenced.java
@@ -0,0 +1,43 @@
+/* Unreferenced.java --
+ Copyright (c) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package java.rmi.server;
+
+public interface Unreferenced
+{
+ void unreferenced();
+}
diff --git a/libjava/classpath/java/rmi/server/package.html b/libjava/classpath/java/rmi/server/package.html
new file mode 100644
index 000000000..54055a721
--- /dev/null
+++ b/libjava/classpath/java/rmi/server/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in java.rmi.server package.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - java.rmi.server</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>