44 * an external process. Designed to work with {@link JDIDefaultExecutionControl}.
45 *
46 * @author Jan Lahoda
47 * @author Robert Field
48 */
49 public class RemoteExecutionControl extends DirectExecutionControl implements ExecutionControl {
50
51 /**
52 * Launch the agent, connecting to the JShell-core over the socket specified
53 * in the command-line argument.
54 *
55 * @param args standard command-line arguments, expectation is the socket
56 * number is the only argument
57 * @throws Exception any unexpected exception
58 */
59 public static void main(String[] args) throws Exception {
60 String loopBack = null;
61 Socket socket = new Socket(loopBack, Integer.parseInt(args[0]));
62 InputStream inStream = socket.getInputStream();
63 OutputStream outStream = socket.getOutputStream();
64 Map<String, Consumer<OutputStream>> chans = new HashMap<>();
65 chans.put("out", st -> System.setOut(new PrintStream(st, true)));
66 chans.put("err", st -> System.setErr(new PrintStream(st, true)));
67 forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, chans);
68 }
69
70 // These three variables are used by the main JShell process in interrupting
71 // the running process. Access is via JDI, so the reference is not visible
72 // to code inspection.
73 private boolean inClientCode; // Queried by the main process (in superclass)
74 private boolean expectingStop; // Set by the main process
75 // Set by the main process
76
77 // thrown by the main process via JDI:
78 private final StopExecutionException stopException = new StopExecutionException();
79
80 /**
81 * Creates an instance, delegating loader operations to the specified
82 * delegate.
83 *
84 * @param loaderDelegate the delegate to handle loading classes
85 */
86 public RemoteExecutionControl(LoaderDelegate loaderDelegate) {
87 super(loaderDelegate);
|
44 * an external process. Designed to work with {@link JDIDefaultExecutionControl}.
45 *
46 * @author Jan Lahoda
47 * @author Robert Field
48 */
49 public class RemoteExecutionControl extends DirectExecutionControl implements ExecutionControl {
50
51 /**
52 * Launch the agent, connecting to the JShell-core over the socket specified
53 * in the command-line argument.
54 *
55 * @param args standard command-line arguments, expectation is the socket
56 * number is the only argument
57 * @throws Exception any unexpected exception
58 */
59 public static void main(String[] args) throws Exception {
60 String loopBack = null;
61 Socket socket = new Socket(loopBack, Integer.parseInt(args[0]));
62 InputStream inStream = socket.getInputStream();
63 OutputStream outStream = socket.getOutputStream();
64 Map<String, Consumer<OutputStream>> outputs = new HashMap<>();
65 outputs.put("out", st -> System.setOut(new PrintStream(st, true)));
66 outputs.put("err", st -> System.setErr(new PrintStream(st, true)));
67 Map<String, Consumer<InputStream>> input = new HashMap<>();
68 input.put("in", st -> System.setIn(st));
69 forwardExecutionControlAndIO(new RemoteExecutionControl(), inStream, outStream, outputs, input);
70 }
71
72 // These three variables are used by the main JShell process in interrupting
73 // the running process. Access is via JDI, so the reference is not visible
74 // to code inspection.
75 private boolean inClientCode; // Queried by the main process (in superclass)
76 private boolean expectingStop; // Set by the main process
77 // Set by the main process
78
79 // thrown by the main process via JDI:
80 private final StopExecutionException stopException = new StopExecutionException();
81
82 /**
83 * Creates an instance, delegating loader operations to the specified
84 * delegate.
85 *
86 * @param loaderDelegate the delegate to handle loading classes
87 */
88 public RemoteExecutionControl(LoaderDelegate loaderDelegate) {
89 super(loaderDelegate);
|