code: public Object attachVirtualMachine() {
          if (options.getPid() == null && options.getProcessPattern() == null) {
              return null;
          }
          Class vmClass = lookupVirtualMachineClass();
          String pid = null;
          try {
              Method method = vmClass.getMethod("attach",String.class);
              pid = getProcessId(options);
              return method.invoke(null, pid);
          } catch (NoSuchMethodException e) {
              throw new ProcessingException("Internal: No method 'attach' found on " + vmClass,e,options);
          } catch (InvocationTargetException e) {
              throw new ProcessingException(getPidErrorMesssage(pid,"InvocationTarget",vmClass),e,options);
          } catch (IllegalAccessException e) {
              throw new ProcessingException(getPidErrorMesssage(pid, "IllegalAccessException", vmClass),e,options);
          } catch (IllegalArgumentException e) {
              throw new ProcessingException("Illegal Argument",e,options);
          }
      }
docs: Lookup and create a {@link com.sun.tools.attach.VirtualMachine} via reflection. First, a direct
  lookup via {@link Class#forName(String)} is done, which will succeed for JVM on OS X, since tools.jar
  is bundled there together with classes.zip. Next, tools.jar is tried to be found (by examine <code>java.home</code>)
  and an own classloader is created for looking up the VirtualMachine.
  
  If lookup fails, a message is printed out (except when '--quiet' is provided)
  
  @return the create virtual machine of <code>null</code> if none could be created