diff --git a/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java b/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java index 2e10313f5fb..4f29e0519b4 100644 --- a/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java +++ b/jdk/test/java/rmi/registry/altSecurityManager/AltSecurityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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,9 @@ * java.rmi/sun.rmi.server * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp - * @build TestLibrary JavaVM RMID TestSecurityManager + * java.base/sun.nio.ch + * @build TestLibrary RMID RMIDSelectorProvider RegistryVM RMIRegistryRunner + * TestSecurityManager * @run main/othervm AltSecurityManager */ @@ -44,7 +46,6 @@ * 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; @@ -57,31 +58,34 @@ public class AltSecurityManager implements Runnable { private static final long TIME_OUT = (long)(15000 * TestLibrary.getTimeoutFactor()); - public AltSecurityManager(int port) { - if (port <= 0) { - TestLibrary.bomb("Port must be greater than 0."); - } - - this.regPort = port; - } - public void run() { try { if (utilityToStart.equals(REGISTRY_IMPL)) { - vm = new JavaVM(utilityToStart, - " -Djava.security.manager=TestSecurityManager", - Integer.toString(regPort)); + vm = RegistryVM.createRegistryVMWithRunner( + "RMIRegistryRunner", + "-Djava.security.manager=TestSecurityManager"); } else if (utilityToStart.contains(ACTIVATION)) { - vm = new JavaVM(utilityToStart, - " -Djava.security.manager=TestSecurityManager", - "-port " + Integer.toString(regPort)); + vm = RMID.createRMIDOnEphemeralPortWithOptions( + "-Djava.security.manager=TestSecurityManager"); } else { TestLibrary.bomb("Utility to start must be " + REGISTRY_IMPL + " or " + ACTIVATION); } System.err.println("starting " + utilityToStart); - vm.execute(); + try { + vm.start(); + throw new RuntimeException("Expected exception did not occur!"); + } catch (Exception expected) { + int exit = vm.waitFor(); + if (exit != TestSecurityManager.EXIT_VALUE) { + throw new RuntimeException(utilityToStart + + " exit with an unexpected value " + + exit + "."); + } + System.err.format("Success: starting %s exited with status %d%n", + utilityToStart, TestSecurityManager.EXIT_VALUE); + } } catch (Exception e) { TestLibrary.bomb(e); @@ -96,8 +100,7 @@ public class AltSecurityManager implements Runnable { utilityToStart = utility; try { - int port = TestLibrary.getUnusedRandomPort(); - Thread thread = new Thread(new AltSecurityManager(port)); + Thread thread = new Thread(new AltSecurityManager()); System.err.println("expecting RuntimeException for " + "checkListen in child process"); long start = System.currentTimeMillis(); @@ -116,7 +119,7 @@ public class AltSecurityManager implements Runnable { " terminated on time"); } } finally { - vm.destroy(); + vm.cleanup(); vm = null; } } diff --git a/jdk/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java b/jdk/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java index e1a6ef85db3..ea291919ad3 100644 --- a/jdk/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java +++ b/jdk/test/java/rmi/registry/altSecurityManager/TestSecurityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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 @@ /**/ public class TestSecurityManager extends SecurityManager { + public static final int EXIT_VALUE = 123; + public TestSecurityManager() { } @@ -36,7 +38,7 @@ public class TestSecurityManager extends SecurityManager { // by the main test process to detect that the proper security // manager has been installed in the relevant VMs. // - System.exit(1); + System.exit(EXIT_VALUE); } public void checkExit(int status) { diff --git a/jdk/test/java/rmi/registry/altSecurityManager/registry.security.policy b/jdk/test/java/rmi/registry/altSecurityManager/registry.security.policy new file mode 100644 index 00000000000..5c09bd0d93b --- /dev/null +++ b/jdk/test/java/rmi/registry/altSecurityManager/registry.security.policy @@ -0,0 +1,8 @@ +grant { + permission java.lang.RuntimePermission "accessClassInPackage.sun.rmi.registry"; + permission java.util.PropertyPermission "env.class.path", "read"; + permission java.io.FilePermission ".", "read"; + permission java.util.PropertyPermission "user.dir", "read"; + permission java.lang.RuntimePermission "createClassLoader"; + permission java.lang.RuntimePermission "setContextClassLoader"; +}; diff --git a/jdk/test/java/rmi/registry/altSecurityManager/rmid.security.policy b/jdk/test/java/rmi/registry/altSecurityManager/rmid.security.policy new file mode 100644 index 00000000000..5307f72ce64 --- /dev/null +++ b/jdk/test/java/rmi/registry/altSecurityManager/rmid.security.policy @@ -0,0 +1,7 @@ +grant { + permission java.lang.RuntimePermission "selectorProvider"; + permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch"; + permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read"; + permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read"; + permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept"; +}; diff --git a/jdk/test/java/rmi/registry/reexport/Reexport.java b/jdk/test/java/rmi/registry/reexport/Reexport.java index b0b29ef9bd4..47320afaf48 100644 --- a/jdk/test/java/rmi/registry/reexport/Reexport.java +++ b/jdk/test/java/rmi/registry/reexport/Reexport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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,7 @@ * java.rmi/sun.rmi.server * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp - * @build TestLibrary REGISTRY RegistryRunner + * @build TestLibrary RegistryVM RegistryRunner * @run main/othervm Reexport */ @@ -114,7 +114,7 @@ public class Reexport { public static void makeRegistry() { try { - subreg = REGISTRY.createREGISTRY(); + subreg = RegistryVM.createRegistryVM(); subreg.start(); port = subreg.getPort(); System.out.println("Starting registry on port " + port); @@ -125,12 +125,12 @@ public class Reexport { } } - private static REGISTRY subreg = null; + private static RegistryVM subreg = null; private static int port = -1; public static void killRegistry() { if (subreg != null) { - subreg.shutdown(); + subreg.cleanup(); subreg = null; } } diff --git a/jdk/test/java/rmi/testlibrary/JavaVM.java b/jdk/test/java/rmi/testlibrary/JavaVM.java index 087e700391e..5c841f5426b 100644 --- a/jdk/test/java/rmi/testlibrary/JavaVM.java +++ b/jdk/test/java/rmi/testlibrary/JavaVM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -229,6 +229,22 @@ public class JavaVM { vm = null; } + /** + * Return exit value for vm process. + * @return exit value for vm process + * @throws IllegalThreadStateException if the vm process has not yet terminated + */ + public int exitValue() { + return vm.exitValue(); + } + + /** + * Destroy the vm process, and do necessary cleanup. + */ + public void cleanup() { + destroy(); + } + /** * Destroys the VM, waits for it to terminate, and returns * its exit status. diff --git a/jdk/test/java/rmi/testlibrary/RMID.java b/jdk/test/java/rmi/testlibrary/RMID.java index 07628fb2358..a2135b3a9b0 100644 --- a/jdk/test/java/rmi/testlibrary/RMID.java +++ b/jdk/test/java/rmi/testlibrary/RMID.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -140,18 +140,6 @@ public class RMID extends JavaVM { } private static String makeArgs(boolean includePortArg, int port) { - String propagateManager = null; - - // rmid will run with a security manager set, but no policy - // file - it should not need one. - if (System.getSecurityManager() == null) { - propagateManager = MANAGER_OPTION + - TestParams.defaultSecurityManager; - } else { - propagateManager = MANAGER_OPTION + - System.getSecurityManager().getClass().getName(); - } - // getAbsolutePath requires permission to read user.dir String args = " -log " + (new File(LOGDIR, log)).getAbsolutePath(); @@ -209,8 +197,31 @@ public class RMID extends JavaVM { public static RMID createRMID(OutputStream out, OutputStream err, boolean debugExec, boolean includePortArg, int port) + { + return createRMIDWithOptions(out, err, debugExec, includePortArg, port, ""); + } + + /** + * Create a RMID on a specified port capturing stdout and stderr + * with additional command line options and whether to print out + * debugging information that is used for spawning activation groups. + * + * @param out the OutputStream where the normal output of the + * rmid subprocess goes + * @param err the OutputStream where the error output of the + * rmid subprocess goes + * @param debugExec whether to print out debugging information + * @param includePortArg whether to include port argument + * @param port the port on which rmid accepts requests + * @param additionalOptions additional command line options + * @return a RMID instance + */ + public static RMID createRMIDWithOptions(OutputStream out, OutputStream err, + boolean debugExec, boolean includePortArg, + int port, String additionalOptions) { String options = makeOptions(port, debugExec, false); + options += " " + additionalOptions; String args = makeArgs(includePortArg, port); RMID rmid = new RMID("sun.rmi.server.Activation", options, args, out, err, port); @@ -223,6 +234,19 @@ public class RMID extends JavaVM { return createRMID(System.out, System.err, true, false, 0); } + /** + * Create a RMID on an ephemeral port capturing stdout and stderr + * with additional command line options. + * + * @param additionalOptions additional command line options + * @return a RMID instance + */ + public static RMID createRMIDOnEphemeralPortWithOptions( + String additionalOptions) { + return createRMIDWithOptions(System.out, System.err, + true, false, 0, additionalOptions); + } + public static RMID createRMIDOnEphemeralPort(OutputStream out, OutputStream err, boolean debugExec) diff --git a/jdk/test/java/rmi/testlibrary/RMIRegistryRunner.java b/jdk/test/java/rmi/testlibrary/RMIRegistryRunner.java new file mode 100644 index 00000000000..3be51e95e14 --- /dev/null +++ b/jdk/test/java/rmi/testlibrary/RMIRegistryRunner.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2017, 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. + */ + +/**/ + +import java.rmi.*; +import java.rmi.registry.*; +import java.rmi.server.*; + +/** + * Class to run a rmiregistry whose VM can be told to exit remotely; + * Difference between this class and RegistryRunner is that this class + * simulate rmiregistry closer than RegistryRunner. + */ +public class RMIRegistryRunner extends RegistryRunner +{ + public RMIRegistryRunner() throws RemoteException { + } + + /** + * port 0 means to use ephemeral port to start registry. + * + * @param args command line arguments passed in from main + * @return the port number on which registry accepts requests + */ + protected static int init(String[] args) { + try { + if (args.length == 0) { + System.err.println("Usage: "); + System.exit(0); + } + int port = -1; + port = Integer.parseInt(args[0]); + + // call RegistryImpl.createRegistry to simulate rmiregistry. + registry = sun.rmi.registry.RegistryImpl.createRegistry(port); + if (port == 0) { + port = TestLibrary.getRegistryPort(registry); + } + + // create a remote object to tell this VM to exit + exiter = new RMIRegistryRunner(); + Naming.rebind("rmi://localhost:" + port + + "/RemoteExiter", exiter); + + return port; + } catch (Exception e) { + System.err.println(e.getMessage()); + e.printStackTrace(); + System.exit(1); + } + return -1; + } + + public static void main(String[] args) { + int port = init(args); + notify(port); + } +} diff --git a/jdk/test/java/rmi/testlibrary/RegistryRunner.java b/jdk/test/java/rmi/testlibrary/RegistryRunner.java index e8c9ab45873..a604a8d0027 100644 --- a/jdk/test/java/rmi/testlibrary/RegistryRunner.java +++ b/jdk/test/java/rmi/testlibrary/RegistryRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2017, 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,7 @@ import java.rmi.server.*; /** * Class to run a registry whose VM can be told to exit remotely; using - * the rmiregistry in this fashion makes tests more robust under + * a registry (in a sub-process) in this fashion makes tests more robust under * windows where Process.destroy() seems not to be 100% reliable. */ public class RegistryRunner extends UnicastRemoteObject @@ -38,8 +38,8 @@ public class RegistryRunner extends UnicastRemoteObject private static final String PORT_LABEL_START = "RegistryRunner.port.start:"; private static final String PORT_LABEL_END = ":RegistryRunner.port.end"; - private static Registry registry = null; - private static RemoteExiter exiter = null; + protected static Registry registry = null; + protected static RemoteExiter exiter = null; public RegistryRunner() throws RemoteException { } @@ -72,6 +72,7 @@ public class RegistryRunner extends UnicastRemoteObject } catch (RemoteException re) { } e = null; + } catch (java.net.MalformedURLException mfue) { // will not happen } catch (NotBoundException nbe) { @@ -97,6 +98,9 @@ public class RegistryRunner extends UnicastRemoteObject /** * port 0 means to use ephemeral port to start registry. + * + * @param args command line arguments passed in from main + * @return the port number on which registry accepts requests */ protected static int init(String[] args) { try { @@ -128,13 +132,15 @@ public class RegistryRunner extends UnicastRemoteObject } /** - * REGISTRY.start() will filter the output of registry subprocess, - * when valid port is detected, REGISTRY.start() returns. + * RegistryVM.start() will filter the output of registry subprocess, + * when valid port is detected, RegistryVM.start() returns. * So, for subclass, it's important to call this method after registry * is initialized and necessary remote objects have been bound. + * + * @param port the port on which registry accepts requests */ protected static void notify(int port) { - // this output is important for REGISTRY to get the port + // this output is important for RegistryVM to get the port // where rmiregistry is serving System.out.println(PORT_LABEL_START + port + PORT_LABEL_END); System.out.flush(); diff --git a/jdk/test/java/rmi/testlibrary/REGISTRY.java b/jdk/test/java/rmi/testlibrary/RegistryVM.java similarity index 50% rename from jdk/test/java/rmi/testlibrary/REGISTRY.java rename to jdk/test/java/rmi/testlibrary/RegistryVM.java index 6cd866a70da..69b9d8f4f1d 100644 --- a/jdk/test/java/rmi/testlibrary/REGISTRY.java +++ b/jdk/test/java/rmi/testlibrary/RegistryVM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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,13 +25,15 @@ import java.io.OutputStream; import java.io.IOException; /** - * Class to run and control rmiregistry in a sub-process. + * Class to run and control registry/rmiregistry in a sub-process. + * The behaviour changes when use different runner, currently + * there are 2 built-in runners, RegistryRunner and RMIRegistryRunner. * * We can't kill a registry if we have too-close control * over it. We must make it in a subprocess, and then kill the * subprocess when it has served our needs. */ -public class REGISTRY extends JavaVM { +public class RegistryVM extends JavaVM { private static final double START_TIMEOUT = 20_000 * TestLibrary.getTimeoutFactor(); @@ -39,7 +41,7 @@ public class REGISTRY extends JavaVM { private int port = -1; - private REGISTRY(String runner, OutputStream out, OutputStream err, + private RegistryVM(String runner, OutputStream out, OutputStream err, String options, int port) { super(runner, options, Integer.toString(port), out, err); try { @@ -54,33 +56,86 @@ public class REGISTRY extends JavaVM { this.port = port; } - public static REGISTRY createREGISTRY() { - return createREGISTRYWithRunner(DEFAULT_RUNNER, System.out, System.err, "", 0); + /** + * Create a RegistryVM instance on an ephemeral port. + * + * @return a RegistryVM instance + */ + public static RegistryVM createRegistryVM() { + return createRegistryVMWithRunner(DEFAULT_RUNNER, System.out, System.err, "", 0); } - public static REGISTRY createREGISTRY(OutputStream out, OutputStream err, - String options, int port) { - return createREGISTRYWithRunner(DEFAULT_RUNNER, out, err, options, port); + /** + * Create a RegistryVM instance on an ephemeral port with additional + * command line options. + * + * @param options command line options + * @return a RegistryVM instance + */ + public static RegistryVM createRegistryVM(String options) { + return createRegistryVMWithRunner( + DEFAULT_RUNNER, System.out, System.err, options, 0); } - public static REGISTRY createREGISTRYWithRunner(String runner, String options) { - return createREGISTRYWithRunner(runner, System.out, System.err, options, 0); + /** + * Create a RegistryVM instance on a specified port capturing stdout and + * stderr with additional command line options. + * + * @param out the OutputStream where the normal output of the + * registry subprocess goes + * @param err the OutputStream where the error output of the + * registry subprocess goes + * @param options the command line options + * @param port the port on which Registry accepts requests + * @return a RegistryVM instance + */ + public static RegistryVM createRegistryVM(OutputStream out, OutputStream err, + String options, int port) { + return createRegistryVMWithRunner(DEFAULT_RUNNER, out, err, options, port); } - public static REGISTRY createREGISTRYWithRunner(String runner, OutputStream out, + /** + * Create a RegistryVM instance on an ephemeral port with additional + * command line options and a specified runner. + * + * @param runner the runner class name + * @param options command line options + * @return a RegistryVM instance + */ + public static RegistryVM createRegistryVMWithRunner(String runner, String options) { + return createRegistryVMWithRunner(runner, System.out, System.err, options, 0); + } + + /** + * Create a RegistryVM instance on a specified port capturing stdout and + * stderr with additional command line options and a specified runner. + * + * @param runner the runner class name + * @param out the OutputStream where the normal output of the + * registry subprocess goes + * @param err the OutputStream where the error output of the + * registry subprocess goes + * @param options the command line options + * @param port the port on which Registry accepts requests + * @return a RegistryVM instance + */ + public static RegistryVM createRegistryVMWithRunner(String runner, OutputStream out, OutputStream err, String options, int port) { options += " --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED" + " --add-exports=java.rmi/sun.rmi.server=ALL-UNNAMED" + " --add-exports=java.rmi/sun.rmi.transport=ALL-UNNAMED" + " --add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"; - REGISTRY reg = new REGISTRY(runner, out, err, options, port); - return reg; + RegistryVM reg = new RegistryVM(runner, out, err, options, port); + reg.setPolicyFile(TestParams.defaultRegistryPolicy); + return reg; } /** * Starts the registry in a sub-process and waits up to * the given timeout period to confirm that it's running, * and get the port where it's running. + * + * @throws IOException if fails to start subprocess */ public void start() throws IOException { super.start(); @@ -96,6 +151,12 @@ public class REGISTRY extends JavaVM { if (port != -1) { break; } + try { + int exit = vm.exitValue(); + TestLibrary.bomb("[RegistryVM] registry sub-process exited with status " + + exit + "."); + } catch (IllegalThreadStateException ignore) { } + if (System.currentTimeMillis() > deadline) { TestLibrary.bomb("Failed to start registry, giving up after " + (System.currentTimeMillis() - startTime) + "ms.", null); @@ -106,12 +167,16 @@ public class REGISTRY extends JavaVM { /** * Shuts down the registry. */ - public void shutdown() { + @Override + public void cleanup() { RegistryRunner.requestExit(port); + super.destroy(); } /** * Gets the port where the registry is serving. + * + * @return the port where the registry is serving */ public int getPort() { return port; diff --git a/jdk/test/java/rmi/testlibrary/TestParams.java b/jdk/test/java/rmi/testlibrary/TestParams.java index 5f60efbd639..4b1f4d6e6e7 100644 --- a/jdk/test/java/rmi/testlibrary/TestParams.java +++ b/jdk/test/java/rmi/testlibrary/TestParams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -42,6 +42,9 @@ public class TestParams { /** name of default security policy for RMID */ public static final String defaultRmidPolicy; + /** name of default security policy for RegistryVM */ + public static final String defaultRegistryPolicy; + /** name of default security policy for activation groups */ public static final String defaultGroupPolicy; @@ -69,6 +72,9 @@ public class TestParams { defaultRmidPolicy = testSrc + File.separatorChar + "rmid.security.policy"; + defaultRegistryPolicy = + testSrc + File.separatorChar + "registry.security.policy"; + defaultGroupPolicy = testSrc + File.separatorChar + "group.security.policy"; diff --git a/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java b/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java index 9d700c4786b..295646cab5d 100644 --- a/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java +++ b/jdk/test/java/rmi/transport/dgcDeadLock/DGCDeadLock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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,7 @@ * java.rmi/sun.rmi.server * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp - * @build TestLibrary Test TestImpl REGISTRY RegistryRunner + * @build TestLibrary Test TestImpl RegistryVM RegistryRunner * @run main/othervm/policy=security.policy/timeout=360 DGCDeadLock */ @@ -68,21 +68,18 @@ public class DGCDeadLock implements Runnable { static public void main(String[] args) { - REGISTRY testImplVM = null; + RegistryVM testImplVM = null; System.err.println("\nregression test for 4118056\n"); TestLibrary.suggestSecurityManager("java.rmi.RMISecurityManager"); try { - String options = " -Djava.security.policy=" + - TestParams.defaultPolicy + - " --add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED" + + String options = " --add-opens java.rmi/sun.rmi.transport=ALL-UNNAMED" + " -Djava.rmi.dgc.leaseValue=500000" + " -Dsun.rmi.dgc.checkInterval=" + - (HOLD_TARGET_TIME - 5000) + - "" ; + (HOLD_TARGET_TIME - 5000); - testImplVM = REGISTRY.createREGISTRYWithRunner("TestImpl", options); + testImplVM = RegistryVM.createRegistryVMWithRunner("TestImpl", options); testImplVM.start(); registryPort = testImplVM.getPort(); @@ -107,7 +104,7 @@ public class DGCDeadLock implements Runnable { TestLibrary.bomb("test failed in main()", e); } finally { if (testImplVM != null) { - testImplVM.shutdown(); + testImplVM.cleanup(); testImplVM = null; } } diff --git a/jdk/test/java/rmi/transport/dgcDeadLock/registry.security.policy b/jdk/test/java/rmi/transport/dgcDeadLock/registry.security.policy new file mode 100644 index 00000000000..926d8787fd9 --- /dev/null +++ b/jdk/test/java/rmi/transport/dgcDeadLock/registry.security.policy @@ -0,0 +1,27 @@ +/* + * security policy used by the registry sub-process + */ + +grant { + // used by TestLibrary to determine extra commandline properties + permission java.io.FilePermission "..${/}..${/}test.props", "read"; + + // property specifically accessed by this test. + permission java.util.PropertyPermission "sun.rmi.transport.cleanInterval", "write"; + permission java.util.PropertyPermission "package.restrict.access.sun", "read"; + permission java.util.PropertyPermission "package.restrict.access.sun.rmi", "read"; + + // test needs to use java to exec an EchoImpl object + permission java.io.FilePermission "${java.home}${/}bin${/}java", "execute"; + + // used by TestLibrary to determine test environment + permission java.util.PropertyPermission "test.*", "read"; + permission java.util.PropertyPermission "user.dir", "read"; + permission java.util.PropertyPermission "java.home", "read"; + + permission java.util.PropertyPermission "java.security.policy", "read"; + permission java.util.PropertyPermission "java.security.manager", "read"; + + // test needs to export rmid and communicate with objects on arbitrary ports + permission java.net.SocketPermission "*:1024-", "connect,accept,listen"; +}; diff --git a/jdk/test/sun/rmi/transport/tcp/DeadCachedConnection.java b/jdk/test/sun/rmi/transport/tcp/DeadCachedConnection.java index cbc34f7687e..b63869ef2e3 100644 --- a/jdk/test/sun/rmi/transport/tcp/DeadCachedConnection.java +++ b/jdk/test/sun/rmi/transport/tcp/DeadCachedConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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,7 @@ * java.rmi/sun.rmi.server * java.rmi/sun.rmi.transport * java.rmi/sun.rmi.transport.tcp - * @build TestLibrary REGISTRY RegistryRunner + * @build TestLibrary RegistryVM RegistryRunner * @run main/othervm DeadCachedConnection */ @@ -100,7 +100,7 @@ public class DeadCachedConnection { public static int makeRegistry(int port) { try { - subreg = REGISTRY.createREGISTRY(System.out, System.err, "", port); + subreg = RegistryVM.createRegistryVM(System.out, System.err, "", port); subreg.start(); int regPort = subreg.getPort(); System.out.println("Starting registry on port " + regPort); @@ -113,11 +113,11 @@ public class DeadCachedConnection { return -1; } - private static REGISTRY subreg = null; + private static RegistryVM subreg = null; public static void killRegistry() throws InterruptedException { if (subreg != null) { - subreg.shutdown(); + subreg.cleanup(); subreg = null; } }