@Override public void close() throws IOException { if (hPipe != -1) { WindowsVirtualMachine.closePipe(hPipe); hPipe = -1; } } }
@Override public void detach() throws IOException { synchronized (this) { if (hProcess != -1) { closeProcess(hProcess); hProcess = -1; } } }
public WindowsVirtualMachine(AttachProvider provider, String id) throws IOException { super(provider, id); int pid = Integer.parseInt(id); hProcess = openProcess(pid); }
long hPipe = createPipe(pipeName); closePipe(hPipe); throw new IOException("Detached from target VM"); enqueue(hProcess, stub, cmd, pipeName, args); connectPipe(hPipe); int status = readInt(is); closePipe(hPipe); throw ioe;
@SuppressWarnings({"UseOfSunClasses"}) private VirtualMachine getVirtualMachineImplementationFromEmbeddedOnes() { try { if (File.separatorChar == '\\') { return new WindowsVirtualMachine(ATTACH_PROVIDER, pid); } else { return new LinuxVirtualMachine(ATTACH_PROVIDER, pid); } } catch (AttachNotSupportedException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } catch (UnsatisfiedLinkError ignore) { //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException throw new IllegalStateException( "Unable to load Java agent; please add lib/tools.jar from your JDK to the classpath"); } }
public WindowsVirtualMachine(AttachProvider provider, String id) throws AttachNotSupportedException, IOException { super(provider, id); int pid; try { pid = Integer.parseInt(id); } catch (NumberFormatException x) { throw new AttachNotSupportedException("Invalid process identifier"); } hProcess = openProcess(pid); // The target VM might be a pre-6.0 VM so we enqueue a "null" command // which minimally tests that the enqueue function exists in the target // VM. try { enqueue(hProcess, stub, null, null); } catch (IOException x) { throw new AttachNotSupportedException(x.getMessage()); } }
@Override public synchronized int read(byte[] bs, int off, int len) throws IOException { if (off < 0 || off > bs.length || len < 0 || off + len > bs.length || off + len < 0) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } return readPipe(hPipe, bs, off, len); }
long hPipe = createPipe(pipename); closePipe(hPipe); throw new IOException("Detached from target VM"); enqueue(hProcess, stub, cmd, pipename, args); connectPipe(hPipe); int status = readInt(is); if (status != 0) { closePipe(hPipe); throw ioe;
private static VirtualMachine getVirtualMachineImplementationFromEmbeddedOnes(String pid) { try { if (isWindows()) { return new WindowsVirtualMachine(ATTACH_PROVIDER, pid); } String osName = System.getProperty("os.name"); if (osName.startsWith("Linux") || osName.startsWith("LINUX")) { return new LinuxVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Mac OS X")) { return new BsdVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Solaris")) { return new SolarisVirtualMachine(ATTACH_PROVIDER, pid); } } catch (AttachNotSupportedException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } catch (UnsatisfiedLinkError e) { throw new IllegalStateException("Native library for Attach API not available in this JRE", e); } return null; }
@Override public synchronized int read(byte[] bs, int off, int len) throws IOException { if ((off < 0) || (off > bs.length) || (len < 0) || ((off + len) > bs.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) return 0; return WindowsVirtualMachine.readPipe(hPipe, bs, off, len); }
private static VirtualMachine getVirtualMachineImplementationFromEmbeddedOnes(String pid) { try { if (isWindows()) { return new WindowsVirtualMachine(ATTACH_PROVIDER, pid); } String osName = System.getProperty("os.name"); if (osName.startsWith("Linux") || osName.startsWith("LINUX")) { return new LinuxVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Mac OS X")) { return new BsdVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Solaris")) { return new SolarisVirtualMachine(ATTACH_PROVIDER, pid); } } catch (AttachNotSupportedException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } catch (UnsatisfiedLinkError e) { throw new IllegalStateException("Native library for Attach API not available in this JRE", e); } return null; }
@Override public void detach() throws IOException { synchronized (this) { if (hProcess != -1) { closeProcess(hProcess); hProcess = -1; } } }
@Override public void close() throws IOException { if (hPipe != -1) { closePipe(hPipe); hPipe = -1; } } }
private static VirtualMachine getVirtualMachineImplementationFromEmbeddedOnes(String pid) { try { if (isWindows()) { return new WindowsVirtualMachine(ATTACH_PROVIDER, pid); } String osName = System.getProperty("os.name"); if (osName.startsWith("Linux") || osName.startsWith("LINUX")) { return new LinuxVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Mac OS X")) { return new BsdVirtualMachine(ATTACH_PROVIDER, pid); } else if (osName.startsWith("Solaris")) { return new SolarisVirtualMachine(ATTACH_PROVIDER, pid); } } catch (AttachNotSupportedException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } catch (UnsatisfiedLinkError e) { throw new IllegalStateException("Native library for Attach API not available in this JRE", e); } return null; }