agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java

Print this page
rev 5644 : 6626412: jstack using SA prints some info messages into err stream
Reviewed-by:

@@ -23,15 +23,15 @@
  */
 
 package sun.jvm.hotspot.tools;
 
 import java.io.PrintStream;
-import java.util.Hashtable;
 
-import sun.jvm.hotspot.*;
-import sun.jvm.hotspot.runtime.*;
-import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.HotSpotAgent;
+import sun.jvm.hotspot.debugger.DebuggerException;
+import sun.jvm.hotspot.debugger.JVMDebugger;
+import sun.jvm.hotspot.runtime.VM;
 
 // generic command line or GUI tool.
 // override run & code main as shown below.
 
 public abstract class Tool implements Runnable {

@@ -145,10 +145,11 @@
           usage();
           return 1;
       }
 
       PrintStream err = System.err;
+      PrintStream out = System.out;
 
       int pid = 0;
       String coreFileName   = null;
       String executableName = null;
       String remoteServer   = null;

@@ -178,22 +179,22 @@
 
       agent = new HotSpotAgent();
       try {
         switch (debugeeType) {
           case DEBUGEE_PID:
-             err.println("Attaching to process ID " + pid + ", please wait...");
+             out.println("Attaching to process ID " + pid + ", please wait...");
              agent.attach(pid);
              break;
 
           case DEBUGEE_CORE:
-             err.println("Attaching to core " + coreFileName +
+             out.println("Attaching to core " + coreFileName +
                          " from executable " + executableName + ", please wait...");
              agent.attach(executableName, coreFileName);
              break;
 
           case DEBUGEE_REMOTE:
-             err.println("Attaching to remote server " + remoteServer + ", please wait...");
+             out.println("Attaching to remote server " + remoteServer + ", please wait...");
              agent.attach(remoteServer);
              break;
         }
       }
       catch (DebuggerException e) {

@@ -216,11 +217,11 @@
         }
         err.println();
         return 1;
       }
 
-      err.println("Debugger attached successfully.");
+      out.println("Debugger attached successfully.");
       startInternal();
       return 0;
    }
 
    // When using an existing JVMDebugger.

@@ -235,27 +236,27 @@
    }
 
    // Remains of the start mechanism, common to both start methods.
    private void startInternal() {
 
-      PrintStream err = System.err;
+      PrintStream out = System.out;
       VM vm = VM.getVM();
       if (vm.isCore()) {
-        err.println("Core build detected.");
+        out.println("Core build detected.");
       } else if (vm.isClientCompiler()) {
-        err.println("Client compiler detected.");
+        out.println("Client compiler detected.");
       } else if (vm.isServerCompiler()) {
-        err.println("Server compiler detected.");
+        out.println("Server compiler detected.");
       } else {
         throw new RuntimeException("Fatal error: "
             + "should have been able to detect core/C1/C2 build");
       }
 
       String version = vm.getVMRelease();
       if (version != null) {
-        err.print("JVM version is ");
-        err.println(version);
+        out.print("JVM version is ");
+        out.println(version);
       }
 
       run();
    }
 }