Top


定義場所(file name)

jdk/src/solaris/classes/sun/tools/attach/SolarisVirtualMachine.java

説明(description)

    /**
     * Execute the given command in the target VM.
     */

名前(function name)

    InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException {

本体部(body)

  {- -------------------------------------------
  (1) (assert)
      ---------------------------------------- -}

            assert args.length <= 3;                // includes null

  {- -------------------------------------------
  (1) 既に detach 済みであれば IOException.
      (See: sun.tools.attach.SolarisVirtualMachine.detach())
      ---------------------------------------- -}

            // first check that we are still attached
            int door;
            synchronized (this) {
                if (fd == -1) {
                    throw new IOException("Detached from target VM");
                }
                door = fd;
            }

  {- -------------------------------------------
  (1) door 経由で, 指定されたコマンド (及びその引数) を通知する.
      ---------------------------------------- -}

            // enqueue the command via a door call
            int s = enqueue(door, cmd, args);
            assert s >= 0;                          // valid file descriptor

  {- -------------------------------------------
  (1) 処理の終了ステータスを door 経由で読み取る
      ---------------------------------------- -}

            // The door call returns a file descriptor (one end of a socket pair).
            // Create an input stream around it.
            SocketInputStream sis = new SocketInputStream(s);

            // Read the command completion status
            int completionStatus;
            try {
                completionStatus = readInt(sis);
            } catch (IOException ioe) {
                sis.close();
                throw ioe;
            }

  {- -------------------------------------------
  (1) もし処理がエラーを起こしていたら, 適切な例外をスロー.
      ---------------------------------------- -}

            // If non-0 it means an error but we need to special-case the
            // "load" command to ensure that the right exception is thrown.
            if (completionStatus != 0) {
                sis.close();
                if (cmd.equals("load")) {
                    throw new AgentLoadException("Failed to load agent library");
                } else {
                    throw new IOException("Command failed in target VM");
                }
            }

  {- -------------------------------------------
  (1) 処理結果を読むための SocketInputStream オブジェクトをリターン.
      ---------------------------------------- -}

            // Return the input stream so that the command output can be read
            return sis;
        }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.