/** if this line can not be current => stepOver & return true. return false on the other hand. */
 boolean resolveCanBeCurrent(ThreadReference tr) {
   try {
     Location l = tr.frame(0).location();
     if (l == null) return false;
     return resolveCanBeCurrent(
         tr, Utils.getLineForSource(l.declaringType().name(), l.sourceName(), l.lineNumber()));
   } catch (Exception e) {
   }
   return false;
 }
  /** Executes breakpoint hit event. */
  public void exec(com.sun.jdi.event.Event ev) {
    // S ystem.out.println ("exec "); // NOI18N
    removeStepRequest();
    StepEvent event = (StepEvent) ev;
    ThreadReference tr = event.thread();
    Location loc = event.location();
    int ln = -1;
    String methodName = "?"; // NOI18N
    String className = "?"; // NOI18N
    String lineNumber = "?"; // NOI18N
    String threadName = tr.name();
    Line l = null;

    if (loc != null) {
      if (loc.method() != null) methodName = loc.method().name();
      className = loc.declaringType().name();
      ln = loc.lineNumber();
      if (ln >= 0) lineNumber = "" + loc.lineNumber();
    }

    if (ln != -1)
      try {
        l = Utils.getLineForSource(className, loc.sourceName(), ln);
      } catch (AbsentInformationException e) {
        l = Utils.getLine(className, ln);
      }

    if (resolveCanBeCurrent(tr, l))
      // if this line can not be current resolveCanBeCurrent () calls stepOver
      return;
    // line can be current

    if ((l == null) && (getLastAction() == ACTION_TRACE_INTO))
      // try to find another "intelligent" line of code
      traceToSourceCode(tr);
    // you know - intelligent means that one with source code
    else {
      makeCurrent(threadName, className, methodName, lineNumber, l != null, tr);
      operator.stopRequest();
    }
  }
  private VirtualMachine launch(DebuggerInfo info) throws DebuggerException {
    // create process & read password for local debugging

    // create main class & arguments ...............................................
    StringBuffer sb = new StringBuffer();
    sb.append(mainClassName);
    String[] infoArgs = info.getArguments();
    int i, k = infoArgs.length;
    for (i = 0; i < k; i++) sb.append(" \"").append(infoArgs[i]).append('"'); // NOI18N
    String main = new String(sb);

    // create connector ..............................................................
    VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
    java.util.List lcs = vmm.launchingConnectors();
    k = lcs.size();
    for (i = 0; i < k; i++)
      if (((LaunchingConnector) lcs.get(i)).name().indexOf("RawCommandLineLaunch") >= 0) // NOI18N
      break;
    if (i == k) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_Cannot_find_launcher"))
              .format(
                  new Object[] {
                    "RawCommandLineLaunch" // NOI18N
                  }));
    }
    LaunchingConnector lc = (LaunchingConnector) lcs.get(i);
    String transport = lc.transport().name();

    // create commandLine & NbProcessDescriptor ..............................
    NbProcessDescriptor debugerProcess;
    if (info instanceof ProcessDebuggerInfo)
      debugerProcess = ((ProcessDebuggerInfo) info).getDebuggerProcess();
    else debugerProcess = ProcessDebuggerType.DEFAULT_DEBUGGER_PROCESS;

    // generate password
    String password;
    if (transport.equals("dt_shmem")) { // NOI18N
      connector = getAttachingConnectorFor("dt_shmem");
      password = generatePassword();
      args = connector.defaultArguments();
      ((Argument) args.get("name")).setValue(password);
    } else {
      try {
        java.net.ServerSocket ss = new java.net.ServerSocket(0);
        password = "" + ss.getLocalPort(); // NOI18N
        ss.close();
      } catch (java.io.IOException e) {
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_Cannot_find_empty_local_port"))
                .format(new Object[] {e.toString()}));
      }
      connector = getAttachingConnectorFor("dt_socket");
      args = connector.defaultArguments();
      ((Argument) args.get("port")).setValue(password);
    }
    HashMap map =
        Utils.processDebuggerInfo(
            info,
            "-Xdebug -Xnoagent -Xrunjdwp:transport="
                + // NOI18N
                transport
                + ",address="
                + // NOI18N
                password
                + ",suspend=y ", // NOI18N
            main);
    MapFormat format = new MapFormat(map);
    String commandLine =
        format.format(
            debugerProcess.getProcessName()
                + " "
                + // NOI18N
                debugerProcess.getArguments());
    println(commandLine, ERR_OUT);
    /*
    We mus wait on process start to connect...
    try {
      process = debugerProcess.exec (format);
    } catch (java.io.IOException exc) {
      finishDebugger ();
      throw new DebuggerException (
        new MessageFormat (bundle.getString ("EXC_While_create_debuggee")).
          format (new Object[] {
            debugerProcess.getProcessName (),
            exc.toString ()
          }),
        exc
      );
    }
    return connect (
      null,
      connector,
      args
    );*/

    /*      S ystem.out.println ("attaching: ");
    Utils.showConnectors (vmm.attachingConnectors ());

    S ystem.out.println ("launching: ");
    Utils.showConnectors (vmm.launchingConnectors ());

    S ystem.out.println ("listening: ");
    Utils.showConnectors (vmm.listeningConnectors ());*/

    // set debugger-start arguments
    Map params = lc.defaultArguments();
    ((Argument) params.get("command"))
        .setValue( // NOI18N
            commandLine);
    ((Argument) params.get("address"))
        .setValue( // NOI18N
            password);

    // launch VM
    try {
      return lc.launch(params);
    } catch (VMStartException exc) {
      showOutput(process = exc.process(), ERR_OUT, ERR_OUT);
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_While_create_debuggee"))
              .format(
                  new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}),
          exc);
    } catch (Exception exc) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_While_create_debuggee"))
              .format(
                  new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}),
          exc);
    }
  }