--- old/test/java/rmi/Naming/LookupNameWithColon.java 2016-12-12 20:51:54.624472872 -0800 +++ new/test/java/rmi/Naming/LookupNameWithColon.java 2016-12-12 20:51:54.407472882 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, 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,7 @@ "multiple:colons:in:name" }; - Registry reg = TestLibrary.createRegistryOnUnusedPort(); + Registry reg = TestLibrary.createRegistryOnEphemeralPort(); int port = TestLibrary.getRegistryPort(reg); for (int i = 0; i < names.length; i++) { --- old/test/java/rmi/Naming/RmiIsNoScheme.java 2016-12-12 20:51:55.299472842 -0800 +++ new/test/java/rmi/Naming/RmiIsNoScheme.java 2016-12-12 20:51:55.081472852 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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,7 +49,7 @@ System.err.println("\nRegression test for bug 4626311\n"); try { - Registry registry = TestLibrary.createRegistryOnUnusedPort(); + Registry registry = TestLibrary.createRegistryOnEphemeralPort(); int registryPort = TestLibrary.getRegistryPort(registry); Naming.rebind("//:" + registryPort + "/RmiIsNoScheme", new RmiIsNoScheme()); --- old/test/java/rmi/Naming/UnderscoreHost.java 2016-12-12 20:51:56.002472810 -0800 +++ new/test/java/rmi/Naming/UnderscoreHost.java 2016-12-12 20:51:55.767472821 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -80,7 +80,7 @@ try { HostVerifyingSocketFactory hvf = new HostVerifyingSocketFactory(); RMISocketFactory.setSocketFactory(hvf); - Registry r = TestLibrary.createRegistryOnUnusedPort(); + Registry r = TestLibrary.createRegistryOnEphemeralPort(); int port = TestLibrary.getRegistryPort(r); t = new UnderscoreHost(); r.rebind(NAME, t); --- old/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java 2016-12-12 20:51:56.739472777 -0800 +++ new/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java 2016-12-12 20:51:56.437472791 -0800 @@ -85,7 +85,7 @@ try { TestLibrary.suggestSecurityManager("java.lang.SecurityManager"); - registry = TestLibrary.createRegistryOnUnusedPort(); + registry = TestLibrary.createRegistryOnEphemeralPort(); registryPort = TestLibrary.getRegistryPort(registry); // must run with java.lang.SecurityManager or the test --- old/test/java/rmi/registry/emptyName/EmptyName.java 2016-12-12 20:51:57.395472747 -0800 +++ new/test/java/rmi/registry/emptyName/EmptyName.java 2016-12-12 20:51:57.173472757 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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,7 +38,7 @@ public class EmptyName { public static void main(String[] args) throws Exception { - Registry impl = TestLibrary.createRegistryOnUnusedPort(); + Registry impl = TestLibrary.createRegistryOnEphemeralPort(); Registry stub = (Registry) RemoteObject.toStub(impl); stub.bind("", stub); stub.lookup(""); --- old/test/java/rmi/reliability/juicer/AppleUserImpl.java 2016-12-12 20:51:58.312472706 -0800 +++ new/test/java/rmi/reliability/juicer/AppleUserImpl.java 2016-12-12 20:51:58.045472718 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -313,7 +313,7 @@ synchronized (user) { // create new registry and bind new AppleUserImpl in registry - Registry registry = TestLibrary.createRegistryOnUnusedPort(); + Registry registry = TestLibrary.createRegistryOnEphemeralPort(); registryPort = TestLibrary.getRegistryPort(registry); LocateRegistry.getRegistry(registryPort).rebind("AppleUser", user); --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java 2016-12-12 20:51:59.232472665 -0800 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java 2016-12-12 20:51:58.942472678 -0800 @@ -43,7 +43,7 @@ import java.rmi.registry.*; public class UseCustomSocketFactory { - static final int REGISTRY_PORT = TestLibrary.getUnusedRandomPort(); + static int registryPort = -1; static String[] protocol = new String[] { "", "compress", "xor" }; @@ -54,7 +54,8 @@ TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); try { - LocateRegistry.createRegistry(REGISTRY_PORT); + Registry reg = LocateRegistry.createRegistry(0); + registryPort = TestLibrary.getRegistryPort(reg); } catch (RemoteException e) { TestLibrary.bomb("creating registry", e); } @@ -90,7 +91,7 @@ "-Djava.security.policy=" + TestParams.defaultPolicy + " -Drmi.registry.port=" + - REGISTRY_PORT + + registryPort + " -Djava.rmi.activation.port=" + rmidPort, protocol[i]); @@ -108,7 +109,7 @@ long stopTime = System.currentTimeMillis() + 24000; do { try { - echo[i] = (Echo) Naming.lookup("//:" + REGISTRY_PORT + + echo[i] = (Echo) Naming.lookup("//:" + registryPort + "/EchoServer"); break; } catch (NotBoundException e) { @@ -138,7 +139,7 @@ } finally { serverVM.destroy(); try { - Naming.unbind("//:" + REGISTRY_PORT + "/EchoServer"); + Naming.unbind("//:" + registryPort + "/EchoServer"); } catch (RemoteException | NotBoundException | MalformedURLException e) { TestLibrary.bomb("unbinding EchoServer", e); } --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/security.policy 2016-12-12 20:51:59.963472632 -0800 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/security.policy 2016-12-12 20:51:59.698472644 -0800 @@ -20,6 +20,13 @@ 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"; + // used by TestLibrary to determine test environment permission java.util.PropertyPermission "test.*", "read"; permission java.util.PropertyPermission "user.dir", "read"; --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java 2016-12-12 20:52:00.719472598 -0800 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java 2016-12-12 20:52:00.493472608 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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.out.println("\nRegression test for bug 4148850\n"); TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); - int registryPort = TestLibrary.getUnusedRandomPort(); + int registryPort = -1; try { impl = new HelloImpl(); @@ -68,9 +68,10 @@ * allow the rmiregistry to be secure. */ registry = LocateRegistry. - createRegistry(registryPort, + createRegistry(0, new Compress.CompressRMIClientSocketFactory(), new Compress.CompressRMIServerSocketFactory()); + registryPort = TestLibrary.getRegistryPort(registry); registry.rebind("/HelloServer", impl); checkStub(registry, "RMIServerSocket"); --- old/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/security.policy 2016-12-12 20:52:01.506472562 -0800 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/registry/security.policy 2016-12-12 20:52:01.239472574 -0800 @@ -22,6 +22,13 @@ 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/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java 2016-12-12 20:52:02.378472523 -0800 +++ new/test/java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java 2016-12-12 20:52:02.006472540 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -55,7 +55,7 @@ TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); try { - Registry registry = TestLibrary.createRegistryOnUnusedPort(); + Registry registry = TestLibrary.createRegistryOnEphemeralPort(); registryPort = TestLibrary.getRegistryPort(registry); } catch (RemoteException e) { TestLibrary.bomb("creating registry", e); --- old/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java 2016-12-12 20:52:03.346472479 -0800 +++ new/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java 2016-12-12 20:52:03.048472493 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, 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 @@ -80,7 +80,7 @@ UnicastRemoteObject.exportObject(obj); System.err.println("exported shutdown monitor"); - Registry localRegistry = TestLibrary.createRegistryOnUnusedPort(); + Registry localRegistry = TestLibrary.createRegistryOnEphemeralPort(); int registryPort = TestLibrary.getRegistryPort(localRegistry); System.err.println("created local registry"); --- old/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java 2016-12-12 20:52:04.332472435 -0800 +++ new/test/java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java 2016-12-12 20:52:04.023472449 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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,7 +49,7 @@ public static void main(String[] args) { try { System.err.println("\nRegression test for bug 4331349\n"); - Registry registry = TestLibrary.createRegistryOnUnusedPort(); + Registry registry = TestLibrary.createRegistryOnEphemeralPort(); int registryPort = TestLibrary.getRegistryPort(registry); Remote obj = new UnexportLeak(); WeakReference wr = new WeakReference(obj); --- old/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java 2016-12-12 20:52:05.122472399 -0800 +++ new/test/java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java 2016-12-12 20:52:04.866472411 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -81,7 +81,7 @@ try { UnicastRemoteObject.exportObject(obj); System.err.println("exported remote object"); - Registry registry1 = TestLibrary.createRegistryOnUnusedPort(); + Registry registry1 = TestLibrary.createRegistryOnEphemeralPort(); int port = TestLibrary.getRegistryPort(registry1); System.err.println("created registry"); --- old/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java 2016-12-12 20:52:05.924472363 -0800 +++ new/test/java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java 2016-12-12 20:52:05.619472377 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -122,7 +122,7 @@ UnicastRemoteObject.exportObject(obj); System.err.println("exported remote object"); - Registry registry1 = TestLibrary.createRegistryOnUnusedPort(); + Registry registry1 = TestLibrary.createRegistryOnEphemeralPort(); int port = TestLibrary.getRegistryPort(registry1); System.err.println("created registry"); --- old/test/java/rmi/transport/checkFQDN/CheckFQDN.java 2016-12-12 20:52:06.774472325 -0800 +++ new/test/java/rmi/transport/checkFQDN/CheckFQDN.java 2016-12-12 20:52:06.490472338 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -81,7 +81,7 @@ System.err.println ("\nRegression test for bug/rfe 4115683\n"); - Registry registry = TestLibrary.createRegistryOnUnusedPort(); + Registry registry = TestLibrary.createRegistryOnEphemeralPort(); REGISTRY_PORT = TestLibrary.getRegistryPort(registry); registry.bind("CheckFQDN", checkFQDN); --- old/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 2016-12-12 20:52:07.886915275 -0800 +++ new/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java 2016-12-12 20:52:07.620782287 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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,6 +30,7 @@ * @library ../../testlibrary * @modules java.rmi/sun.rmi.registry * java.rmi/sun.rmi.server + * java.rmi/sun.rmi.transport:open * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp * @build TestLibrary CheckLeaseLeak_Stub LeaseLeakClient LeaseLeak @@ -90,7 +91,7 @@ try { Registry registry = - TestLibrary.createRegistryOnUnusedPort(); + TestLibrary.createRegistryOnEphemeralPort(); int registryPort = TestLibrary.getRegistryPort(registry); leakServer = new CheckLeaseLeak(); --- old/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java 2016-12-12 20:52:08.676309740 -0800 +++ new/test/java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java 2016-12-12 20:52:08.437190251 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -44,7 +44,6 @@ import java.rmi.server.UnicastRemoteObject; public class RapidExportUnexport { - private static final int PORT = TestLibrary.getUnusedRandomPort(); private static final int REPS = 100; private static final long TIMEOUT = 60000; @@ -55,7 +54,7 @@ long start = System.currentTimeMillis(); for (int i = 0; i < REPS; i++) { System.err.println(i); - UnicastRemoteObject.exportObject(impl, PORT); + UnicastRemoteObject.exportObject(impl, 0); UnicastRemoteObject.unexportObject(impl, true); Thread.sleep(1); // work around BindException (bug?) } --- old/test/sun/rmi/rmic/newrmic/equivalence/AppleUserImpl.java 2016-12-12 20:52:09.621782197 -0800 +++ new/test/sun/rmi/rmic/newrmic/equivalence/AppleUserImpl.java 2016-12-12 20:52:09.209576216 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -253,7 +253,7 @@ int port = -1; // create new registry and bind new AppleUserImpl in registry try { - Registry registry = TestLibrary.createRegistryOnUnusedPort(); + Registry registry = TestLibrary.createRegistryOnEphemeralPort(); port = TestLibrary.getRegistryPort(registry); Naming.rebind("rmi://localhost:" + port + "/AppleUser",user); } catch (RemoteException e) { --- old/test/sun/rmi/runtime/Log/checkLogging/CheckLogging.java 2016-12-12 20:52:10.412177161 -0800 +++ new/test/sun/rmi/runtime/Log/checkLogging/CheckLogging.java 2016-12-12 20:52:10.165053672 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, 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 @@ -103,7 +103,7 @@ private static Registry registry; static { try { - registry = TestLibrary.createRegistryOnUnusedPort(); + registry = TestLibrary.createRegistryOnEphemeralPort(); REGISTRY_PORT = TestLibrary.getRegistryPort(registry); LOCATION = "rmi://localhost:" + REGISTRY_PORT + "/"; } catch (Exception e) {