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

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -31,11 +31,12 @@
  * BindException) might seem odd and not to be expected, it has
  * historically worked with the J2SE RMI implementation, so it should
  * continue to work because existing applications might depend on it.
  * @author Peter Jones
  *
- * @build ReuseDefaultPort
+ * @library ../../testlibrary
+ * @build ReuseDefaultPort TestLibrary
  * @run main/othervm ReuseDefaultPort
  */
 
 import java.io.IOException;
 import java.net.ServerSocket;

@@ -46,11 +47,11 @@
 import java.rmi.server.RMISocketFactory;
 import java.rmi.server.UnicastRemoteObject;
 
 public class ReuseDefaultPort implements Remote {
 
-    private static final int PORT = 2223;
+    private static final int PORT = TestLibrary.getUnusedRandomPort();
 
     private ReuseDefaultPort() { }
 
     public static void main(String[] args) throws Exception {
         System.err.println("\nRegression test for bug 6269166\n");