提交 42e48ae0 编写于 作者: R rfield

8161983: JShell API: Clean-up following 8160127 et. al.

Reviewed-by: jlahoda
上级 286708d0
......@@ -47,7 +47,7 @@ import java.util.function.Supplier;
import java.util.stream.Stream;
import jdk.internal.jshell.debug.InternalDebugControl;
import jdk.jshell.Snippet.Status;
import jdk.jshell.execution.JDIDefaultExecutionControl;
import jdk.jshell.execution.JdiDefaultExecutionControl;
import jdk.jshell.spi.ExecutionControl.EngineTerminationException;
import jdk.jshell.spi.ExecutionControl.ExecutionControlException;
import jdk.jshell.spi.ExecutionEnv;
......@@ -117,10 +117,9 @@ public class JShell implements AutoCloseable {
this.extraRemoteVMOptions = b.extraRemoteVMOptions;
this.extraCompilerOptions = b.extraCompilerOptions;
this.executionControlGenerator = b.executionControlGenerator==null
? failOverExecutionControlGenerator(
JDIDefaultExecutionControl.launch(),
JDIDefaultExecutionControl.listen("localhost"),
JDIDefaultExecutionControl.listen(null))
? failOverExecutionControlGenerator(JdiDefaultExecutionControl.launch(),
JdiDefaultExecutionControl.listen("localhost"),
JdiDefaultExecutionControl.listen(null))
: b.executionControlGenerator;
this.maps = new SnippetMaps(this);
......
......@@ -60,7 +60,7 @@ import static jdk.jshell.execution.Util.remoteInputOutput;
* @author Robert Field
* @author Jan Lahoda
*/
public class JDIDefaultExecutionControl extends JDIExecutionControl {
public class JdiDefaultExecutionControl extends JdiExecutionControl {
private static final String REMOTE_AGENT = RemoteExecutionControl.class.getName();
......@@ -117,14 +117,14 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl {
int port = listener.getLocalPort();
// Set-up the JDI connection
JDIInitiator jdii = new JDIInitiator(port,
JdiInitiator jdii = new JdiInitiator(port,
env.extraRemoteVMOptions(), REMOTE_AGENT, isLaunch, host);
VirtualMachine vm = jdii.vm();
Process process = jdii.process();
List<Consumer<String>> deathListeners = new ArrayList<>();
deathListeners.add(s -> env.closeDown());
Util.detectJDIExitEvent(vm, s -> {
Util.detectJdiExitEvent(vm, s -> {
for (Consumer<String> h : deathListeners) {
h.accept(s);
}
......@@ -140,7 +140,7 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl {
outputs.put("err", env.userErr());
Map<String, InputStream> input = new HashMap<>();
input.put("in", env.userIn());
return remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new JDIDefaultExecutionControl(objOut, objIn, vm, process, deathListeners));
return remoteInputOutput(socket.getInputStream(), out, outputs, input, (objIn, objOut) -> new JdiDefaultExecutionControl(objOut, objIn, vm, process, deathListeners));
}
}
......@@ -150,7 +150,7 @@ public class JDIDefaultExecutionControl extends JDIExecutionControl {
* @param cmdout the output for commands
* @param cmdin the input for responses
*/
private JDIDefaultExecutionControl(ObjectOutput cmdout, ObjectInput cmdin,
private JdiDefaultExecutionControl(ObjectOutput cmdout, ObjectInput cmdin,
VirtualMachine vm, Process process, List<Consumer<String>> deathListeners) {
super(cmdout, cmdin);
this.vm = vm;
......
......@@ -34,7 +34,7 @@ import com.sun.jdi.event.*;
* Adapted from jdb EventHandler.
* Only exit and disconnect events processed.
*/
class JDIEventHandler implements Runnable {
class JdiEventHandler implements Runnable {
private final Thread thread;
private volatile boolean connected = true;
......@@ -49,7 +49,7 @@ class JDIEventHandler implements Runnable {
* @param reportVMExit callback to report exit/disconnect
* (passed true if the VM has died)
*/
JDIEventHandler(VirtualMachine vm, Consumer<String> reportVMExit) {
JdiEventHandler(VirtualMachine vm, Consumer<String> reportVMExit) {
this.vm = vm;
this.reportVMExit = reportVMExit;
this.thread = new Thread(this, "event-handler");
......
......@@ -39,7 +39,7 @@ import static java.util.stream.Collectors.toMap;
/**
* Abstract JDI implementation of {@link jdk.jshell.spi.ExecutionControl}
*/
public abstract class JDIExecutionControl extends StreamingExecutionControl implements ExecutionControl {
public abstract class JdiExecutionControl extends StreamingExecutionControl implements ExecutionControl {
/**
* Mapping from class names to JDI {@link ReferenceType}.
......@@ -51,7 +51,7 @@ public abstract class JDIExecutionControl extends StreamingExecutionControl impl
* @param out the output from the remote agent
* @param in the input to the remote agent
*/
protected JDIExecutionControl(ObjectOutput out, ObjectInput in) {
protected JdiExecutionControl(ObjectOutput out, ObjectInput in) {
super(out, in);
}
......
......@@ -40,7 +40,7 @@ import com.sun.jdi.connect.ListeningConnector;
* Sets up a JDI connection, providing the resulting JDI {@link VirtualMachine}
* and the {@link Process} the remote agent is running in.
*/
public class JDIInitiator {
public class JdiInitiator {
private VirtualMachine vm;
private Process process = null;
......@@ -59,7 +59,7 @@ public class JDIInitiator {
* @param host explicit hostname to use, if null use discovered
* hostname, applies to listening only (!isLaunch)
*/
public JDIInitiator(int port, List<String> remoteVMOptions, String remoteAgent,
public JdiInitiator(int port, List<String> remoteVMOptions, String remoteAgent,
boolean isLaunch, String host) {
this.remoteAgent = remoteAgent;
String connectorName
......
......@@ -41,7 +41,7 @@ import static jdk.jshell.execution.Util.forwardExecutionControlAndIO;
* process). This agent loads code over a socket from the main JShell process,
* executes the code, and other misc, Specialization of
* {@link DirectExecutionControl} which adds stop support controlled by
* an external process. Designed to work with {@link JDIDefaultExecutionControl}.
* an external process. Designed to work with {@link JdiDefaultExecutionControl}.
*
* @author Jan Lahoda
* @author Robert Field
......
......@@ -239,9 +239,9 @@ public class Util {
* @param unbiddenExitHandler the handler, which will accept the exit
* information
*/
public static void detectJDIExitEvent(VirtualMachine vm, Consumer<String> unbiddenExitHandler) {
public static void detectJdiExitEvent(VirtualMachine vm, Consumer<String> unbiddenExitHandler) {
if (vm.canBeModified()) {
new JDIEventHandler(vm, unbiddenExitHandler).start();
new JdiEventHandler(vm, unbiddenExitHandler).start();
}
}
......
......@@ -44,12 +44,13 @@ import java.io.Serializable;
* To install an {@code ExecutionControl}, its {@code Generator} is passed to
* {@link jdk.jshell.JShell.Builder#executionEngine(ExecutionControl.Generator) }.
*/
public interface ExecutionControl {
public interface ExecutionControl extends AutoCloseable {
/**
* Defines a functional interface for creating {@link ExecutionControl}
* instances.
*/
@FunctionalInterface
public interface Generator {
/**
......
......@@ -33,7 +33,7 @@
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import jdk.jshell.execution.JDIDefaultExecutionControl;
import jdk.jshell.execution.JdiDefaultExecutionControl;
import jdk.jshell.spi.ExecutionControl;
import jdk.jshell.spi.ExecutionEnv;
import static jdk.jshell.execution.Util.failOverExecutionControlGenerator;
......@@ -47,7 +47,7 @@ public class FailOverExecutionControlTest extends ExecutionControlTestBase {
setUp(builder -> builder.executionEngine(failOverExecutionControlGenerator(
new AlwaysFailingGenerator(),
new AlwaysFailingGenerator(),
JDIDefaultExecutionControl.launch())));
JdiDefaultExecutionControl.launch())));
}
class AlwaysFailingGenerator implements ExecutionControl.Generator {
......
......@@ -27,20 +27,20 @@
* @summary Tests for standard JDI connector (without failover) -- launching
* @modules jdk.jshell/jdk.jshell.execution
* @build KullaTesting ExecutionControlTestBase
* @run testng JDILaunchingExecutionControlTest
* @run testng JdiLaunchingExecutionControlTest
*/
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import jdk.jshell.execution.JDIDefaultExecutionControl;
import jdk.jshell.execution.JdiDefaultExecutionControl;
@Test
public class JDILaunchingExecutionControlTest extends ExecutionControlTestBase {
public class JdiLaunchingExecutionControlTest extends ExecutionControlTestBase {
@BeforeMethod
@Override
public void setUp() {
setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.launch()));
setUp(builder -> builder.executionEngine(JdiDefaultExecutionControl.launch()));
}
}
......@@ -27,20 +27,20 @@
* @summary Tests for alternate JDI connector -- listening
* @modules jdk.jshell/jdk.jshell.execution
* @build KullaTesting ExecutionControlTestBase
* @run testng JDIListeningExecutionControlTest
* @run testng JdiListeningExecutionControlTest
*/
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import jdk.jshell.execution.JDIDefaultExecutionControl;
import jdk.jshell.execution.JdiDefaultExecutionControl;
@Test
public class JDIListeningExecutionControlTest extends ExecutionControlTestBase {
public class JdiListeningExecutionControlTest extends ExecutionControlTestBase {
@BeforeMethod
@Override
public void setUp() {
setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen(null)));
setUp(builder -> builder.executionEngine(JdiDefaultExecutionControl.listen(null)));
}
}
......@@ -27,20 +27,20 @@
* @summary Tests for alternate JDI connector -- listening to "localhost"
* @modules jdk.jshell/jdk.jshell.execution
* @build KullaTesting ExecutionControlTestBase
* @run testng JDIListeningLocalhostExecutionControlTest
* @run testng JdiListeningLocalhostExecutionControlTest
*/
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import jdk.jshell.execution.JDIDefaultExecutionControl;
import jdk.jshell.execution.JdiDefaultExecutionControl;
@Test
public class JDIListeningLocalhostExecutionControlTest extends ExecutionControlTestBase {
public class JdiListeningLocalhostExecutionControlTest extends ExecutionControlTestBase {
@BeforeMethod
@Override
public void setUp() {
setUp(builder -> builder.executionEngine(JDIDefaultExecutionControl.listen("localhost")));
setUp(builder -> builder.executionEngine(JdiDefaultExecutionControl.listen("localhost")));
}
}
......@@ -26,7 +26,7 @@
* @bug 8160128 8159935
* @summary Tests for Aux channel, custom remote agents, custom JDI implementations.
* @build KullaTesting ExecutionControlTestBase
* @run testng UserJDIUserRemoteTest
* @run testng UserJdiUserRemoteTest
*/
import java.io.ByteArrayOutputStream;
import org.testng.annotations.Test;
......@@ -44,8 +44,8 @@ import com.sun.jdi.VMDisconnectedException;
import com.sun.jdi.VirtualMachine;
import jdk.jshell.VarSnippet;
import jdk.jshell.execution.DirectExecutionControl;
import jdk.jshell.execution.JDIExecutionControl;
import jdk.jshell.execution.JDIInitiator;
import jdk.jshell.execution.JdiExecutionControl;
import jdk.jshell.execution.JdiInitiator;
import jdk.jshell.execution.Util;
import java.io.InputStream;
import java.io.OutputStream;
......@@ -64,7 +64,7 @@ import static jdk.jshell.execution.Util.forwardExecutionControlAndIO;
import static jdk.jshell.execution.Util.remoteInputOutput;
@Test
public class UserJDIUserRemoteTest extends ExecutionControlTestBase {
public class UserJdiUserRemoteTest extends ExecutionControlTestBase {
ExecutionControl currentEC;
ByteArrayOutputStream auxStream;
......@@ -115,7 +115,7 @@ public class UserJDIUserRemoteTest extends ExecutionControlTestBase {
}
}
class MyExecutionControl extends JDIExecutionControl {
class MyExecutionControl extends JdiExecutionControl {
private static final String REMOTE_AGENT = MyRemoteExecutionControl.class.getName();
......@@ -128,7 +128,7 @@ class MyExecutionControl extends JDIExecutionControl {
*
* @return the generator
*/
public static ExecutionControl.Generator create(UserJDIUserRemoteTest test) {
public static ExecutionControl.Generator create(UserJdiUserRemoteTest test) {
return env -> make(env, test);
}
......@@ -145,7 +145,7 @@ class MyExecutionControl extends JDIExecutionControl {
* @return the channel
* @throws IOException if there are errors in set-up
*/
static ExecutionControl make(ExecutionEnv env, UserJDIUserRemoteTest test) throws IOException {
static ExecutionControl make(ExecutionEnv env, UserJdiUserRemoteTest test) throws IOException {
try (final ServerSocket listener = new ServerSocket(0)) {
// timeout after 60 seconds
listener.setSoTimeout(60000);
......@@ -157,14 +157,14 @@ class MyExecutionControl extends JDIExecutionControl {
opts.add(System.getProperty("java.class.path")
+ System.getProperty("path.separator")
+ System.getProperty("user.dir"));
JDIInitiator jdii = new JDIInitiator(port,
JdiInitiator jdii = new JdiInitiator(port,
opts, REMOTE_AGENT, true, null);
VirtualMachine vm = jdii.vm();
Process process = jdii.process();
List<Consumer<String>> deathListeners = new ArrayList<>();
deathListeners.add(s -> env.closeDown());
Util.detectJDIExitEvent(vm, s -> {
Util.detectJdiExitEvent(vm, s -> {
for (Consumer<String> h : deathListeners) {
h.accept(s);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册