--- old/test/ProblemList.txt 2012-07-13 13:16:41.729990549 -0700 +++ new/test/ProblemList.txt 2012-07-13 13:16:41.529987365 -0700 @@ -161,9 +161,6 @@ # 6988950 demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all -# Need to be marked othervm, or changed to be samevm safe -com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java generic-all - # 7162111 demo/jvmti/mtrace/TraceJFrame.java macosx-all javax/script/CauseExceptionTest.java macosx-all @@ -268,21 +265,11 @@ # jdk_rmi -# 7140992 -java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all - -# 6948101 -java/rmi/transport/pinLastArguments/PinLastArguments.java generic-all - # 7146541 java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java linux-all # 7132247 java/rmi/registry/readTest/readTest.sh windows-all - -# 7142596 -java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java generic-all - ############################################################################ # jdk_security --- old/test/TEST.ROOT 2012-07-13 13:16:42.422001566 -0700 +++ new/test/TEST.ROOT 2012-07-13 13:16:42.225998446 -0700 @@ -9,4 +9,4 @@ othervm.dirs=java/rmi sun/rmi javax/management # Tests that cannot run concurrently -exclusiveAccess.dirs=java/rmi sun/rmi sun/management/jmxremote sun/tools/jstatd +exclusiveAccess.dirs=java/rmi/Naming sun/management/jmxremote sun/tools/jstatd --- old/test/com/sun/jndi/rmi/registry/RegistryContext/ContextWithNullProperties.java 2012-07-13 13:16:43.110012519 -0700 +++ new/test/com/sun/jndi/rmi/registry/RegistryContext/ContextWithNullProperties.java 2012-07-13 13:16:42.914009399 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -25,26 +25,22 @@ * @test * @bug 6676075 * @summary RegistryContext (com.sun.jndi.url.rmi.rmiURLContext) coding problem + * @library ../../../../../../java/rmi/testlibrary + * @build TestLibrary + * @run main ContextWithNullProperties */ +import com.sun.jndi.rmi.registry.RegistryContextsun.jndi.rmi.RegistryContext; import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; - -import com.sun.jndi.rmi.registry.*; +import java.rmi.registry.Registry; public class ContextWithNullProperties { - public static void main(String[] args) throws Exception { - - // Create registry on port 1099 if one is not already running. - try { - LocateRegistry.createRegistry(1099); - } catch (RemoteException e) { - } - + Registry registry = TestLibrary.createRegistryOnUnusedPort(); + int registryPort = TestLibrary.getRegistryPort(registry); System.out.println("Connecting to the default Registry..."); // Connect to the default Registry. // Pass null as the JNDI environment properties (see final argument) - RegistryContext ctx = new RegistryContext(null, -1, null); + RegistryContext ctx = new RegistryContext(null, registryPort, null); } } --- old/test/com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java 2012-07-13 13:16:43.806023599 -0700 +++ new/test/com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java 2012-07-13 13:16:43.606020415 -0700 @@ -1,26 +1,51 @@ /* + * Copyright (c) 2007, 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. + * + * This code 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 + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* * @test * @bug 4278121 * @summary Ensure that calling unbind() on an unbound name returns * successfully. + * @library ../../../../../../java/rmi/testlibrary + * @build TestLibrary + * @run main UnbindIdempotent */ -import javax.naming.*; +import java.rmi.registry.Registry; +import javax.naming.InitialContext; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; public class UnbindIdempotent { public static void main(String[] args) throws Exception { - - // Create registry on port 1099 if one is not already running. - try { - java.rmi.registry.LocateRegistry.createRegistry(1099); - } catch (java.rmi.RemoteException e) { - } - - Context ictx = new InitialContext(); + Registry registry = TestLibrary.createRegistryOnUnusedPort(); + int registryPort = TestLibrary.getRegistryPort(registry); + InitialContext ictx = new InitialContext(); Context rctx; + try { - rctx = (Context)ictx.lookup("rmi://localhost:1099"); + rctx = (Context)ictx.lookup("rmi://localhost:" + Integer.toString(registryPort)); } catch (NamingException e) { // Unable to set up for test. return; --- old/test/java/rmi/Naming/LookupNameWithColon.java 2012-07-13 13:16:44.490034490 -0700 +++ new/test/java/rmi/Naming/LookupNameWithColon.java 2012-07-13 13:16:44.290031304 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -25,10 +25,13 @@ * @bug 4387038 * @summary Ensure that java.rmi.Naming.lookup functions properly for names * containing embedded ':' characters. + * + * @library ../testlibrary + * @build TestLibrary + * @run main LookupNameWithColon */ import java.rmi.Naming; -import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; public class LookupNameWithColon { @@ -38,15 +41,12 @@ "multiple:colons:in:name" }; - Registry reg; - try { - reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT); - } catch (Exception ex) { - reg = LocateRegistry.getRegistry(); - } + Registry reg = TestLibrary.createRegistryOnUnusedPort(); + int port = TestLibrary.getRegistryPort(reg); + for (int i = 0; i < names.length; i++) { reg.rebind(names[i], reg); - Naming.lookup("rmi://localhost/" + names[i]); + Naming.lookup("rmi://localhost:" + port + "/" + names[i]); } } } --- old/test/java/rmi/Naming/RmiIsNoScheme.java 2012-07-13 13:16:45.194045697 -0700 +++ new/test/java/rmi/Naming/RmiIsNoScheme.java 2012-07-13 13:16:44.990042449 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -39,9 +39,6 @@ import java.rmi.registry.*; public class RmiIsNoScheme implements Remote, Serializable { - - private static final int REGISTRY_PORT = 2002; - private RmiIsNoScheme() {} public static void main(String[] args) { @@ -49,10 +46,11 @@ System.err.println("\nRegression test for bug 4626311\n"); try { - LocateRegistry.createRegistry(REGISTRY_PORT); - Naming.rebind("//:" + REGISTRY_PORT + "/RmiIsNoScheme", + Registry registry = TestLibrary.createRegistryOnUnusedPort(); + int registryPort = TestLibrary.getRegistryPort(registry); + Naming.rebind("//:" + registryPort + "/RmiIsNoScheme", new RmiIsNoScheme()); - String name = Naming.list("//:" + REGISTRY_PORT)[0]; + String name = Naming.list("//:" + registryPort)[0]; System.err.println("name = " + name); if (name.startsWith("rmi:", 0) == false) { System.err.println("TEST PASSED: rmi scheme not present"); --- old/test/java/rmi/Naming/UnderscoreHost.java 2012-07-13 13:16:45.870056459 -0700 +++ new/test/java/rmi/Naming/UnderscoreHost.java 2012-07-13 13:16:45.666053211 -0700 @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2005, 2006, 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. - * - * This code 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 - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 5083594 - * @summary Ensure that Naming.java correctly parses host names with '_' in - * them. - * @author Vinod Johnson - * - * @library ../testlibrary - * @build TestLibrary - * @build UnderscoreHost UnderscoreHost_Stub - * @run main/othervm UnderscoreHost + /* + * 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. + * + * This code 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 + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + /* + * @test + * @bug 5083594 + * @summary Ensure that Naming.java correctly parses host names with '_' in + * them. + * @author Vinod Johnson + * + * @library ../testlibrary + * @build TestLibrary + * @build UnderscoreHost UnderscoreHost_Stub + * @run main/othervm UnderscoreHost */ import java.io.IOException; @@ -77,11 +77,12 @@ try { HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory(); RMISocketFactory.setSocketFactory(hvf); - Registry r = LocateRegistry.createRegistry(Registry.REGISTRY_PORT); + Registry r = TestLibrary.createRegistryOnUnusedPort(); + int port = TestLibrary.getRegistryPort(r); t = new UnderscoreHost(); r.rebind(NAME, t); Naming.lookup("rmi://" + HOSTNAME + - ":" + Registry.REGISTRY_PORT + "/" + NAME); + ":" + port + "/" + NAME); /* * This test is coded to pass whether java.net.URI obeys * RFC 2396 or RFC 3986 (see 5085902, 6394131, etc.). --- old/test/java/rmi/Naming/legalRegistryNames/LegalRegistryNames.java 2012-07-13 13:16:46.550067285 -0700 +++ new/test/java/rmi/Naming/legalRegistryNames/LegalRegistryNames.java 2012-07-13 13:16:46.354064164 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -45,7 +45,9 @@ /** * Ensure that all legal forms of Naming URLs operate with the - * java.rmi.Naming interface + * java.rmi.Naming interface. This test requires using the default RMI Registry + * port as it tests all of the RMI naming URL's, including the ones which do not + * take a port (and therefore uses the default port). */ public class LegalRegistryNames extends UnicastRemoteObject implements Legal --- old/test/java/rmi/activation/Activatable/checkActivateRef/security.policy 2012-07-13 13:16:47.250078429 -0700 +++ new/test/java/rmi/activation/Activatable/checkActivateRef/security.policy 2012-07-13 13:16:47.050075245 -0700 @@ -29,11 +29,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/Activatable/checkAnnotations/security.policy 2012-07-13 13:16:47.934089318 -0700 +++ new/test/java/rmi/activation/Activatable/checkAnnotations/security.policy 2012-07-13 13:16:47.734086134 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // required for test to create an ActivationGroup permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/Activatable/checkImplClassLoader/security.policy 2012-07-13 13:16:48.630100399 -0700 +++ new/test/java/rmi/activation/Activatable/checkImplClassLoader/security.policy 2012-07-13 13:16:48.426097151 -0700 @@ -32,11 +32,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // required for test to create an ActivationGroup permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/Activatable/checkRegisterInLog/security.policy 2012-07-13 13:16:49.330111543 -0700 +++ new/test/java/rmi/activation/Activatable/checkRegisterInLog/security.policy 2012-07-13 13:16:49.122108231 -0700 @@ -21,17 +21,18 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; // allow exporting of remote objects on an arbitrary port. - permission java.net.SocketPermission "*:1024-", "connect,accept"; + permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; // allow exporting object with non-public remote interface permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe"; --- old/test/java/rmi/activation/Activatable/createPrivateActivable/security.policy 2012-07-13 13:16:50.070123324 -0700 +++ new/test/java/rmi/activation/Activatable/createPrivateActivable/security.policy 2012-07-13 13:16:49.858119949 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/Activatable/downloadParameterClass/security.policy 2012-07-13 13:16:50.742134022 -0700 +++ new/test/java/rmi/activation/Activatable/downloadParameterClass/security.policy 2012-07-13 13:16:50.538130774 -0700 @@ -31,11 +31,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // allow exporting of remote objects on an arbitrary port. permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; --- old/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/security.policy 2012-07-13 13:16:51.430144975 -0700 +++ new/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/security.policy 2012-07-13 13:16:51.222141664 -0700 @@ -30,11 +30,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/Activatable/extLoadedImpl/security.policy 2012-07-13 13:16:52.130156119 -0700 +++ new/test/java/rmi/activation/Activatable/extLoadedImpl/security.policy 2012-07-13 13:16:51.918152744 -0700 @@ -17,11 +17,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // allow exporting of remote objects on an arbitrary port. permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; --- old/test/java/rmi/activation/Activatable/forceLogSnapshot/security.policy 2012-07-13 13:16:52.822167136 -0700 +++ new/test/java/rmi/activation/Activatable/forceLogSnapshot/security.policy 2012-07-13 13:16:52.618163888 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/Activatable/inactiveGroup/security.policy 2012-07-13 13:16:53.514178153 -0700 +++ new/test/java/rmi/activation/Activatable/inactiveGroup/security.policy 2012-07-13 13:16:53.314174969 -0700 @@ -21,17 +21,18 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; // allow exporting of remote objects on an arbitrary port. - permission java.net.SocketPermission "*:1024-", "connect,accept"; + permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; // allow exporting object with non-public remote interface permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe"; --- old/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java 2012-07-13 13:16:54.238189679 -0700 +++ new/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java 2012-07-13 13:16:54.018186177 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 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 @@ -58,7 +58,7 @@ System.err.println("look up activation system"); Registry rmidRegistry = - LocateRegistry.getRegistry(ActivationSystem.SYSTEM_PORT); + LocateRegistry.getRegistry(rmid.getPort()); ActivationSystem system = (ActivationSystem) rmidRegistry.lookup(NAME); --- old/test/java/rmi/activation/Activatable/nestedActivate/security.policy 2012-07-13 13:16:54.918200505 -0700 +++ new/test/java/rmi/activation/Activatable/nestedActivate/security.policy 2012-07-13 13:16:54.718197321 -0700 @@ -21,17 +21,18 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; // allow exporting of remote objects on an arbitrary port. - permission java.net.SocketPermission "*:1024-", "connect,accept"; + permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; // allow exporting of non-public remote interface permission java.rmi.RMIPermission "exportRemoteInterface.ActivateMe"; --- old/test/java/rmi/activation/Activatable/nonExistentActivatable/security.policy 2012-07-13 13:16:55.602211394 -0700 +++ new/test/java/rmi/activation/Activatable/nonExistentActivatable/security.policy 2012-07-13 13:16:55.406208274 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/Activatable/restartCrashedService/security.policy 2012-07-13 13:16:56.310222666 -0700 +++ new/test/java/rmi/activation/Activatable/restartCrashedService/security.policy 2012-07-13 13:16:56.094219227 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/Activatable/restartLatecomer/security.policy 2012-07-13 13:16:56.986233428 -0700 +++ new/test/java/rmi/activation/Activatable/restartLatecomer/security.policy 2012-07-13 13:16:56.778230117 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Used in remote impl of Activator.inactive; by the method // "restartThread.dispose()"when it calls thread.interrupt() --- old/test/java/rmi/activation/Activatable/restartService/security.policy 2012-07-13 13:16:57.686244572 -0700 +++ new/test/java/rmi/activation/Activatable/restartService/security.policy 2012-07-13 13:16:57.478241261 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Used in remote impl of Activator.inactive; by the method // "restartThread.dispose()"when it calls thread.interrupt() --- old/test/java/rmi/activation/Activatable/shutdownGracefully/security.policy 2012-07-13 13:16:58.362255334 -0700 +++ new/test/java/rmi/activation/Activatable/shutdownGracefully/security.policy 2012-07-13 13:16:58.166252214 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // allow exporting of remote objects on an arbitrary port. permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; --- old/test/java/rmi/activation/Activatable/unregisterInactive/security.policy 2012-07-13 13:16:59.046266224 -0700 +++ new/test/java/rmi/activation/Activatable/unregisterInactive/security.policy 2012-07-13 13:16:58.846263040 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // Needed to create an activation group permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/ActivateFailedException/activateFails/security.policy 2012-07-13 13:16:59.738277240 -0700 +++ new/test/java/rmi/activation/ActivateFailedException/activateFails/security.policy 2012-07-13 13:16:59.542274120 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // required for test to create an ActivationGroup permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/ActivationSystem/activeGroup/security.policy 2012-07-13 13:17:00.438288385 -0700 +++ new/test/java/rmi/activation/ActivationSystem/activeGroup/security.policy 2012-07-13 13:17:00.230285073 -0700 @@ -15,11 +15,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // test needs to export rmid and communicate with objects on arbitrary ports permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; --- old/test/java/rmi/activation/ActivationSystem/modifyDescriptor/security.policy 2012-07-13 13:17:01.122299274 -0700 +++ new/test/java/rmi/activation/ActivationSystem/modifyDescriptor/security.policy 2012-07-13 13:17:00.922296090 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // required for test to create an ActivationGroup permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java 2012-07-13 13:17:01.810310227 -0700 +++ new/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java 2012-07-13 13:17:01.606306979 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -61,7 +61,7 @@ extends Activatable implements Runnable, CanCreateStubs { public static boolean sameGroup = false; - + private static int registryPort = -1; private static CanCreateStubs canCreateStubs = null; private static Registry registry = null; @@ -76,8 +76,8 @@ try { TestLibrary.suggestSecurityManager("java.lang.SecurityManager"); - registry = java.rmi.registry.LocateRegistry. - createRegistry(TestLibrary.REGISTRY_PORT); + registry = TestLibrary.createRegistryOnUnusedPort(); + registryPort = TestLibrary.getRegistryPort(registry); // must run with java.lang.SecurityManager or the test // result will be nullified if running with a build where @@ -192,7 +192,7 @@ // obtain reference to the test registry registry = java.rmi.registry.LocateRegistry. - getRegistry(TestLibrary.REGISTRY_PORT); + getRegistry(registryPort); } /** --- old/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/security.policy 2012-07-13 13:17:02.510321371 -0700 +++ new/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/security.policy 2012-07-13 13:17:02.306318124 -0700 @@ -21,15 +21,22 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // required for test to create an ActivationGroup permission java.lang.RuntimePermission "setFactory"; + // required for test to get the registry port + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp"; + // test needs to export rmid and communicate with objects on arbitrary ports permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; }; --- old/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java 2012-07-13 13:17:03.182332070 -0700 +++ new/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java 2012-07-13 13:17:02.982328886 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -74,7 +74,7 @@ private static boolean done = false; private static ActivateMe lastResortExitObj = null; private static final int NUM_OBJECTS = 10; - private static int PORT = 2006; + private static int registryPort = -1; public UnregisterGroup(ActivationID id, MarshalledObject mobj) throws Exception @@ -116,7 +116,7 @@ try { CallbackInterface cobj = - (CallbackInterface)Naming.lookup("//:" + PORT + "/Callback"); + (CallbackInterface)Naming.lookup("//:" + registryPort + "/Callback"); cobj.inc(); } catch (Exception e) { System.err.println("cobj.inc exception"); @@ -235,7 +235,8 @@ try { // create reg and export callback object - registry = LocateRegistry.createRegistry(PORT); + registry = TestLibrary.createRegistryOnUnusedPort(); + registryPort = TestLibrary.getRegistryPort(registry); Callback robj = new Callback(); registry.bind("Callback", robj); --- old/test/java/rmi/activation/ActivationSystem/unregisterGroup/security.policy 2012-07-13 13:17:03.870343023 -0700 +++ new/test/java/rmi/activation/ActivationSystem/unregisterGroup/security.policy 2012-07-13 13:17:03.666339775 -0700 @@ -21,11 +21,12 @@ permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; - // used by TestLibrary to determine test environment + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.classes", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // required for test to create an ActivationGroup permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java 2012-07-13 13:17:04.458352384 -0700 +++ new/test/java/rmi/activation/CommandEnvironment/SetChildEnv.java 2012-07-13 13:17:04.246349009 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -53,31 +53,37 @@ public static void main(String argv[]) throws Exception { + int runningPort = TestLibrary.getUnusedRandomPort(); + System.out.println("java.compiler=" + System.getProperty("java.compiler")); // don't embed spaces in any of the test args/props, because // they won't be parsed properly - runwith (new String[0], new String[0]); + runwith (new String[0], new String[0], runningPort); runwith ( new String[] { "-verbosegc" }, new String[] { "foo.bar=SetChildEnvTest", - "sun.rmi.server.doSomething=true" } + "sun.rmi.server.doSomething=true" }, + runningPort ); runwith ( new String[] { }, - new String[] { "parameter.count=zero" } + new String[] { "parameter.count=zero" }, + runningPort ); runwith ( new String[] { "-Xmx32m" }, - new String[] { } + new String[] { }, + runningPort ); } private static void runwith( String[] params, // extra args - String[] props // extra system properties + String[] props, // extra system properties + int port // port on which to communicate ) throws Exception { @@ -89,7 +95,8 @@ RMID.removeLog(); RMID rmid = RMID.createRMID(watcher.otherEnd(), watcher.otherEnd(), - true); // debugExec turned on + true, // debugExec turned on + true, port); rmid.start(); @@ -195,7 +202,7 @@ actsys.unregisterGroup(gid); Thread.sleep(5000); - rmid.destroy(); + ActivationLibrary.rmidCleanup(rmid); } public static class DebugExecWatcher @@ -243,7 +250,19 @@ System.err.println(line); } } catch (IOException e) { - e.printStackTrace(); + /* During termination of distant rmid, StreamPipes will be broken when + * distant vm terminates. A "Pipe broken" exception is expected because + * DebugExecWatcher points to the same streams as StreamPipes used by RMID. + * If we get this exception. We just terminate the thread. + */ + if (e.getMessage().equals("Pipe broken")) { + try { + str.close(); + } catch (IOException ioe) {} + } + else { + e.printStackTrace(); + } } } } --- old/test/java/rmi/activation/CommandEnvironment/security.policy 2012-07-13 13:17:04.914359643 -0700 +++ new/test/java/rmi/activation/CommandEnvironment/security.policy 2012-07-13 13:17:04.706356332 -0700 @@ -27,6 +27,7 @@ permission java.util.PropertyPermission "test.src", "read"; permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; // required for test to create an ActivationGroup permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java 2012-07-13 13:17:05.482368686 -0700 +++ new/test/java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java 2012-07-13 13:17:05.274365375 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 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 @@ -31,8 +31,7 @@ * @library ../../testlibrary * @build RMID ActivationLibrary * @build InheritedChannelNotServerSocket - * @run main/othervm/timeout=240 -Djava.rmi.activation.port=5398 - * InheritedChannelNotServerSocket + * @run main/othervm/timeout=240 InheritedChannelNotServerSocket */ import java.io.IOException; @@ -55,8 +54,6 @@ import java.rmi.server.UnicastRemoteObject; public class InheritedChannelNotServerSocket { - - private static final int PORT = 5398; private static final Object lock = new Object(); private static boolean notified = false; @@ -79,7 +76,8 @@ public static void main(String[] args) throws Exception { System.err.println("\nRegression test for bug 6261402\n"); - + System.setProperty("java.rmi.activation.port", + Integer.toString(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT)); RMID rmid = null; Callback obj = null; try { @@ -91,7 +89,8 @@ Callback proxy = (Callback) UnicastRemoteObject.exportObject(obj, 0); Registry registry = - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + LocateRegistry.createRegistry( + TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT); registry.bind("Callback", proxy); /* @@ -99,7 +98,8 @@ */ System.err.println("start rmid with inherited channel"); RMID.removeLog(); - rmid = RMID.createRMID(System.out, System.err, true, true, PORT); + rmid = RMID.createRMID(System.out, System.err, true, true, + TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT); rmid.addOptions(new String[]{ "-Djava.nio.channels.spi.SelectorProvider=" + "InheritedChannelNotServerSocket$SP"}); @@ -122,7 +122,7 @@ if (obj != null) { UnicastRemoteObject.unexportObject(obj, true); } - ActivationLibrary.rmidCleanup(rmid, PORT); + ActivationLibrary.rmidCleanup(rmid); } } @@ -175,7 +175,7 @@ try { System.err.println("notify test..."); Registry registry = - LocateRegistry.getRegistry(TestLibrary.REGISTRY_PORT); + LocateRegistry.getRegistry(TestLibrary.INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { --- old/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java 2012-07-13 13:17:06.174379703 -0700 +++ new/test/java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java 2012-07-13 13:17:05.966376392 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -29,7 +29,8 @@ * @library ../../testlibrary * @build RMID ActivationLibrary * @build RmidViaInheritedChannel - * @run main/othervm/timeout=240 -Djava.rmi.activation.port=5398 RmidViaInheritedChannel + * @build TestLibrary + * @run main/othervm/timeout=240 RmidViaInheritedChannel */ import java.io.IOException; @@ -48,8 +49,6 @@ import java.rmi.server.UnicastRemoteObject; public class RmidViaInheritedChannel implements Callback { - - private static final int PORT = 5398; private static final Object lock = new Object(); private static boolean notified = false; @@ -64,7 +63,8 @@ } public static void main(String[] args) throws Exception { - + System.setProperty("java.rmi.activation.port", + Integer.toString(TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT)); RMID rmid = null; Callback obj = null; @@ -77,7 +77,8 @@ Callback proxy = (Callback) UnicastRemoteObject.exportObject(obj, 0); Registry registry = - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + LocateRegistry.createRegistry( + TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT); registry.bind("Callback", proxy); /* @@ -85,7 +86,8 @@ */ System.err.println("start rmid with inherited channel"); RMID.removeLog(); - rmid = RMID.createRMID(System.out, System.err, true, false, PORT); + rmid = RMID.createRMID(System.out, System.err, true, false, + TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT); rmid.addOptions(new String[]{ "-Djava.nio.channels.spi.SelectorProvider=RmidViaInheritedChannel$RmidSelectorProvider"}); rmid.start(); @@ -108,7 +110,7 @@ if (obj != null) { UnicastRemoteObject.unexportObject(obj, true); } - ActivationLibrary.rmidCleanup(rmid, PORT); + ActivationLibrary.rmidCleanup(rmid); } } @@ -166,7 +168,8 @@ channel = ServerSocketChannel.open(); ServerSocket serverSocket = channel.socket(); serverSocket.bind( - new InetSocketAddress(InetAddress.getLocalHost(), PORT)); + new InetSocketAddress(InetAddress.getLocalHost(), + TestLibrary.RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT)); System.err.println("serverSocket = " + serverSocket); /* @@ -175,7 +178,7 @@ try { System.err.println("notify test..."); Registry registry = - LocateRegistry.getRegistry(TestLibrary.REGISTRY_PORT); + LocateRegistry.getRegistry(TestLibrary.RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT); Callback obj = (Callback) registry.lookup("Callback"); obj.notifyTest(); } catch (NotBoundException nbe) { --- old/test/java/rmi/activation/rmidViaInheritedChannel/rmid.security.policy 2012-07-13 13:17:06.874390847 -0700 +++ new/test/java/rmi/activation/rmidViaInheritedChannel/rmid.security.policy 2012-07-13 13:17:06.670387599 -0700 @@ -2,4 +2,5 @@ permission java.lang.RuntimePermission "selectorProvider"; permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch"; permission java.net.SocketPermission "*", "connect,accept"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; }; --- old/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java 2012-07-13 13:17:07.566401864 -0700 +++ new/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java 2012-07-13 13:17:07.366398680 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -27,7 +27,7 @@ * @author Laird Dornin * * @library ../../testlibrary - * @build StreamPipe TestParams TestLibrary JavaVM + * @build StreamPipe TestParams TestLibrary JavaVM RMID * @build AltSecurityManager TestSecurityManager * @run main/othervm AltSecurityManager */ @@ -41,23 +41,41 @@ * if registry and rmid take too long to exit. */ public class AltSecurityManager implements Runnable { - + private final int regPort; // variable to hold registry and rmid children static JavaVM vm = null; // names of utilities static String utilityToStart = null; - static String registry = "sun.rmi.registry.RegistryImpl"; - static String rmid = "sun.rmi.server.Activation"; + static final String REGISTRY_IMPL = "sun.rmi.registry.RegistryImpl"; + static final String ACTIVATION = "sun.rmi.server.Activation"; // children should exit in at least this time. static long TIME_OUT = 15000; + public AltSecurityManager(int port) { + if (port <= 0) { + TestLibrary.bomb("Port must be greater then 0."); + } + + this.regPort = port; + } + public void run() { try { - vm = new JavaVM(utilityToStart, - " -Djava.security.manager=TestSecurityManager", - ""); + if (utilityToStart.equals(REGISTRY_IMPL)) { + vm = new JavaVM(utilityToStart, + " -Djava.security.manager=TestSecurityManager", + Integer.toString(regPort)); + } else if (utilityToStart.contains(ACTIVATION)) { + vm = new JavaVM(utilityToStart, + " -Djava.security.manager=TestSecurityManager", + "-port " + Integer.toString(regPort)); + } else { + TestLibrary.bomb("Utility to start must be " + REGISTRY_IMPL + + " or " + ACTIVATION); + } + System.err.println("starting " + utilityToStart); vm.start(); vm.getVM().waitFor(); @@ -75,7 +93,8 @@ utilityToStart = utility; try { - Thread thread = new Thread(new AltSecurityManager()); + int port = TestLibrary.getUnusedRandomPort(); + Thread thread = new Thread(new AltSecurityManager(port)); System.err.println("expecting RuntimeException for " + "checkListen in child process"); long start = System.currentTimeMillis(); @@ -90,8 +109,8 @@ // dont pollute other tests; increase the likelihood // that rmid will go away if it did not exit already. - if (utility.equals(rmid)) { - RMID.shutdown(); + if (utility.equals(ACTIVATION)) { + RMID.shutdown(port); } TestLibrary.bomb(utilityToStart + @@ -111,10 +130,10 @@ System.err.println("\nRegression test for bug 4183202\n"); // make sure the registry exits early. - ensureExit(registry); + ensureExit(REGISTRY_IMPL); // make sure rmid exits early - ensureExit(rmid); + ensureExit(ACTIVATION); System.err.println("test passed"); --- old/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java 2012-07-13 13:17:08.254412817 -0700 +++ new/test/java/rmi/registry/classPathCodebase/ClassPathCodebase.java 2012-07-13 13:17:08.050409569 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -30,7 +30,7 @@ * @author Peter Jones * * @library ../../testlibrary - * @build ClassPathCodebase Dummy + * @build ClassPathCodebase Dummy TestLibrary * @run main/othervm/policy=security.policy ClassPathCodebase */ @@ -83,11 +83,12 @@ System.getProperty("java.home") + File.separator + "bin" + File.separator + "rmiregistry"; + int port = TestLibrary.getUnusedRandomPort(); String cmdarray[] = new String[] { rmiregistryCommand, "-J-Denv.class.path=.", "-J-Djava.rmi.server.codebase=" + exportCodebaseURL, - Integer.toString(TestLibrary.REGISTRY_PORT) }; + Integer.toString(port) }; System.err.println("\nCommand used to spawn rmiregistry process:"); System.err.println("\t" + Arrays.asList(cmdarray).toString()); @@ -118,7 +119,7 @@ * dummy object to it. */ Registry registry = LocateRegistry.getRegistry( - "localhost", TestLibrary.REGISTRY_PORT); + "localhost", port); try { registry.bind(dummyBinding, dummyObject); @@ -133,7 +134,7 @@ { System.err.println( "Error: another registry running on port " + - TestLibrary.REGISTRY_PORT + "?"); + port + "?"); } throw e; } --- old/test/java/rmi/registry/emptyName/EmptyName.java 2012-07-13 13:17:08.970424216 -0700 +++ new/test/java/rmi/registry/emptyName/EmptyName.java 2012-07-13 13:17:08.762420904 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -24,6 +24,8 @@ /* @test * @bug 4399304 * @summary check that registry allows empty names + * @library ../../testlibrary + * @build TestLibrary * @run main/othervm EmptyName */ import java.rmi.registry.LocateRegistry; @@ -32,7 +34,7 @@ public class EmptyName { public static void main(String[] args) throws Exception { - Registry impl = LocateRegistry.createRegistry(0); + Registry impl = TestLibrary.createRegistryOnUnusedPort(); Registry stub = (Registry) RemoteObject.toStub(impl); stub.bind("", stub); stub.lookup(""); --- old/test/java/rmi/registry/interfaceHash/InterfaceHash.java 2012-07-13 13:17:09.650435042 -0700 +++ new/test/java/rmi/registry/interfaceHash/InterfaceHash.java 2012-07-13 13:17:09.450431858 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -35,8 +35,10 @@ * "interface hash": 4905912898345647071L. * * @author Peter Jones + * @library ../../testlibrary * @build InterfaceHash * @build ReferenceRegistryStub + * @build TestLibrary * @run main/othervm InterfaceHash */ @@ -58,7 +60,7 @@ public class InterfaceHash { - private static final int PORT = 2020; + private static final int PORT = TestLibrary.getUnusedRandomPort(); private static final String NAME = "WMM"; public static void main(String[] args) throws Exception { --- old/test/java/rmi/registry/multipleRegistries/MultipleRegistries.java 2012-07-13 13:17:10.354446249 -0700 +++ new/test/java/rmi/registry/multipleRegistries/MultipleRegistries.java 2012-07-13 13:17:10.154443065 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -26,6 +26,8 @@ * @summary Can't run multiple registries in the same VM * @author Ann Wollrath * + * @library ../../testlibrary + * @build TestLibrary * @build MultipleRegistries * @run main/othervm/timeout=240 MultipleRegistries */ @@ -58,12 +60,13 @@ System.err.println("proxy = " + proxy); System.err.println("export registries"); - Registry registryImpl1 = LocateRegistry.createRegistry(2030); - Registry registryImpl2 = LocateRegistry.createRegistry(2040); - + Registry registryImpl1 = TestLibrary.createRegistryOnUnusedPort(); + int port1 = TestLibrary.getRegistryPort(registryImpl1); + Registry registryImpl2 = TestLibrary.createRegistryOnUnusedPort(); + int port2 = TestLibrary.getRegistryPort(registryImpl2); System.err.println("bind remote object in registries"); - Registry registry1 = LocateRegistry.getRegistry(2030); - Registry registry2 = LocateRegistry.getRegistry(2040); + Registry registry1 = LocateRegistry.getRegistry(port1); + Registry registry2 = LocateRegistry.getRegistry(port2); registry1.bind(NAME, proxy); registry2.bind(NAME, proxy); --- old/test/java/rmi/registry/readTest/readTest.java 2012-07-13 13:17:11.062457521 -0700 +++ new/test/java/rmi/registry/readTest/readTest.java 2012-07-13 13:17:10.862454337 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -29,18 +29,19 @@ public class readTest { public static void main(String args[]) throws Exception { - int port = 7491; try { testPkg.Server obj = new testPkg.Server(); testPkg.Hello stub = (testPkg.Hello) UnicastRemoteObject.exportObject(obj, 0); // Bind the remote object's stub in the registry - Registry registry = LocateRegistry.getRegistry(port); + Registry registry = + LocateRegistry.getRegistry(TestLibrary.READTEST_REGISTRY_PORT); registry.bind("Hello", stub); System.err.println("Server ready"); // now, let's test client - testPkg.Client client = new testPkg.Client(port); + testPkg.Client client = + new testPkg.Client(TestLibrary.READTEST_REGISTRY_PORT); String testStubReturn = client.testStub(); if(!testStubReturn.equals(obj.hello)) { throw new RuntimeException("Test Fails : unexpected string from stub call"); --- old/test/java/rmi/registry/readTest/readTest.sh 2012-07-13 13:17:11.778468920 -0700 +++ new/test/java/rmi/registry/readTest/readTest.sh 2012-07-13 13:17:11.574465672 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 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 @@ -23,6 +23,8 @@ # @test # @bug 7102369 7094468 7100592 +# @library ../../testlibrary +# @build TestLibrary # @summary remove java.rmi.server.codebase property parsing from registyimpl # @run shell readTest.sh @@ -44,22 +46,24 @@ ;; esac +TEST_CLASSPATH=.:$TESTCLASSES cp -r ${TESTSRC}${FS}* . ${TESTJAVA}${FS}bin${FS}javac testPkg${FS}*java -${TESTJAVA}${FS}bin${FS}javac readTest.java +${TESTJAVA}${FS}bin${FS}javac -cp $TEST_CLASSPATH readTest.java mkdir rmi_tmp RMIREG_OUT=rmi.out #start rmiregistry without any local classes on classpath cd rmi_tmp -${TESTJAVA}${FS}bin${FS}rmiregistry 7491 > ..${FS}${RMIREG_OUT} 2>&1 & +# NOTE: This RMI Registry port must match TestLibrary.READTEST_REGISTRY_PORT +${TESTJAVA}${FS}bin${FS}rmiregistry 64005 > ..${FS}${RMIREG_OUT} 2>&1 & RMIREG_PID=$! # allow some time to start sleep 3 cd .. # trailing / after code base is important for rmi codebase property. -${TESTJAVA}${FS}bin${FS}java -Djava.rmi.server.codebase=${FILEURL}`pwd`/ readTest > OUT.TXT 2>&1 & +${TESTJAVA}${FS}bin${FS}java -cp $TEST_CLASSPATH -Djava.rmi.server.codebase=${FILEURL}`pwd`/ readTest > OUT.TXT 2>&1 & TEST_PID=$! #bulk of testcase - let it run for a while sleep 5 --- old/test/java/rmi/registry/reexport/Reexport.java 2012-07-13 13:17:12.458479746 -0700 +++ new/test/java/rmi/registry/reexport/Reexport.java 2012-07-13 13:17:12.250476434 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -49,22 +49,21 @@ import java.rmi.server.*; public class Reexport { - static public final int regport = TestLibrary.REGISTRY_PORT; - static public void main(String[] argv) { Registry reg = null; + int regPort = TestLibrary.getUnusedRandomPort(); try { System.err.println("\nregression test for 4120329\n"); // establish the registry (we hope) - System.err.println("Starting registry on port " + regport); - Reexport.makeRegistry(regport); + System.err.println("Starting registry on port " + regPort); + Reexport.makeRegistry(regPort); // Get a handle to the registry System.err.println("Creating duplicate registry, this should fail..."); - reg = createReg(true); + reg = createReg(true, regPort); if (reg != null) { TestLibrary.bomb("failed was able to duplicate the registry?!?"); @@ -73,7 +72,7 @@ // Kill the first registry. System.err.println("Bringing down the first registry"); try { - Reexport.killRegistry(); + Reexport.killRegistry(regPort); } catch (Exception foo) { } @@ -81,7 +80,7 @@ System.err.println("Trying again to start our own " + "registry... this should work"); - reg = createReg(false); + reg = createReg(false, regPort); if (reg == null) { TestLibrary.bomb("Could not create registry on second try"); @@ -93,17 +92,17 @@ TestLibrary.bomb(e); } finally { // dont leave the registry around to affect other tests. - killRegistry(); + killRegistry(regPort); reg = null; } } - static Registry createReg(boolean remoteOk) { + static Registry createReg(boolean remoteOk, int port) { Registry reg = null; try { - reg = LocateRegistry.createRegistry(regport); + reg = LocateRegistry.createRegistry(port); } catch (Throwable e) { if (remoteOk) { System.err.println("EXPECTING PORT IN USE EXCEPTION:"); @@ -140,10 +139,10 @@ } private static Process subreg = null; - public static void killRegistry() { + public static void killRegistry(int port) { if (Reexport.subreg != null) { - RegistryRunner.requestExit(); + RegistryRunner.requestExit(port); try { Reexport.subreg.waitFor(); --- old/test/java/rmi/reliability/juicer/AppleUserImpl.java 2012-07-13 13:17:13.174491144 -0700 +++ new/test/java/rmi/reliability/juicer/AppleUserImpl.java 2012-07-13 13:17:12.974487960 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -59,19 +59,21 @@ * @build Apple AppleEvent AppleImpl AppleUserImpl * @build Orange OrangeEcho OrangeEchoImpl OrangeImpl * @build ApplicationServer + * @build TestLibrary * * @run main/othervm/policy=security.policy AppleUserImpl -seconds 30 * * @author Peter Jones, Nigel Daley */ -import java.rmi.RemoteException; import java.rmi.NoSuchObjectException; -import java.rmi.server.UnicastRemoteObject; +import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.UnicastRemoteObject; import java.util.Random; -import java.util.logging.Logger; import java.util.logging.Level; +import java.util.logging.Logger; /** * The AppleUserImpl class implements the behavior of the remote @@ -80,7 +82,7 @@ * AppleUserThread is created for each apple. */ public class AppleUserImpl extends UnicastRemoteObject implements AppleUser { - + private static int registryPort = -1; private static final Logger logger = Logger.getLogger("reliability.appleuser"); private static int threadNum = 0; @@ -308,8 +310,10 @@ synchronized (user) { // create new registry and bind new AppleUserImpl in registry - LocateRegistry.createRegistry(2006); - LocateRegistry.getRegistry(2006).rebind("AppleUser",user); + Registry registry = TestLibrary.createRegistryOnUnusedPort(); + registryPort = TestLibrary.getRegistryPort(registry); + LocateRegistry.getRegistry(registryPort).rebind("AppleUser", + user); // start the other server if applicable if (othervm) { @@ -318,7 +322,9 @@ "started in separate process"); } else { Class app = Class.forName("ApplicationServer"); - server = new Thread((Runnable) app.newInstance()); + java.lang.reflect.Constructor appConstructor = + app.getDeclaredConstructor(new Class[] {Integer.TYPE}); + server = new Thread((Runnable) appConstructor.newInstance(registryPort)); logger.log(Level.INFO, "Starting application server " + "in same process"); server.start(); --- old/test/java/rmi/reliability/juicer/ApplicationServer.java 2012-07-13 13:17:13.906502798 -0700 +++ new/test/java/rmi/reliability/juicer/ApplicationServer.java 2012-07-13 13:17:13.694499423 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -38,18 +38,21 @@ private static final int LOOKUP_ATTEMPTS = 5; private static final int DEFAULT_NUMAPPLES = 10; private static final String DEFAULT_REGISTRYHOST = "localhost"; + private static final int DEFAULT_REGISTRYPORT = -1; private final int numApples; private final String registryHost; + private final int registryPort; private final Apple[] apples; private AppleUser user; - ApplicationServer() { - this(DEFAULT_NUMAPPLES, DEFAULT_REGISTRYHOST); + ApplicationServer(int registryPort) { + this(DEFAULT_NUMAPPLES, DEFAULT_REGISTRYHOST, registryPort); } - ApplicationServer(int numApples, String registryHost) { + ApplicationServer(int numApples, String registryHost, int registryPort) { this.numApples = numApples; this.registryHost = registryHost; + this.registryPort = registryPort; apples = new Apple[numApples]; } @@ -71,7 +74,7 @@ for (i = 0; i < LOOKUP_ATTEMPTS; i++) { try { Registry registry = LocateRegistry.getRegistry( - registryHost, 2006); + registryHost, registryPort); user = (AppleUser) registry.lookup("AppleUser"); user.startTest(); break; //successfully obtained AppleUser @@ -120,16 +123,20 @@ private static void usage() { System.err.println("Usage: ApplicationServer [-numApples ]"); System.err.println(" [-registryHost ]"); + System.err.println(" -registryPort "); System.err.println(" numApples The number of apples (threads) to use."); System.err.println(" The default is 10 apples."); System.err.println(" host The host running rmiregistry " + "which contains AppleUser."); System.err.println(" The default is \"localhost\"."); + System.err.println(" port The port the rmiregistry is running" + + "on."); System.err.println(); } public static void main(String[] args) { int num = DEFAULT_NUMAPPLES; + int port = -1; String host = DEFAULT_REGISTRYHOST; // parse command line args @@ -142,17 +149,25 @@ } else if (arg.equals("-registryHost")) { i++; host = args[i]; + } else if (arg.equals("-registryPort")) { + i++; + port = Integer.parseInt(args[i]); } else { usage(); } } + + if (port == -1) { + usage(); + throw new RuntimeException("Port must be specified."); + } } catch (Throwable t) { usage(); throw new RuntimeException("TEST FAILED: Bad argument"); } // start the client server - Thread server = new Thread(new ApplicationServer(num,host)); + Thread server = new Thread(new ApplicationServer(num,host,port)); server.start(); // main should exit once all exported remote objects are gc'd } --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl.java 2012-07-13 13:17:14.586513624 -0700 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/EchoImpl.java 2012-07-13 13:17:14.390510503 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -128,8 +128,9 @@ ActivationGroup.createGroup(groupID, groupDesc, 0); EchoImpl impl = new EchoImpl(protocol); - System.out.println("EchoServer: binding in registry"); - Naming.rebind("//:" + UseCustomSocketFactory.REGISTRY_PORT + + int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); + System.out.println("EchoServer: binding in registry on port:" + registryPort); + Naming.rebind("//:" + registryPort + "/EchoServer", impl); System.out.println("EchoServer ready."); } catch (Exception e) { --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java 2012-07-13 13:17:15.282524704 -0700 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java 2012-07-13 13:17:15.074521393 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -32,6 +32,7 @@ * @build EchoImpl * @build EchoImpl_Stub * @build UseCustomSocketFactory + * @build TestLibrary * @run main/othervm/policy=security.policy/timeout=360 UseCustomSocketFactory */ @@ -42,8 +43,8 @@ import java.rmi.registry.*; public class UseCustomSocketFactory { + static final int REGISTRY_PORT = TestLibrary.getUnusedRandomPort(); - final static int REGISTRY_PORT = 2006; static String[] protocol = new String[] { "", "compress", "xor" }; public static void main(String[] args) { @@ -68,7 +69,7 @@ " -C-Djava.security.manager=java.rmi.RMISecurityManager "}); rmid.start(); - Echo[] echo = spawnAndTest(); + Echo[] echo = spawnAndTest(rmid.getPort()); reactivateAndTest(echo); } catch (IOException e) { TestLibrary.bomb("creating rmid", e); @@ -78,17 +79,20 @@ } } - private static Echo[] spawnAndTest() { + private static Echo[] spawnAndTest(int rmidPort) { System.err.println("\nCreate Test-->"); Echo[] echo = new Echo[protocol.length]; for (int i = 0; i < protocol.length; i++) { - JavaVM serverVM = new JavaVM("EchoImpl", "-Djava.security.policy=" + - TestParams.defaultPolicy, + TestParams.defaultPolicy + + " -Drmi.registry.port=" + + REGISTRY_PORT + + " -Djava.rmi.activation.port=" + + rmidPort, protocol[i]); System.err.println("\nusing protocol: " + --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/security.policy 2012-07-13 13:17:15.978535785 -0700 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/security.policy 2012-07-13 13:17:15.770532473 -0700 @@ -30,6 +30,9 @@ permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "rmi.registry.port", "read"; + permission java.util.PropertyPermission "java.rmi.activation.port", "write"; + // required for test to create an ActivationGroup permission java.lang.RuntimePermission "setFactory"; --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl.java 2012-07-13 13:17:16.666546738 -0700 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/HelloImpl.java 2012-07-13 13:17:16.462543490 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -65,8 +65,9 @@ if (args.length >= 1) protocol = args[0]; + int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); registry = java.rmi.registry.LocateRegistry. - getRegistry("localhost", TestLibrary.REGISTRY_PORT, + getRegistry("localhost", registryPort, new Compress.CompressRMIClientSocketFactory()); UseCustomSocketFactory.checkStub(registry, "RMIClientSocket"); hello = (Hello) registry.lookup("/HelloServer"); --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java 2012-07-13 13:17:17.370557946 -0700 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java 2012-07-13 13:17:17.166554698 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -32,6 +32,7 @@ * @build Hello * @build HelloImpl * @build HelloImpl_Stub + * @build TestLibrary * @build UseCustomSocketFactory * @build Compress * @run main/othervm/policy=security.policy/timeout=240 UseCustomSocketFactory @@ -58,6 +59,7 @@ System.out.println("\nRegression test for bug 4148850\n"); TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); + int registryPort = TestLibrary.getUnusedRandomPort(); try { impl = new HelloImpl(); @@ -67,7 +69,7 @@ * allow the rmiregistry to be secure. */ registry = LocateRegistry. - createRegistry(TestLibrary.REGISTRY_PORT, + createRegistry(registryPort, new Compress.CompressRMIClientSocketFactory(), new Compress.CompressRMIServerSocketFactory()); registry.rebind("/HelloServer", impl); @@ -77,8 +79,12 @@ TestLibrary.bomb("creating registry", e); } - JavaVM serverVM = new JavaVM("HelloImpl", "-Djava.security.policy=" + - TestParams.defaultPolicy, ""); + JavaVM serverVM = new JavaVM("HelloImpl", + "-Djava.security.policy=" + + TestParams.defaultPolicy + + " -Drmi.registry.port=" + + registryPort, + ""); try { --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/security.policy 2012-07-13 13:17:18.058568899 -0700 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/security.policy 2012-07-13 13:17:17.854565651 -0700 @@ -22,6 +22,8 @@ permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "rmi.registry.port", "read"; + permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl.java 2012-07-13 13:17:18.750579916 -0700 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/EchoImpl.java 2012-07-13 13:17:18.554576795 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -64,8 +64,9 @@ System.out.println("EchoServer: creating remote object"); EchoImpl impl = new EchoImpl(protocol); + int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); System.out.println("EchoServer: binding in registry"); - Naming.rebind("//:" + TestLibrary.REGISTRY_PORT + + Naming.rebind("//:" + registryPort + "/EchoServer", impl); System.out.println("EchoServer ready."); } catch (Exception e) { --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java 2012-07-13 13:17:19.426590678 -0700 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java 2012-07-13 13:17:19.222587430 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -46,6 +46,8 @@ public static void main(String[] args) { + int registryPort = -1; + String[] protocol = new String[] { "", "compress", "xor" }; System.out.println("\nRegression test for bug 4127826\n"); @@ -53,7 +55,8 @@ TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); try { - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + Registry registry = TestLibrary.createRegistryOnUnusedPort(); + registryPort = TestLibrary.getRegistryPort(registry); } catch (Exception e) { TestLibrary.bomb("creating registry", e); } @@ -65,7 +68,9 @@ JavaVM serverVM = new JavaVM("EchoImpl", "-Djava.security.policy=" + - TestParams.defaultPolicy, + TestParams.defaultPolicy + + " -Drmi.registry.port=" + + registryPort, protocol[i]); System.err.println("\nusing protocol: " + (protocol[i] == "" ? "none" : protocol[i])); @@ -79,7 +84,7 @@ Echo obj = null; do { try { - obj = (Echo) Naming.lookup("//:" + TestLibrary.REGISTRY_PORT + + obj = (Echo) Naming.lookup("//:" + registryPort + "/EchoServer"); break; } catch (NotBoundException e) { @@ -109,7 +114,7 @@ } finally { serverVM.destroy(); try { - Naming.unbind("//:" + TestLibrary.REGISTRY_PORT + + Naming.unbind("//:" + registryPort + "/EchoServer"); } catch (Exception e) { TestLibrary.bomb("unbinding EchoServer", e); --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/security.policy 2012-07-13 13:17:20.114601631 -0700 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/security.policy 2012-07-13 13:17:19.914598447 -0700 @@ -22,9 +22,18 @@ permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "rmi.registry.port", "read"; + permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; + // used by TestLibrary to get the RMI Registry port + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.proxy"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp"; + // test needs to export rmid and communicate with objects on arbitrary ports permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; }; --- old/test/java/rmi/server/RemoteServer/AddrInUse.java 2012-07-13 13:17:20.802612584 -0700 +++ new/test/java/rmi/server/RemoteServer/AddrInUse.java 2012-07-13 13:17:20.602609400 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -26,6 +26,7 @@ * @summary retryServerSocket should not retry on BindException * @author Ann Wollrath * + * @library ../../testlibrary * @build AddrInUse * @run main/othervm AddrInUse */ @@ -36,7 +37,7 @@ public class AddrInUse implements Runnable { - private static final int PORT = 9999; + private static int port = -1; private static final long TIMEOUT = 10000; private boolean exportSucceeded = false; @@ -49,7 +50,7 @@ * has already been bound, and record the result. */ try { - LocateRegistry.createRegistry(PORT); + LocateRegistry.createRegistry(port); synchronized (this) { exportSucceeded = true; notifyAll(); @@ -68,8 +69,9 @@ /* * Bind a server socket to a port. */ - System.err.println("create a ServerSocket on port " + PORT + "..."); - ServerSocket server = new ServerSocket(PORT); + ServerSocket server = new ServerSocket(0); + port = server.getLocalPort(); + System.err.println("Created a ServerSocket on port " + port + "..."); /* * Start a thread that creates a registry on the same port, --- old/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java 2012-07-13 13:17:21.506623792 -0700 +++ new/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java 2012-07-13 13:17:21.298620480 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,15 +82,17 @@ UnicastRemoteObject.exportObject(obj); System.err.println("exported shutdown monitor"); - Registry localRegistry = - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + Registry localRegistry = TestLibrary.createRegistryOnUnusedPort(); + int registryPort = TestLibrary.getRegistryPort(localRegistry); System.err.println("created local registry"); localRegistry.bind(BINDING, obj); System.err.println("bound shutdown monitor in local registry"); System.err.println("starting remote ShutdownImpl VM..."); - (new JavaVM("ShutdownImpl")).start(); + (new JavaVM("ShutdownImpl", + "-Drmi.registry.port=" + + registryPort, "")).start(); Shutdown s; synchronized (obj.lock) { --- old/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl.java 2012-07-13 13:17:22.198634809 -0700 +++ new/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/ShutdownImpl.java 2012-07-13 13:17:22.002631688 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -68,8 +68,9 @@ public static void main(String[] args) { try { + int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); Registry registry = - LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); + LocateRegistry.getRegistry("", registryPort); ShutdownMonitor monitor = (ShutdownMonitor) registry.lookup(KeepAliveDuringCall.BINDING); System.err.println("(ShutdownImpl) retrieved shutdown monitor"); --- old/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java 2012-07-13 13:17:22.906646080 -0700 +++ new/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java 2012-07-13 13:17:22.698642769 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,8 +28,10 @@ * * @author Ann Wollrath * + * @library ../../../testlibrary * @build UnexportLeak * @build UnexportLeak_Stub + * @build TestLibrary * @build Ping * @run main/othervm UnexportLeak */ @@ -40,20 +42,18 @@ import java.rmi.registry.*; public class UnexportLeak implements Ping { - - private static int PORT = 2006; - public void ping() { } public static void main(String[] args) { try { System.err.println("\nRegression test for bug 4331349\n"); - LocateRegistry.createRegistry(PORT); + Registry registry = TestLibrary.createRegistryOnUnusedPort(); + int registryPort = TestLibrary.getRegistryPort(registry); Remote obj = new UnexportLeak(); WeakReference wr = new WeakReference(obj); UnicastRemoteObject.exportObject(obj); - LocateRegistry.getRegistry(PORT).rebind("UnexportLeak", obj); + LocateRegistry.getRegistry(registryPort).rebind("UnexportLeak", obj); UnicastRemoteObject.unexportObject(obj, true); obj = null; flushRefs(); --- old/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java 2012-07-13 13:17:23.606657224 -0700 +++ new/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java 2012-07-13 13:17:23.394653849 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -37,6 +37,7 @@ * @library ../../../testlibrary * @build FiniteGCLatency * @build FiniteGCLatency_Stub + * @build TestLibrary * @run main/othervm/timeout=120 FiniteGCLatency */ @@ -78,11 +79,11 @@ try { UnicastRemoteObject.exportObject(obj); System.err.println("exported remote object"); - - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + Registry registry1 = TestLibrary.createRegistryOnUnusedPort(); + int port = TestLibrary.getRegistryPort(registry1); System.err.println("created registry"); - Registry registry = LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); + Registry registry = LocateRegistry.getRegistry("", port); registry.bind(BINDING, obj); System.err.println("bound remote object in registry"); --- old/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java 2012-07-13 13:17:24.298668241 -0700 +++ new/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java 2012-07-13 13:17:24.086664866 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -87,8 +87,9 @@ UnicastRemoteObject.exportObject(obj); System.err.println("exported remote object"); + int registryPort = TestLibrary.getUnusedRandomPort(); Registry localRegistry = - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + LocateRegistry.createRegistry(registryPort); System.err.println("created local registry"); localRegistry.bind(BINDING, obj); @@ -96,7 +97,8 @@ synchronized (obj.lock) { System.err.println("starting remote client VM..."); - (new JavaVM("SelfTerminator")).start(); + (new JavaVM("SelfTerminator", "-Drmi.registry.port=" + + registryPort, "")).start(); System.err.println("waiting for unreferenced() callback..."); obj.lock.wait(TIMEOUT); --- old/test/java/rmi/server/Unreferenced/leaseCheckInterval/SelfTerminator.java 2012-07-13 13:17:24.982679130 -0700 +++ new/test/java/rmi/server/Unreferenced/leaseCheckInterval/SelfTerminator.java 2012-07-13 13:17:24.774675819 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -33,8 +33,10 @@ public static void main(String[] args) { try { + int registryPort = + Integer.parseInt(System.getProperty("rmi.registry.port")); Registry registry = - LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); + LocateRegistry.getRegistry("", registryPort); Remote stub = registry.lookup(LeaseCheckInterval.BINDING); Runtime.getRuntime().halt(0); } catch (Exception e) { --- old/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java 2012-07-13 13:17:25.706690657 -0700 +++ new/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java 2012-07-13 13:17:25.494687282 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -41,6 +41,7 @@ * @library ../../../testlibrary * @build UnreferencedContext * @build UnreferencedContext_Stub + * @build TestLibrary * @run main/othervm/timeout=120 UnreferencedContext */ @@ -119,10 +120,11 @@ UnicastRemoteObject.exportObject(obj); System.err.println("exported remote object"); - LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + Registry registry1 = TestLibrary.createRegistryOnUnusedPort(); + int port = TestLibrary.getRegistryPort(registry1); System.err.println("created registry"); - Registry registry = LocateRegistry.getRegistry("", TestLibrary.REGISTRY_PORT); + Registry registry = LocateRegistry.getRegistry("", port); registry.bind(BINDING, obj); System.err.println("bound remote object in registry"); --- old/test/java/rmi/server/useCustomRef/UseCustomRef.java 2012-07-13 13:17:26.406701801 -0700 +++ new/test/java/rmi/server/useCustomRef/UseCustomRef.java 2012-07-13 13:17:26.206698617 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -35,6 +35,7 @@ * @build Ping * @build UseCustomRef_Stub * @build UseCustomRef_Skel + * @build TestLibrary * @run main/othervm/policy=security.policy/secure=java.rmi.RMISecurityManager/timeout=120 UseCustomRef * * This test was failing to run because the synthetic access @@ -84,8 +85,9 @@ TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); System.err.println("creating Registry..."); - registry = LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + registry = TestLibrary.createRegistryOnUnusedPort(); + int port = TestLibrary.getRegistryPort(registry); /* * create object with custom ref and bind in registry */ @@ -97,7 +99,7 @@ "instanceof CustomServerRef"); } - String name = "//:" + TestLibrary.REGISTRY_PORT + "/UseCustomRef"; + String name = "//:" + port + "/UseCustomRef"; // String name = "UseCustomRef"; System.err.println("binding object in registry..."); Naming.rebind(name, cr); --- old/test/java/rmi/server/useCustomRef/security.policy 2012-07-13 13:17:27.098712818 -0700 +++ new/test/java/rmi/server/useCustomRef/security.policy 2012-07-13 13:17:26.902709697 -0700 @@ -8,8 +8,11 @@ grant { // the test uses a class in the package sun.rmi.server + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry"; permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server"; permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.proxy"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp"; permission java.util.PropertyPermission "package.restrict.access.sun", "read"; permission java.util.PropertyPermission "package.restrict.access.sun.rmi", "read"; --- old/test/java/rmi/testlibrary/ActivationLibrary.java 2012-07-13 13:17:27.786723771 -0700 +++ new/test/java/rmi/testlibrary/ActivationLibrary.java 2012-07-13 13:17:27.586720587 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -169,37 +169,10 @@ return false; } - /** - * Check to see if an arry of Strings contains a given string. - */ - private static boolean - containsString(String[] strings, String contained) - { - if (strings == null) { - if (contained == null) { - return true; - } - return false; - } - - for (int i = 0 ; i < strings.length ; i ++ ) { - if ((strings[i] != null) && - (strings[i].indexOf(contained) >= 0)) - { - return true; - } - } - return false; - } - /** cleanup after rmid */ public static void rmidCleanup(RMID rmid) { - rmidCleanup(rmid, TestLibrary.RMID_PORT); - } - - public static void rmidCleanup(RMID rmid, int port) { if (rmid != null) { - if (!ActivationLibrary.safeDestroy(rmid, port, SAFE_WAIT_TIME)) { + if (!ActivationLibrary.safeDestroy(rmid, SAFE_WAIT_TIME)) { TestLibrary.bomb("rmid not destroyed in: " + SAFE_WAIT_TIME + " milliseconds"); @@ -215,8 +188,8 @@ * @return whether or not shutdown completed succesfully in the * timeAllowed */ - private static boolean safeDestroy(RMID rmid, int port, long timeAllowed) { - DestroyThread destroyThread = new DestroyThread(rmid, port); + private static boolean safeDestroy(RMID rmid, long timeAllowed) { + DestroyThread destroyThread = new DestroyThread(rmid); destroyThread.start(); try { @@ -236,9 +209,9 @@ private final int port; private boolean succeeded = false; - DestroyThread(RMID rmid, int port) { + DestroyThread(RMID rmid) { this.rmid = rmid; - this.port = port; + this.port = rmid.getPort(); this.setDaemon(true); } --- old/test/java/rmi/testlibrary/RMID.java 2012-07-13 13:17:28.470734660 -0700 +++ new/test/java/rmi/testlibrary/RMID.java 2012-07-13 13:17:28.270731476 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -28,7 +28,6 @@ import java.io.*; import java.rmi.*; import java.rmi.activation.*; -import java.util.Properties; /** * Utility class that creates an instance of rmid with a policy @@ -133,7 +132,7 @@ boolean debugExec) { return createRMID(out, err, debugExec, true, - TestLibrary.RMID_PORT); + TestLibrary.getUnusedRandomPort()); } public static RMID createRMID(OutputStream out, OutputStream err, @@ -208,7 +207,7 @@ // if rmid is already running, then the test will fail with // a well recognized exception (port already in use...). - mesg("starting rmid..."); + mesg("starting rmid on port #" + port + "..."); super.start(); int slopFactor = 1; @@ -235,6 +234,14 @@ // Checking if rmid is present if (ActivationLibrary.rmidRunning(port)) { + /** + * We need to set the java.rmi.activation.port value as the + * activation system will use the property to determine the + * port #. The activation system will use this value if set. + * If it isn't set, the activation system will set it to an + * incorrect value. + */ + System.setProperty("java.rmi.activation.port", Integer.toString(port)); mesg("finished starting rmid."); return; } @@ -259,10 +266,6 @@ * Shutdown does not nullify possible references to the rmid * process object (destroy does though). */ - public static void shutdown() { - shutdown(TestLibrary.RMID_PORT); - } - public static void shutdown(int port) { try { @@ -301,9 +304,7 @@ * if rmid is a child process of the current VM. */ public void destroy() { - - // attempt graceful shutdown of the activation system on - // TestLibrary.RMID_PORT + // attempt graceful shutdown of the activation system shutdown(port); if (vm != null) { @@ -357,4 +358,6 @@ vm = null; } } + + public int getPort() {return port;} } --- old/test/java/rmi/testlibrary/RegistryRunner.java 2012-07-13 13:17:29.186746059 -0700 +++ new/test/java/rmi/testlibrary/RegistryRunner.java 2012-07-13 13:17:28.966742557 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -56,12 +56,13 @@ * Request that the registry process exit and handle * related exceptions. */ - public static void requestExit() { + public static void requestExit(int port) { + try { RemoteExiter exiter = (RemoteExiter) Naming.lookup("rmi://localhost:" + - TestLibrary.REGISTRY_PORT + + port + "/RemoteExiter"); try { exiter.exit(); @@ -84,7 +85,7 @@ System.err.println("Usage: "); System.exit(0); } - int port = TestLibrary.REGISTRY_PORT; + int port = -1; try { port = Integer.parseInt(args[0]); } catch (NumberFormatException nfe) { --- old/test/java/rmi/testlibrary/StreamPipe.java 2012-07-13 13:17:29.758755165 -0700 +++ new/test/java/rmi/testlibrary/StreamPipe.java 2012-07-13 13:17:29.546751790 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -113,7 +113,9 @@ w.flush(); line = r.readLine(); } - + } catch (InterruptedIOException iioe) { + // Thread interrupted during IO operation. Terminate StreamPipe. + return; } catch (IOException e) { System.err.println("*** IOException in StreamPipe.run:"); e.printStackTrace(); --- old/test/java/rmi/testlibrary/TestLibrary.java 2012-07-13 13:17:30.326764208 -0700 +++ new/test/java/rmi/testlibrary/TestLibrary.java 2012-07-13 13:17:30.122760960 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -36,37 +36,63 @@ * not make use of packages. */ +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.io.OutputStream; import java.io.PrintStream; -import java.net.URL; import java.net.MalformedURLException; -import java.rmi.activation.Activatable; -import java.rmi.activation.ActivationID; +import java.net.ServerSocket; +import java.net.URL; import java.rmi.NoSuchObjectException; -import java.rmi.registry.Registry; import java.rmi.Remote; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.ExportException; +import java.rmi.server.RemoteRef; import java.rmi.server.UnicastRemoteObject; import java.util.Enumeration; -import java.util.Hashtable; import java.util.Properties; -import java.io.ByteArrayOutputStream; -import java.security.AccessController; -import java.security.PrivilegedAction; +import sun.rmi.registry.RegistryImpl; +import sun.rmi.server.UnicastServerRef; +import sun.rmi.transport.Endpoint; +import sun.rmi.transport.LiveRef; +import sun.rmi.transport.tcp.TCPEndpoint; /** * Class of utility/library methods (i.e. procedures) that assist with * the writing and maintainance of rmi regression tests. */ public class TestLibrary { - - /** standard test port number for registry */ - public final static int REGISTRY_PORT = 2006; - /** port for rmid necessary: not used to actually start rmid */ - public final static int RMID_PORT = 1098; + /** + * IMPORTANT! + * + * RMI tests are run concurrently and port conflicts result when a single + * port number is used by multiple tests. When needing a port, use + * getUnusedRandomPort() wherever possible. If getUnusedRandomPort() cannot + * be used, reserve and specify a port to use for your test here. This + * will ensure there are no port conflicts amongst the RMI tests. The + * port numbers specified here may also be specified in the respective + * tests. Do not change the reserved port numbers here without also + * changing the port numbers in the respective tests. + * + * When needing an instance of the RMIRegistry, use + * createRegistryOnUnusedPort wherever possible to prevent port conflicts. + * + * Reserved port range: FIXED_PORT_MIN to FIXED_PORT_MAX (inclusive) for + * tests which cannot use a random port. If new fixed ports are added below + * FIXED_PORT_MIN or above FIXED_PORT_MAX, then adjust + * FIXED_PORT_MIN/MAX appropriately. + */ + public final static int FIXED_PORT_MIN = 64001; + public final static int FIXED_PORT_MAX = 64010; + public final static int RMIDVIAINHERITEDCHANNEL_ACTIVATION_PORT = 64001; + public final static int RMIDVIAINHERITEDCHANNEL_REGISTRY_PORT = 64002; + public final static int INHERITEDCHANNELNOTSERVERSOCKET_ACTIVATION_PORT = 64003; + public final static int INHERITEDCHANNELNOTSERVERSOCKET_REGISTRY_PORT = 64004; + public final static int READTEST_REGISTRY_PORT = 64005; static void mesg(Object mesg) { System.err.println("TEST_LIBRARY: " + mesg.toString()); @@ -340,6 +366,92 @@ } /** + * Creates an RMI {@link Registry} on a random port. + * + * @returns an RMI Registry, using a random port. + * @throws RemoteException if there was a problem creating a Registry. + */ + public static Registry createRegistryOnUnusedPort() throws RemoteException { + Registry registry = null; + + try { + registry = LocateRegistry.createRegistry(0); + } catch (ExportException ee) { + // If we have an ExportException, it's becuase there's already a + // registry which was created using + // LocateRegistry.createRegistry(0) running in this VM. Try + // getting a random port and creating the registry using the + // random port instead. + int port = getUnusedRandomPort(); + + try { + registry = LocateRegistry.createRegistry(port); + } catch(RemoteException re) { + throw new RemoteException("Could not create registry."); + } + } catch (Exception ex) { + throw new RemoteException("Could not create registry."); + } + + return registry; + } + + /** + * Returns the port number the RMI {@link Registry} is running on. + * + * @param registry the registry to find the port of. + * @return the port number the registry is using. + * @throws NullPointerException if registry is {@code null}. + * @throws RuntimeException if there was a problem getting the port number. + */ + public static int getRegistryPort(Registry registry) { + int port = -1; + + try { + RemoteRef remoteRef = ((RegistryImpl)registry).getRef(); + LiveRef liveRef = ((UnicastServerRef)remoteRef).getLiveRef(); + Endpoint endpoint = liveRef.getChannel().getEndpoint(); + TCPEndpoint tcpEndpoint = (TCPEndpoint) endpoint; + port = tcpEndpoint.getPort(); + } catch (Exception ex) { + throw new RuntimeException("Error getting registry port."); + } + + return port; + } + + /** + * Returns an unused random port number less than FIXED_PORT_MIN and greater + * than FIXED_PORT_MAX. Will try up to 10 times to get a random port before + * giving up and throwing a RuntimeException. + * + * @return an unused random port number. + * @throws RuntimeException if there was a problem getting a port. + */ + public static int getUnusedRandomPort() { + int numTries = 0; + int unusedRandomPort = FIXED_PORT_MIN; + + while ((numTries++ < 10) && ((unusedRandomPort >= FIXED_PORT_MIN) && + (unusedRandomPort <= FIXED_PORT_MAX))) + { + try (ServerSocket ss = new ServerSocket(0)) { + unusedRandomPort = ss.getLocalPort(); + } catch (Exception e) { + // Do nothing + } + } + + if ((unusedRandomPort >= FIXED_PORT_MIN) && + (unusedRandomPort <= FIXED_PORT_MAX)) + { + throw new RuntimeException("Error getting unused random port."); + } + + return unusedRandomPort; + } + + /** * Method to capture the stack trace of an exception and return it * as a string. */ --- old/test/java/rmi/transport/checkFQDN/CheckFQDN.java 2012-07-13 13:17:31.030775416 -0700 +++ new/test/java/rmi/transport/checkFQDN/CheckFQDN.java 2012-07-13 13:17:30.826772168 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -34,6 +34,7 @@ * * @library ../../testlibrary * @build CheckFQDN CheckFQDNClient CheckFQDN_Stub TellServerName + * @build TestLibrary * @run main/othervm/timeout=120 CheckFQDN */ @@ -63,7 +64,7 @@ */ public class CheckFQDN extends UnicastRemoteObject implements TellServerName { - + public static int REGISTRY_PORT =-1; static String propertyBeingTested = null; static String propertyBeingTestedValue = null; @@ -77,8 +78,8 @@ System.err.println ("\nRegression test for bug/rfe 4115683\n"); - Registry registry = java.rmi.registry.LocateRegistry. - createRegistry(TestLibrary.REGISTRY_PORT); + Registry registry = TestLibrary.createRegistryOnUnusedPort(); + REGISTRY_PORT = TestLibrary.getRegistryPort(registry); registry.bind("CheckFQDN", checkFQDN); /* test the host name scheme in different environments.*/ @@ -117,7 +118,9 @@ JavaVM jvm = new JavaVM("CheckFQDNClient", propOption + property + equal + - propertyValue + extraProp, + propertyValue + extraProp + + " -Drmi.registry.port=" + + REGISTRY_PORT, ""); propertyBeingTested=property; --- old/test/java/rmi/transport/checkFQDN/CheckFQDNClient.java 2012-07-13 13:17:31.722786433 -0700 +++ new/test/java/rmi/transport/checkFQDN/CheckFQDNClient.java 2012-07-13 13:17:31.522783249 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -58,8 +58,9 @@ System.err.println("Client host name: " + hostname); + int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); tell = (TellServerName) Naming.lookup("rmi://:" + - TestLibrary.REGISTRY_PORT + registryPort + "/CheckFQDN"); tell.tellServerName(hostname); System.err.println("client has exited"); --- old/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 2012-07-13 13:17:32.418797513 -0700 +++ new/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 2012-07-13 13:17:32.206794138 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -29,6 +29,7 @@ * * @library ../../testlibrary * @build CheckLeaseLeak CheckLeaseLeak_Stub LeaseLeakClient LeaseLeak + * @build TestLibrary * @run main/othervm/timeout=240 CheckLeaseLeak * */ @@ -57,7 +58,6 @@ import java.rmi.registry.*; public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak { - public CheckLeaseLeak() throws RemoteException { } public void ping () throws RemoteException { } @@ -87,8 +87,8 @@ try { Registry registry = - java.rmi.registry.LocateRegistry. - createRegistry(TestLibrary.REGISTRY_PORT); + TestLibrary.createRegistryOnUnusedPort(); + int registryPort = TestLibrary.getRegistryPort(registry); leakServer = new CheckLeaseLeak(); registry.rebind("/LeaseLeak", leakServer); @@ -99,7 +99,10 @@ JavaVM jvm = new JavaVM("LeaseLeakClient", " -Djava.security.policy=" + - TestParams.defaultPolicy, ""); + TestParams.defaultPolicy + + " -Drmi.registry.port=" + + registryPort, + ""); jvm.start(); if (jvm.getVM().waitFor() == 1 ) { --- old/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java 2012-07-13 13:17:33.110808530 -0700 +++ new/test/java/rmi/transport/checkLeaseInfoLeak/LeaseLeakClient.java 2012-07-13 13:17:32.914805410 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -31,11 +31,11 @@ try { LeaseLeak leaseLeak = null; + int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); // put a reference on a remote object. Registry registry = - java.rmi.registry.LocateRegistry.getRegistry( - TestLibrary.REGISTRY_PORT); + java.rmi.registry.LocateRegistry.getRegistry(registryPort); leaseLeak = (LeaseLeak) registry.lookup("/LeaseLeak"); leaseLeak.ping(); --- old/test/java/rmi/transport/checkLeaseInfoLeak/security.policy 2012-07-13 13:17:33.786819292 -0700 +++ new/test/java/rmi/transport/checkLeaseInfoLeak/security.policy 2012-07-13 13:17:33.586816108 -0700 @@ -19,6 +19,7 @@ permission java.util.PropertyPermission "user.dir", "read"; permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "rmi.registry.port", "read"; permission java.util.PropertyPermission "java.security.policy", "read"; permission java.util.PropertyPermission "java.security.manager", "read"; --- old/test/java/rmi/transport/closeServerSocket/CloseServerSocket.java 2012-07-13 13:17:34.466830118 -0700 +++ new/test/java/rmi/transport/closeServerSocket/CloseServerSocket.java 2012-07-13 13:17:34.266826934 -0700 @@ -1,5 +1,5 @@ /* - * 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 @@ -30,7 +30,8 @@ * the local port is released). * @author Peter Jones * - * @build CloseServerSocket + * @library ../../testlibrary + * @build CloseServerSocket TestLibrary * @run main/othervm CloseServerSocket */ @@ -44,8 +45,7 @@ import java.rmi.server.UnicastRemoteObject; public class CloseServerSocket implements Remote { - - private static final int PORT = 2020; + private static final int PORT = TestLibrary.getUnusedRandomPort(); private CloseServerSocket() { } @@ -88,7 +88,7 @@ } private static void verifyPortFree(int port) throws IOException { - ServerSocket ss = new ServerSocket(PORT); + ServerSocket ss = new ServerSocket(port); ss.close(); System.err.println("- port " + port + " is free"); } --- old/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java 2012-07-13 13:17:35.166841262 -0700 +++ new/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java 2012-07-13 13:17:34.958837951 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -32,6 +32,7 @@ * @build Test * @build TestImpl * @build TestImpl_Stub + * @build TestLibrary * @run main/othervm/policy=security.policy/timeout=360 DGCDeadLock */ @@ -53,7 +54,7 @@ import java.io.*; public class DGCDeadLock implements Runnable { - + private static final int REGISTRY_PORT = TestLibrary.getUnusedRandomPort(); final static public int HOLD_TARGET_TIME = 25000; public static int TEST_FAIL_TIME = HOLD_TARGET_TIME + 30000; public static boolean finished = false; @@ -75,7 +76,9 @@ TestParams.defaultPolicy + " -Djava.rmi.dgc.leaseValue=500000" + " -Dsun.rmi.dgc.checkInterval=" + - (HOLD_TARGET_TIME - 5000) + ""; + (HOLD_TARGET_TIME - 5000) + + " -Drmi.registry.port=" + REGISTRY_PORT + + "" ; testImplVM = new JavaVM("TestImpl", options, ""); testImplVM.start(); @@ -112,7 +115,7 @@ // create a test client Test foo = (Test) Naming.lookup("rmi://:" + - TestLibrary.REGISTRY_PORT + + REGISTRY_PORT + "/Foo"); echo = foo.echo("Hello world"); System.err.println("Test object created."); @@ -131,7 +134,7 @@ //import "Bar" Test bar = (Test) Naming.lookup("rmi://:" + - TestLibrary.REGISTRY_PORT + + REGISTRY_PORT + "/Bar"); /* infinite loop to show the liveness of Client, --- old/test/java/rmi/transport/dgcDeadLock/TestImpl.java 2012-07-13 13:17:35.854852215 -0700 +++ new/test/java/rmi/transport/dgcDeadLock/TestImpl.java 2012-07-13 13:17:35.646848904 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -36,7 +36,6 @@ public class TestImpl extends UnicastRemoteObject implements Test { - static Thread locker = null; static TestImpl foo = null; static TestImpl bar = null; @@ -57,20 +56,21 @@ Registry registry = null; try { + int registryPort = Integer.parseInt(System.getProperty("rmi.registry.port")); registry = java.rmi.registry.LocateRegistry. - createRegistry(TestLibrary.REGISTRY_PORT); + createRegistry(registryPort); //export "Foo" foo = new TestImpl(); Naming.rebind("rmi://:" + - TestLibrary.REGISTRY_PORT + registryPort + "/Foo", foo); try { //export "Bar" after leases have been expired. bar = new TestImpl(); Naming.rebind("rmi://localhost:" + - TestLibrary.REGISTRY_PORT + registryPort + "/Bar", bar); } catch (Exception e) { throw new RemoteException(e.getMessage()); --- old/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java 2012-07-13 13:17:36.530862977 -0700 +++ new/test/java/rmi/transport/handshakeFailure/HandshakeFailure.java 2012-07-13 13:17:36.322859666 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -30,7 +30,8 @@ * java.rmi.ConnectException or ConnectIOException, not a MarshalException. * @author Peter Jones * - * @build HandshakeFailure + * @library ../../testlibrary + * @build HandshakeFailure TestLibrary * @run main/othervm HandshakeFailure */ @@ -44,7 +45,7 @@ public class HandshakeFailure { - private static final int PORT = 2020; + private static final int PORT = TestLibrary.getUnusedRandomPort(); private static final int TIMEOUT = 10000; public static void main(String[] args) throws Exception { --- old/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java 2012-07-13 13:17:37.254874503 -0700 +++ new/test/java/rmi/transport/handshakeTimeout/HandshakeTimeout.java 2012-07-13 13:17:37.038871065 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -33,7 +33,8 @@ * this point (because no data for the invocation has yet been written). * @author Peter Jones * - * @build HandshakeTimeout + * @library ../../testlibrary + * @build HandshakeTimeout TestLibrary * @run main/othervm HandshakeTimeout */ @@ -46,7 +47,7 @@ public class HandshakeTimeout { - private static final int PORT = 2020; + private static final int PORT = TestLibrary.getUnusedRandomPort(); private static final int TIMEOUT = 10000; public static void main(String[] args) throws Exception { --- old/test/java/rmi/transport/httpSocket/HttpSocketTest.java 2012-07-13 13:17:37.950885584 -0700 +++ new/test/java/rmi/transport/httpSocket/HttpSocketTest.java 2012-07-13 13:17:37.750882400 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -27,7 +27,7 @@ * @author Dana Burns * * @library ../../testlibrary - * @build HttpSocketTest HttpSocketTest_Stub + * @build HttpSocketTest HttpSocketTest_Stub TestLibrary * @run main/othervm/policy=security.policy HttpSocketTest */ @@ -56,10 +56,7 @@ public class HttpSocketTest extends UnicastRemoteObject implements MyRemoteInterface { - private static final String NAME = "HttpSocketTest"; - private static final String REGNAME = - "//:" + TestLibrary.REGISTRY_PORT + "/" + NAME; public HttpSocketTest() throws RemoteException{} @@ -76,21 +73,20 @@ // Set the socket factory. System.err.println("installing socket factory"); RMISocketFactory.setSocketFactory(new RMIHttpToPortSocketFactory()); + int registryPort = -1; try { - System.err.println("Starting registry"); - registry = LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); - + registry = TestLibrary.createRegistryOnUnusedPort(); + registryPort = TestLibrary.getRegistryPort(registry); } catch (Exception e) { TestLibrary.bomb(e); } try { - registry.rebind( NAME, new HttpSocketTest() ); MyRemoteInterface httpTest = - (MyRemoteInterface)Naming.lookup( REGNAME ); + (MyRemoteInterface)Naming.lookup("//:" + registryPort + "/" + NAME); httpTest.setRemoteObject( new HttpSocketTest() ); Remote r = httpTest.getRemoteObject(); --- old/test/java/rmi/transport/httpSocket/security.policy 2012-07-13 13:17:38.634896473 -0700 +++ new/test/java/rmi/transport/httpSocket/security.policy 2012-07-13 13:17:38.430893225 -0700 @@ -4,6 +4,10 @@ grant { permission java.net.SocketPermission "*:1024-", "accept,connect,listen"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.server"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport"; permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.proxy"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.transport.tcp"; permission java.lang.RuntimePermission "setFactory"; }; --- old/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java 2012-07-13 13:17:39.334907617 -0700 +++ new/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java 2012-07-13 13:17:39.130904370 -0700 @@ -1,5 +1,5 @@ /* - * 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 @@ -31,6 +31,8 @@ * should become unreachable too (through the RMI implementation). * @author Peter Jones * + * @library ../../testlibrary + * @build TestLibrary * @run main/othervm -Dsun.rmi.transport.connectionTimeout=2000 * PinClientSocketFactory */ @@ -56,7 +58,7 @@ public class PinClientSocketFactory { - private static final int PORT = 2345; + private static final int PORT = TestLibrary.getUnusedRandomPort(); private static final int SESSIONS = 50; public interface Factory extends Remote { --- old/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java 2012-07-13 13:17:40.026918634 -0700 +++ new/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java 2012-07-13 13:17:39.818915323 -0700 @@ -1,5 +1,5 @@ /* - * 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 @@ -31,7 +31,8 @@ * procedure (which sleeps 10 seconds after 10 rapid failures). * @author Peter Jones * - * @build RapidExportUnexport + * @library ../../testlibrary + * @build TestLibrary RapidExportUnexport * @run main/othervm RapidExportUnexport */ @@ -39,9 +40,7 @@ import java.rmi.server.UnicastRemoteObject; public class RapidExportUnexport { - - private static final int PORT = 2055; - + private static final int PORT = TestLibrary.getUnusedRandomPort(); private static final int REPS = 100; private static final long TIMEOUT = 60000; --- old/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java 2012-07-13 13:17:40.698929333 -0700 +++ new/test/java/rmi/transport/reuseDefaultPort/ReuseDefaultPort.java 2012-07-13 13:17:40.498926149 -0700 @@ -1,5 +1,5 @@ /* - * 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 @@ -33,7 +33,8 @@ * continue to work because existing applications might depend on it. * @author Peter Jones * - * @build ReuseDefaultPort + * @library ../../testlibrary + * @build ReuseDefaultPort TestLibrary * @run main/othervm ReuseDefaultPort */ @@ -48,7 +49,7 @@ public class ReuseDefaultPort implements Remote { - private static final int PORT = 2223; + private static final int PORT = TestLibrary.getUnusedRandomPort(); private ReuseDefaultPort() { } --- old/test/sun/rmi/rmic/newrmic/equivalence/AppleUserImpl.java 2012-07-13 13:17:41.398940477 -0700 +++ new/test/sun/rmi/rmic/newrmic/equivalence/AppleUserImpl.java 2012-07-13 13:17:41.202937356 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -25,6 +25,7 @@ import java.rmi.Naming; import java.rmi.server.UnicastRemoteObject; import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; import java.util.Random; import java.util.ArrayList; import java.util.Date; @@ -249,11 +250,12 @@ } synchronized (user) { + int port = -1; // create new registry and bind new AppleUserImpl in registry try { - LocateRegistry.createRegistry(1099); //TestLibrary.REGISTRY_PORT); - Naming.rebind("rmi://localhost:1099/AppleUser",user); - //TestLibrary.REGISTRY_PORT + "/AppleUser", user); + Registry registry = TestLibrary.createRegistryOnUnusedPort(); + port = TestLibrary.getRegistryPort(registry); + Naming.rebind("rmi://localhost:" + port + "/AppleUser",user); } catch (RemoteException e) { //TestLibrary.bomb("Failed to bind AppleUser", e); } catch (java.net.MalformedURLException e) { @@ -263,10 +265,9 @@ // start the other server if available try { Class app = Class.forName("ApplicationServer"); - server = new Thread((Runnable) app.newInstance()); - logger.log(Level.INFO, "Starting application server " + - "in same process"); - server.start(); + java.lang.reflect.Constructor appConstructor = + app.getDeclaredConstructor(new Class[] {Integer.TYPE}); + server = new Thread((Runnable) appConstructor.newInstance(port)); } catch (ClassNotFoundException e) { // assume the other server is running in a separate process logger.log(Level.INFO, "Application server must be " + --- old/test/sun/rmi/rmic/newrmic/equivalence/run.sh 2012-07-13 13:17:42.122952003 -0700 +++ new/test/sun/rmi/rmic/newrmic/equivalence/run.sh 2012-07-13 13:17:41.918948755 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2003, 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 @@ -26,6 +26,8 @@ # @summary This test verifies that the new implementation of rmic # generates equivalent classes as the old implementation, for a set # of sample input classes. +# @library ../../../../../java/rmi/testlibrary +# @build TestLibrary # @author Peter Jones # # @build AgentServerImpl --- old/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java 2012-07-13 13:17:42.834963338 -0700 +++ new/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java 2012-07-13 13:17:42.618959899 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -90,7 +90,6 @@ } public static class DoRMIStuff { - private static final int PORT = 2020; private interface Foo extends Remote { Object echo(Object obj) throws RemoteException; } @@ -99,8 +98,9 @@ public Object echo(Object obj) { return obj; } } public static void main(String[] args) throws Exception { - LocateRegistry.createRegistry(PORT); - Registry reg = LocateRegistry.getRegistry("", PORT); + Registry registry = TestLibrary.createRegistryOnUnusedPort(); + int registryPort = TestLibrary.getRegistryPort(registry); + Registry reg = LocateRegistry.getRegistry("", registryPort); FooImpl fooimpl = new FooImpl(); UnicastRemoteObject.exportObject(fooimpl, 0); reg.rebind("foo", fooimpl); --- old/test/sun/rmi/runtime/Log/checkLogging/CheckLogging.java 2012-07-13 13:17:43.534974482 -0700 +++ new/test/sun/rmi/runtime/Log/checkLogging/CheckLogging.java 2012-07-13 13:17:43.330971235 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -77,8 +77,9 @@ * logger output is non-null. */ public class CheckLogging { - private static final String LOCATION = - "rmi://localhost:" + TestLibrary.REGISTRY_PORT + "/"; + private static int REGISTRY_PORT = -1; + private static String LOCATION; + private static final ByteArrayOutputStream clientCallOut = new ByteArrayOutputStream(); @@ -100,7 +101,9 @@ private static Registry registry; static { try { - registry = LocateRegistry.createRegistry(TestLibrary.REGISTRY_PORT); + registry = TestLibrary.createRegistryOnUnusedPort(); + REGISTRY_PORT = TestLibrary.getRegistryPort(registry); + LOCATION = "rmi://localhost:" + REGISTRY_PORT + "/"; } catch (Exception e) { TestLibrary.bomb("could not create registry"); } --- old/test/sun/rmi/transport/proxy/EagerHttpFallback.java 2012-07-13 13:17:44.258986009 -0700 +++ new/test/sun/rmi/transport/proxy/EagerHttpFallback.java 2012-07-13 13:17:44.046982633 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -25,6 +25,8 @@ * @bug 4290727 * @summary Verify that ConnectException will trigger HTTP fallback if * sun.rmi.transport.proxy.eagerHttpFallback system property is set. + * @library ../../../../java/rmi/testlibrary + * @build TestLibrary * @run main/othervm EagerHttpFallback */ @@ -33,8 +35,8 @@ public class EagerHttpFallback { - static final int INITIAL_PORT = 7070; - static final int FALLBACK_PORT = 7071; + static final int INITIAL_PORT = TestLibrary.getUnusedRandomPort(); + static final int FALLBACK_PORT = TestLibrary.getUnusedRandomPort(); public static void main(String[] args) throws Exception { System.setProperty("http.proxyHost", "127.0.0.1"); --- old/test/sun/rmi/transport/tcp/DeadCachedConnection.java 2012-07-13 13:17:44.962997216 -0700 +++ new/test/sun/rmi/transport/tcp/DeadCachedConnection.java 2012-07-13 13:17:44.758993969 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -58,7 +58,7 @@ import java.rmi.server.*; public class DeadCachedConnection { - static public final int regport = 17340; + static public final int regport = TestLibrary.getUnusedRandomPort(); static public void main(String[] argv) throws Exception {