/** * Return the launching connector's arguments. */ static Map <String,Connector.Argument> connectorArguments(LaunchingConnector connector, String mainArgs) { Map<String,Connector.Argument> arguments = connector.defaultArguments(); for (String key : arguments.keySet()) { System.out.println(key); } Connector.Argument mainArg = (Connector.Argument)arguments.get("main"); if (mainArg == null) { throw new Error("Bad launching connector"); } mainArg.setValue(mainArgs); Connector.Argument optionsArg = (Connector.Argument)arguments.get("options"); if (optionsArg == null) { throw new Error("Bad launching connector"); } optionsArg.setValue(ARGUMENTS); return arguments; }
static private VirtualMachine generalGetVM(OutputListener diagnostics, LaunchingConnector connector, Map<String, Connector.Argument> arguments) { VirtualMachine vm = null; try { diagnostics.putString("Starting child."); vm = connector.launch(arguments); } catch (IOException ioe) { diagnostics.putString("Unable to start child: " + ioe.getMessage()); } catch (IllegalConnectorArgumentsException icae) { diagnostics.putString("Unable to start child: " + icae.getMessage()); } catch (VMStartException vmse) { diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n'); dumpFailedLaunchInfo(diagnostics, vmse.process()); } return vm; }
/** * Return the launching connector's arguments. */ static Map <String,Connector.Argument> connectorArguments(LaunchingConnector connector, String mainArgs) { Map<String,Connector.Argument> arguments = connector.defaultArguments(); Connector.Argument mainArg = (Connector.Argument)arguments.get("main"); if (mainArg == null) { throw new Error("Bad launching connector"); } mainArg.setValue(mainArgs); Connector.Argument optionsArg = (Connector.Argument)arguments.get("options"); if (optionsArg == null) { throw new Error("Bad launching connector"); } optionsArg.setValue(ARGUMENTS); return arguments; }
private LaunchingDICookie ( LaunchingConnector launchingConnector, Map<String, ? extends Argument> args, String mainClassName, boolean suspend ) { this.launchingConnector = launchingConnector; this.args = args; this.mainClassName = mainClassName; this.suspend = suspend; }
private static LaunchingConnector findLaunchingConnector () { Iterator<LaunchingConnector> iter = Bootstrap.virtualMachineManager (). launchingConnectors ().iterator (); while (iter.hasNext ()) { LaunchingConnector lc = iter.next (); if (lc.name ().indexOf ("RawCommandLineLaunch") > -1) return lc; } return null; }
public ChildSession(ExecutionManager runtime, LaunchingConnector connector, Map<String, Connector.Argument> arguments, InputListener input, OutputListener output, OutputListener error, OutputListener diagnostics) { this(runtime, generalGetVM(diagnostics, connector, arguments), input, output, error, diagnostics); }
static private VirtualMachine getVM(OutputListener diagnostics, String userVMArgs, String cmdLine) { VirtualMachineManager manager = Bootstrap.virtualMachineManager(); LaunchingConnector connector = manager.defaultConnector(); Map<String, Connector.Argument> arguments = connector.defaultArguments(); arguments.get("options").setValue(userVMArgs); arguments.get("main").setValue(cmdLine); return generalGetVM(diagnostics, connector, arguments); }
/** * Find a com.sun.jdi.CommandLineLaunch connector */ static LaunchingConnector findLaunchingConnector() { List <Connector> connectors = Bootstrap.virtualMachineManager().allConnectors(); Iterator <Connector> iter = connectors.iterator(); while (iter.hasNext()) { Connector connector = iter.next(); if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) { return (LaunchingConnector)connector; } } throw new Error("No launching connector"); }
private VirtualMachine launchTarget() { LaunchingConnector launcher = (LaunchingConnector) connector; try { VirtualMachine new_vm = timedVirtualMachineCreation(() -> launcher.launch(connectorArgs), null); process = new_vm.process(); return new_vm; } catch (Throwable ex) { throw reportLaunchFail(ex, "launch"); } }
@Override public List<LaunchingConnector> launchingConnectors() { List<LaunchingConnector> connectors = new ArrayList<>(); connectors.add(new AdvancedLaunchingConnector(this)); connectors.addAll(super.launchingConnectors()); return connectors; }
private static LaunchingConnector makePlatformConnector() { Class connectorClass = null; try { connectorClass = Class.forName(RAW_COMMANDLINE_LAUNCHER); } catch (ClassNotFoundException cnfe) { } if (connectorClass == null) { throw new RuntimeException("can not load class: " + RAW_COMMANDLINE_LAUNCHER); } try { return (LaunchingConnector) connectorClass.newInstance(); } catch (Exception exp) { throw new RuntimeException(exp); } }
private static LaunchingConnector makePlatformConnector() { Class connectorClass = null; try { connectorClass = Class.forName(SUN_COMMANDLINE_LAUNCHER); } catch (ClassNotFoundException cnfe) { } if (connectorClass == null) { throw new RuntimeException("can not load class: " + SUN_COMMANDLINE_LAUNCHER); } try { return (LaunchingConnector) connectorClass.newInstance(); } catch (Exception exp) { throw new RuntimeException(exp); } }