-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
hopper
-
sparc
-
solaris_2.6
-
Verified
Name: acR10002 Date: 01/21/2002
As one can see from the J2SE 1.4 spec, the Naming service in RMI requires
that:
--------- javadoc for java.rmi.Naming, J2SE 1.4 b91 -----
The Naming
class's methods take, as one of their arguments, a name that is a URL
formatted java.lang.String of the form:
//host:port/name
---------------------------------------------------------
However, in practice it becomes that both //host:port/name and
rmi://host:port/name are acceptable. Moreover, if one binds the remote
object given the name of format "//host:port/name", and then later
attempts to obtain the list of objects bound in the registry like in the
example below:
--------------- Test.java ---------
import java.rmi.*;
public class Test {
public static void main(String argv[]) {
try {
Naming.bind("//archer:5000/test", new RemoteImpl());
String[] list = Naming.list("//archer:5000");
for (int i=0; i<list.length; i++) {
System.out.println(list[i]);
}
Naming.unbind("//archer:5000/test");
} catch (Exception e) {
e.printStackTrace();
}
}
}
class RemoteImpl extends java.rmi.server.UnicastRemoteObject
implements TestRemote {
public RemoteImpl() throws RemoteException {};
}
-----------------------------------
------------ TestRemote.java ------
import java.rmi.*;
interface TestRemote extends Remote {
}
-----------------------------------
then the scheme "rmi:" is automatically appended to each remote object's
URI, so one will see an output:
------------- output from the example -----
--> java Test
rmi://archer:5000/test
-------------------------------------------
This behavior (more specifically - prefix "rmi:") is confusing and
unspecified. Either the usage of scheme "rmi:" should be documented on
the RMI spec level as well as reflected in the javadoc for Naming methods,
or shouldn't be used in RMI implementation at all.
======================================================================
- relates to
-
JDK-4624368 rmi.Naming spec misses <scheme> part of the URL
-
- Closed
-