langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java
changeset 40232 4995ab1a4558
parent 39599 3c7da4996d8c
child 40308 274367a99f98
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Wed Aug 03 11:30:27 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Wed Aug 03 16:01:09 2016 -0700
@@ -62,9 +62,13 @@
      */
     String ownName;
 
+    /** The writer to use for normal output.
+     */
+    PrintWriter stdOut;
+
     /** The writer to use for diagnostic output.
      */
-    PrintWriter out;
+    PrintWriter stdErr;
 
     /** The log to use for diagnostic output.
      */
@@ -102,7 +106,7 @@
      * @param name the name of this tool
      */
     public Main(String name) {
-        this(name, new PrintWriter(System.err, true));
+        this.ownName = name;
     }
 
     /**
@@ -112,7 +116,7 @@
      */
     public Main(String name, PrintWriter out) {
         this.ownName = name;
-        this.out = out;
+        this.stdOut = this.stdErr = out;
     }
 
     /** Report a usage error.
@@ -161,7 +165,14 @@
      * @return the result of the compilation
      */
     public Result compile(String[] argv, Context context) {
-        context.put(Log.outKey, out);
+        if (stdOut != null) {
+            context.put(Log.outKey, stdOut);
+        }
+
+        if (stdErr != null) {
+            context.put(Log.errKey, stdErr);
+        }
+
         log = Log.instance(context);
 
         if (argv.length == 0) {