Java Code Examples for com.sun.jdi.connect.Connector#Argument
The following examples show how to use
com.sun.jdi.connect.Connector#Argument .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChildSession.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example 2
Source File: FieldMonitor.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 3
Source File: LaunchUtilities.java From codewind-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @return argsToConfigure updated with the new arguments. */ public static Map<String, Connector.Argument> configureConnector( Map<String, Connector.Argument> argsToConfigure, String host, int portNumber) { Connector.StringArgument hostArg = (Connector.StringArgument) argsToConfigure.get("hostname"); //$NON-NLS-1$ hostArg.setValue(host); Connector.IntegerArgument portArg = (Connector.IntegerArgument) argsToConfigure.get("port"); //$NON-NLS-1$ portArg.setValue(portNumber); Connector.IntegerArgument timeoutArg = (Connector.IntegerArgument) argsToConfigure.get("timeout"); //$NON-NLS-1$ if (timeoutArg != null) { int timeout = Platform.getPreferencesService().getInt( "org.eclipse.jdt.launching", //$NON-NLS-1$ JavaRuntime.PREF_CONNECT_TIMEOUT, JavaRuntime.DEF_CONNECT_TIMEOUT, null); timeoutArg.setValue(timeout); } return argsToConfigure; }
Example 4
Source File: ChildSession.java From hottub with GNU General Public License v2.0 | 6 votes |
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; }
Example 5
Source File: FieldMonitor.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 6
Source File: ChildSession.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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; }
Example 7
Source File: AcceptTimeout.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors(); for (ListeningConnector lc: connectors) { Map<String,Connector.Argument> cargs = lc.defaultArguments(); Connector.IntegerArgument timeout = (Connector.IntegerArgument)cargs.get("timeout"); /* * If the Connector has a argument named "timeout" then we set the timeout to 1 second * and start it listening on its default address. It should throw TranpsortTimeoutException. */ if (timeout != null) { System.out.println("Testing " + lc.name()); timeout.setValue(1000); System.out.println("Listening on: " + lc.startListening(cargs)); try { lc.accept(cargs); throw new RuntimeException("Connection accepted from some debuggee - unexpected!"); } catch (TransportTimeoutException e) { System.out.println("Timed out as expected.\n"); } lc.stopListening(cargs); } } }
Example 8
Source File: ChildSession.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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); }
Example 9
Source File: ChildSession.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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); }
Example 10
Source File: ChildSession.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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); }
Example 11
Source File: Commands.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void commandConnectors(VirtualMachineManager vmm) { Collection<Connector> ccs = vmm.allConnectors(); if (ccs.isEmpty()) { MessageOutput.println("Connectors available"); } for (Connector cc : ccs) { String transportName = cc.transport() == null ? "null" : cc.transport().name(); MessageOutput.println(); MessageOutput.println("Connector and Transport name", new Object [] {cc.name(), transportName}); MessageOutput.println("Connector description", cc.description()); for (Connector.Argument aa : cc.defaultArguments().values()) { MessageOutput.println(); boolean requiredArgument = aa.mustSpecify(); if (aa.value() == null || aa.value() == "") { //no current value and no default. MessageOutput.println(requiredArgument ? "Connector required argument nodefault" : "Connector argument nodefault", aa.name()); } else { MessageOutput.println(requiredArgument ? "Connector required argument default" : "Connector argument default", new Object [] {aa.name(), aa.value()}); } MessageOutput.println("Connector description", aa.description()); } } }
Example 12
Source File: SimpleLaunchingConnector.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws IOException, IllegalConnectorArgumentsException, VMStartException { /* * Get the class name that we are to execute */ String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value(); if (className.length() == 0) { throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME); } /* * Listen on an emperical port; launch the debuggee; wait for * for the debuggee to connect; stop listening; */ TransportService.ListenKey key = ts.startListening(); String exe = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" + key.address() + " -classpath " + System.getProperty("test.classes") + " " + className; Process process = Runtime.getRuntime().exec(cmd); Connection conn = ts.accept(key, 30*1000, 9*1000); ts.stopListening(key); /* * Debugee is connected - return the virtual machine mirror */ return Bootstrap.virtualMachineManager().createVirtualMachine(conn); }
Example 13
Source File: SimpleLaunchingConnector.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public VirtualMachine launch(Map<String, ? extends Connector.Argument> arguments) throws IOException, IllegalConnectorArgumentsException, VMStartException { /* * Get the class name that we are to execute */ String className = ((StringArgumentImpl)arguments.get(ARG_NAME)).value(); if (className.length() == 0) { throw new IllegalConnectorArgumentsException("class name missing", ARG_NAME); } /* * Listen on an emperical port; launch the debuggee; wait for * for the debuggee to connect; stop listening; */ TransportService.ListenKey key = ts.startListening(); String exe = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; String cmd = exe + " -Xdebug -Xrunjdwp:transport=dt_socket,timeout=15000,address=" + key.address() + " -classpath " + System.getProperty("test.classes") + " " + className; Process process = Runtime.getRuntime().exec(cmd); Connection conn = ts.accept(key, 30*1000, 9*1000); ts.stopListening(key); /* * Debugee is connected - return the virtual machine mirror */ return Bootstrap.virtualMachineManager().createVirtualMachine(conn); }
Example 14
Source File: ChildSession.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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); }
Example 15
Source File: ProcessAttachDebugger.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String main_args[]) throws Exception { String pid = main_args[0]; // find ProcessAttachingConnector List<AttachingConnector> l = Bootstrap.virtualMachineManager().attachingConnectors(); AttachingConnector ac = null; for (AttachingConnector c: l) { if (c.name().equals("com.sun.jdi.ProcessAttach")) { ac = c; break; } } if (ac == null) { throw new RuntimeException("Unable to locate ProcessAttachingConnector"); } Map<String,Connector.Argument> args = ac.defaultArguments(); Connector.StringArgument arg = (Connector.StringArgument)args.get("pid"); arg.setValue(pid); System.out.println("Debugger is attaching to: " + pid + " ..."); VirtualMachine vm = ac.attach(args); System.out.println("Attached! Now listing threads ..."); // list all threads for (ThreadReference thr: vm.allThreads()) { System.out.println(thr); } System.out.println("Debugger done."); }
Example 16
Source File: ProcessAttachDebugger.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String main_args[]) throws Exception { String pid = main_args[0]; // find ProcessAttachingConnector List<AttachingConnector> l = Bootstrap.virtualMachineManager().attachingConnectors(); AttachingConnector ac = null; for (AttachingConnector c: l) { if (c.name().equals("com.sun.jdi.ProcessAttach")) { ac = c; break; } } if (ac == null) { throw new RuntimeException("Unable to locate ProcessAttachingConnector"); } Map<String,Connector.Argument> args = ac.defaultArguments(); Connector.StringArgument arg = (Connector.StringArgument)args.get("pid"); arg.setValue(pid); System.out.println("Debugger is attaching to: " + pid + " ..."); VirtualMachine vm = ac.attach(args); System.out.println("Attached! Now listing threads ..."); // list all threads for (ThreadReference thr: vm.allThreads()) { System.out.println(thr); } System.out.println("Debugger done."); }
Example 17
Source File: ChildSession.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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); }
Example 18
Source File: Commands.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
void commandConnectors(VirtualMachineManager vmm) { Collection<Connector> ccs = vmm.allConnectors(); if (ccs.isEmpty()) { MessageOutput.println("Connectors available"); } for (Connector cc : ccs) { String transportName = cc.transport() == null ? "null" : cc.transport().name(); MessageOutput.println(); MessageOutput.println("Connector and Transport name", new Object [] {cc.name(), transportName}); MessageOutput.println("Connector description", cc.description()); for (Connector.Argument aa : cc.defaultArguments().values()) { MessageOutput.println(); boolean requiredArgument = aa.mustSpecify(); if (aa.value() == null || aa.value() == "") { //no current value and no default. MessageOutput.println(requiredArgument ? "Connector required argument nodefault" : "Connector argument nodefault", aa.name()); } else { MessageOutput.println(requiredArgument ? "Connector required argument default" : "Connector argument default", new Object [] {aa.name(), aa.value()}); } MessageOutput.println("Connector description", aa.description()); } } }
Example 19
Source File: ChildSession.java From hottub with GNU General Public License v2.0 | 5 votes |
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); }
Example 20
Source File: Commands.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void commandConnectors(VirtualMachineManager vmm) { Collection<Connector> ccs = vmm.allConnectors(); if (ccs.isEmpty()) { MessageOutput.println("Connectors available"); } for (Connector cc : ccs) { String transportName = cc.transport() == null ? "null" : cc.transport().name(); MessageOutput.println(); MessageOutput.println("Connector and Transport name", new Object [] {cc.name(), transportName}); MessageOutput.println("Connector description", cc.description()); for (Connector.Argument aa : cc.defaultArguments().values()) { MessageOutput.println(); boolean requiredArgument = aa.mustSpecify(); if (aa.value() == null || aa.value() == "") { //no current value and no default. MessageOutput.println(requiredArgument ? "Connector required argument nodefault" : "Connector argument nodefault", aa.name()); } else { MessageOutput.println(requiredArgument ? "Connector required argument default" : "Connector argument default", new Object [] {aa.name(), aa.value()}); } MessageOutput.println("Connector description", aa.description()); } } }