summaryrefslogtreecommitdiff
path: root/libjava/classpath/java/rmi/server
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/rmi/server')
-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
28 files changed, 3019 insertions, 0 deletions
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>