1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.util.Map; 25 import java.util.logging.Level; 26 import java.util.logging.Logger; 27 import jdk.jshell.JShell; 28 import jdk.jshell.execution.JdiExecutionControlProvider; 29 import jdk.jshell.execution.RemoteExecutionControl; 30 import jdk.jshell.spi.ExecutionControlProvider; 31 32 class DyingRemoteAgent extends RemoteExecutionControl { 33 34 static final boolean INFRA_VERIFY = false; 35 main(String[] args)36 public static void main(String[] args) throws Exception { 37 if (INFRA_VERIFY) { 38 RemoteExecutionControl.main(args); 39 } else { 40 System.exit(1); 41 } 42 } 43 state(boolean isLaunch, String host)44 static JShell state(boolean isLaunch, String host) { 45 ExecutionControlProvider ecp = new JdiExecutionControlProvider(); 46 Map<String,String> pm = ecp.defaultParameters(); 47 pm.put(JdiExecutionControlProvider.PARAM_REMOTE_AGENT, DyingRemoteAgent.class.getName()); 48 pm.put(JdiExecutionControlProvider.PARAM_HOST_NAME, host==null? "" : host); 49 pm.put(JdiExecutionControlProvider.PARAM_LAUNCH, ""+isLaunch); 50 // turn on logging of launch failures 51 Logger.getLogger("jdk.jshell.execution").setLevel(Level.ALL); 52 return JShell.builder() 53 .executionEngine(ecp, pm) 54 .build(); 55 } 56 } 57