< prev index next >

test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 6269166
  26  * @summary After a remote object has been exported on an anonymous
  27  * port, it should be possible to export another remote object on an
  28  * explicit port (and with the same socket factories, if any) with the
  29  * same value as the actual port to which the first export got bound.
  30  * While the fact that this works (instead of failing with a
  31  * BindException) might seem odd and not to be expected, it has
  32  * historically worked with the J2SE RMI implementation, so it should
  33  * continue to work because existing applications might depend on it.
  34  * @author Peter Jones
  35  *
  36  * @library ../../testlibrary




  37  * @build TestLibrary
  38  * @run main/othervm ReuseDefaultPort
  39  */
  40 
  41 import java.io.IOException;
  42 import java.net.ServerSocket;
  43 import java.net.Socket;
  44 import java.rmi.Remote;
  45 import java.rmi.registry.LocateRegistry;
  46 import java.rmi.registry.Registry;
  47 import java.rmi.server.RMISocketFactory;
  48 import java.rmi.server.UnicastRemoteObject;
  49 
  50 public class ReuseDefaultPort implements Remote {
  51 
  52     private static final int PORT = TestLibrary.getUnusedRandomPort();
  53 
  54     private ReuseDefaultPort() { }
  55 
  56     public static void main(String[] args) throws Exception {




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @bug 6269166
  26  * @summary After a remote object has been exported on an anonymous
  27  * port, it should be possible to export another remote object on an
  28  * explicit port (and with the same socket factories, if any) with the
  29  * same value as the actual port to which the first export got bound.
  30  * While the fact that this works (instead of failing with a
  31  * BindException) might seem odd and not to be expected, it has
  32  * historically worked with the J2SE RMI implementation, so it should
  33  * continue to work because existing applications might depend on it.
  34  * @author Peter Jones
  35  *
  36  * @library ../../testlibrary
  37  * @modules java.rmi/sun.rmi.registry
  38  *          java.rmi/sun.rmi.server
  39  *          java.rmi/sun.rmi.transport
  40  *          java.rmi/sun.rmi.transport.tcp
  41  * @build TestLibrary
  42  * @run main/othervm ReuseDefaultPort
  43  */
  44 
  45 import java.io.IOException;
  46 import java.net.ServerSocket;
  47 import java.net.Socket;
  48 import java.rmi.Remote;
  49 import java.rmi.registry.LocateRegistry;
  50 import java.rmi.registry.Registry;
  51 import java.rmi.server.RMISocketFactory;
  52 import java.rmi.server.UnicastRemoteObject;
  53 
  54 public class ReuseDefaultPort implements Remote {
  55 
  56     private static final int PORT = TestLibrary.getUnusedRandomPort();
  57 
  58     private ReuseDefaultPort() { }
  59 
  60     public static void main(String[] args) throws Exception {


< prev index next >