jdk/src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java
changeset 45004 ea3137042a61
parent 26460 68a3e0abedfd
equal deleted inserted replaced
44789:73fd39e0702e 45004:ea3137042a61
    98             // wait for command to complete - process will connect with the
    98             // wait for command to complete - process will connect with the
    99             // completion status
    99             // completion status
   100             connectPipe(hPipe);
   100             connectPipe(hPipe);
   101 
   101 
   102             // create an input stream for the pipe
   102             // create an input stream for the pipe
   103             PipedInputStream is = new PipedInputStream(hPipe);
   103             PipedInputStream in = new PipedInputStream(hPipe);
   104 
   104 
   105             // read completion status
   105             // read completion status
   106             int status = readInt(is);
   106             int status = readInt(in);
   107             if (status != 0) {
   107             if (status != 0) {
   108                 // read from the stream and use that as the error message
   108                 // read from the stream and use that as the error message
   109                 String message = readErrorMessage(is);
   109                 String message = readErrorMessage(in);
   110                 is.close();
   110                 in.close();
   111                 // special case the load command so that the right exception is thrown
   111                 // special case the load command so that the right exception is thrown
   112                 if (cmd.equals("load")) {
   112                 if (cmd.equals("load")) {
   113                     throw new AgentLoadException("Failed to load agent library");
   113                     String msg = "Failed to load agent library";
       
   114                     if (!message.isEmpty())
       
   115                         msg += ": " + message;
       
   116                     throw new AgentLoadException(msg);
   114                 } else {
   117                 } else {
   115                     if (message == null) {
   118                     if (message.isEmpty())
   116                         throw new AttachOperationFailedException("Command failed in target VM");
   119                         message = "Command failed in target VM";
   117                     } else {
   120                     throw new AttachOperationFailedException(message);
   118                         throw new AttachOperationFailedException(message);
       
   119                     }
       
   120                 }
   121                 }
   121             }
   122             }
   122 
   123 
   123             // return the input stream
   124             // return the input stream
   124             return is;
   125             return in;
   125 
   126 
   126         } catch (IOException ioe) {
   127         } catch (IOException ioe) {
   127             closePipe(hPipe);
   128             closePipe(hPipe);
   128             throw ioe;
   129             throw ioe;
   129         }
   130         }