--- old/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java 2016-08-19 22:19:39.699025558 -0700 +++ new/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java 2016-08-19 22:19:39.585022729 -0700 @@ -77,7 +77,7 @@ * @return the generator */ public static ExecutionControl.Generator launch() { - return env -> create(env, true); + return env -> create(env, true, false); } /** @@ -87,7 +87,17 @@ * @return the generator */ public static ExecutionControl.Generator listen() { - return env -> create(env, false); + return env -> create(env, false, false); + } + + /** + * Creates an ExecutionControl instance based on a JDI + * {@code ListeningConnector} connecting to "localhost". + * + * @return the generator + */ + public static ExecutionControl.Generator listenLocalhost() { + return env -> create(env, false, true); } /** @@ -100,10 +110,15 @@ * * @param env the context passed by * {@link jdk.jshell.spi.ExecutionControl#start(jdk.jshell.spi.ExecutionEnv) } + * @param isLaunch does JDI do the launch? That is, LaunchingConnector, + * otherwise we start explicitly and use ListeningConnector + * @param useLocalhost explicitly use "localhost" rather than discovered + * hostname, applies to listening only (!isLaunch) * @return the channel * @throws IOException if there are errors in set-up */ - private static JDIDefaultExecutionControl create(ExecutionEnv env, boolean isLaunch) throws IOException { + private static JDIDefaultExecutionControl create(ExecutionEnv env, + boolean isLaunch, boolean useLocalhost) throws IOException { try (final ServerSocket listener = new ServerSocket(0)) { // timeout after 60 seconds listener.setSoTimeout(60000); @@ -111,7 +126,7 @@ // Set-up the JDI connection JDIInitiator jdii = new JDIInitiator(port, - env.extraRemoteVMOptions(), REMOTE_AGENT, isLaunch); + env.extraRemoteVMOptions(), REMOTE_AGENT, isLaunch, useLocalhost); VirtualMachine vm = jdii.vm(); Process process = jdii.process();