本文整理汇总了Java中com.sun.jdi.VirtualMachineManager类的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachineManager类的具体用法?Java VirtualMachineManager怎么用?Java VirtualMachineManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VirtualMachineManager类属于com.sun.jdi包,在下文中一共展示了VirtualMachineManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
private VirtualMachine connect(int port) throws IOException {
VirtualMachineManager manager = Bootstrap.virtualMachineManager();
// Find appropiate connector
List<AttachingConnector> connectors = manager.attachingConnectors();
AttachingConnector chosenConnector = null;
for (AttachingConnector c : connectors) {
if (c.transport().name().equals(TRANSPORT_NAME)) {
chosenConnector = c;
break;
}
}
if (chosenConnector == null) {
throw new IllegalStateException("Could not find socket connector");
}
// Set port argument
AttachingConnector connector = chosenConnector;
Map<String, Argument> defaults = connector.defaultArguments();
Argument arg = defaults.get(PORT_ARGUMENT_NAME);
if (arg == null) {
throw new IllegalStateException("Could not find port argument");
}
arg.setValue(Integer.toString(port));
// Attach
try {
System.out.println("Connector arguments: " + defaults);
return connector.attach(defaults);
} catch (IllegalConnectorArgumentsException e) {
throw new IllegalArgumentException("Illegal connector arguments", e);
}
}
示例2: createVirtualMachine
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
private VirtualMachine createVirtualMachine(Class vmImplClass,
String debugServerName)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
java.lang.reflect.Method connectByServerMethod =
vmImplClass.getMethod(
"createVirtualMachineForServer",
new Class[] {
VirtualMachineManager.class,
String.class,
Integer.TYPE
});
return (VirtualMachine) connectByServerMethod.invoke(null,
new Object[] {
Bootstrap.virtualMachineManager(),
debugServerName,
new Integer(0)
});
}
示例3: createVirtualMachine
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
private VirtualMachine createVirtualMachine(Class vmImplClass,
String javaExec, String corefile)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
"createVirtualMachineForCorefile",
new Class[] {
VirtualMachineManager.class,
String.class, String.class,
Integer.TYPE
});
return (VirtualMachine) connectByCoreMethod.invoke(null,
new Object[] {
Bootstrap.virtualMachineManager(),
javaExec,
corefile,
new Integer(0)
});
}
示例4: launch
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
/**
* Launch a debuggee in suspend mode.
* @see {@link #launch(VirtualMachineManager, String, String, String, String, String)}
*/
public static IDebugSession launch(VirtualMachineManager vmManager,
String mainClass,
String programArguments,
String vmArguments,
List<String> modulePaths,
List<String> classPaths,
String cwd,
String[] envVars)
throws IOException, IllegalConnectorArgumentsException, VMStartException {
return DebugUtility.launch(vmManager,
mainClass,
programArguments,
vmArguments,
String.join(File.pathSeparator, modulePaths),
String.join(File.pathSeparator, classPaths),
cwd,
envVars);
}
示例5: attach
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
public PermissionDebugger attach() throws IOException, IllegalConnectorArgumentsException {
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
List<AttachingConnector> connectors = vmm.attachingConnectors();
AttachingConnector connector =
connectors
.stream()
.filter(c -> c.transport().name().equals(transport))
.findFirst()
.orElseThrow(
() -> new IOException(String.format("Failed to find transport %s", transport)));
Map<String, Argument> map = connector.defaultArguments();
Argument portArg = map.get(PORT_KEY);
portArg.setValue(port);
map.put(PORT_KEY, portArg);
vm = connector.attach(map);
return this;
}
示例6: launch
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
protected VirtualMachine launch(String[] commandArray, String address,
TransportService.ListenKey listenKey,
TransportService ts)
throws IOException, VMStartException {
Helper helper = new Helper(commandArray, address, listenKey, ts);
helper.launchAndAccept();
VirtualMachineManager manager =
Bootstrap.virtualMachineManager();
return manager.createVirtualMachine(helper.connection(),
helper.process());
}
示例7: virtualMachineManager
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
public static VirtualMachineManager virtualMachineManager() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
JDIPermission vmmPermission =
new JDIPermission("virtualMachineManager");
sm.checkPermission(vmmPermission);
}
synchronized (lock) {
if (vmm == null) {
vmm = new VirtualMachineManagerImpl();
}
}
return vmm;
}
示例8: getVirtualMachineManager
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
@Override
public synchronized VirtualMachineManager getVirtualMachineManager() {
if (vmManager == null) {
vmManager = new AdvancedVirtualMachineManager();
}
return vmManager;
}
示例9: createVirtualMachine
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
private VirtualMachine createVirtualMachine(Class virtualMachineImplClass, int pid)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
java.lang.reflect.Method createByPIDMethod
= virtualMachineImplClass.getMethod("createVirtualMachineForPID",
new Class[] {
VirtualMachineManager.class,
Integer.TYPE, Integer.TYPE
});
return (VirtualMachine) createByPIDMethod.invoke(null,
new Object[] {
Bootstrap.virtualMachineManager(),
new Integer(pid),
new Integer(0)
});
}
示例10: test
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
@Test
public void test() {
VirtualMachineManager virtualMachineManager = Bootstrap.virtualMachineManager();
List<Connector> allConnectors = virtualMachineManager.allConnectors();
List<VirtualMachine> connectedVirtualMachines = virtualMachineManager.connectedVirtualMachines();
System.out.println(allConnectors);
System.out.println(connectedVirtualMachines);
}
示例11: getConnector
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
private AttachingConnector getConnector() {
VirtualMachineManager vmManager = Bootstrap.virtualMachineManager();
for (Connector connector : vmManager.attachingConnectors()) {
if ("com.sun.jdi.SocketAttach".equals(connector.name())) {
return (AttachingConnector) connector;
}
}
throw new IllegalStateException();
}
示例12: virtualMachineManager
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
public static VirtualMachineManager virtualMachineManager() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
JDIPermission vmmPermission =
new JDIPermission("virtualMachineManager");
sm.checkPermission(vmmPermission);
}
synchronized (lock) {
if (vmm == null) {
vmm = new F3VirtualMachineManager();
}
}
return vmm;
}
示例13: connect
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
private VirtualMachine connect(int port) throws IOException {
VirtualMachineManager manager = Bootstrap.virtualMachineManager();
// Find appropiate connector
List<AttachingConnector> connectors = manager.attachingConnectors();
AttachingConnector chosenConnector = null;
for (AttachingConnector c : connectors) {
if (c.transport().name().equals(TRANSPORT_NAME)) {
chosenConnector = c;
break;
}
}
if (chosenConnector == null) {
throw new IllegalStateException("Could not find socket connector");
}
// Set port argument
AttachingConnector connector = chosenConnector;
Map<String, Argument> defaults = connector.defaultArguments();
Argument arg = defaults.get(PORT_ARGUMENT_NAME);
if (arg == null) {
throw new IllegalStateException("Could not find port argument");
}
arg.setValue(Integer.toString(port));
// Attach
try {
System.out.println("Connector arguments: " + defaults);
return connector.attach(defaults);
} catch (IllegalConnectorArgumentsException e) {
throw new IllegalArgumentException("Illegal connector arguments", e);
}
}
示例14: getConnector
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
private AttachingConnector getConnector() {
VirtualMachineManager vmManager = Bootstrap
.virtualMachineManager();
for (AttachingConnector connector : vmManager
.attachingConnectors()) {
if ("com.sun.jdi.SocketAttach".equals(connector
.name())) {
return (AttachingConnector) connector;
}
}
throw new IllegalStateException();
}
示例15: attach
import com.sun.jdi.VirtualMachineManager; //导入依赖的package包/类
public static JPDASupport attach (String mainClass, String[] args, File[] classPath) throws IOException,
DebuggerStartException {
Process process = launchVM (mainClass, args, classPath, "", true);
String line = readLine (process.getInputStream ());
int port = Integer.parseInt (line.substring (line.lastIndexOf (':') + 1).trim ());
ProcessIO pio = new ProcessIO (process);
pio.go ();
VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
List aconnectors = vmm.attachingConnectors();
AttachingConnector connector = null;
for (Iterator i = aconnectors.iterator(); i.hasNext();) {
AttachingConnector ac = (AttachingConnector) i.next();
Transport t = ac.transport ();
if (t != null && t.name().equals("dt_socket")) {
connector = ac;
break;
}
}
if (connector == null)
throw new RuntimeException
("No attaching socket connector available");
JPDADebugger jpdaDebugger = JPDADebugger.attach (
"localhost",
port,
createServices ()
);
return new JPDASupport (jpdaDebugger);
}