JDK-4625211 : com.sun.tools.javac.v8.Main change in error output vs. com.sun.tools.javac.Main
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.3.1
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-01-17
  • Updated: 2002-01-18
  • Resolved: 2002-01-18
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 01/17/2002


FULL PRODUCT VERSION :
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)


FULL OPERATING SYSTEM VERSION :

Microsoft Windows 2000 [Version 5.00.2195]



A DESCRIPTION OF THE PROBLEM :
The original com.sun.tools.javac.Main provided the
following constructore: Main(ByteArrayOutputStream baos,
String name).  This allowed the caller to provide a stream
where compiler output would be redirected.  The newer
com.sun.tools.javac.v8.Main provides only: Main(String
name, boolean gcEnable).  All error output is hardcoded to
System.err stream, which makes it hard for a caller to
smoothly handle errors without redirecting system streams.

REGRESSION.  Last worked in version 1.2.2

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Write code that instantiates a
com.sun.tools.javac.v8.Main object
2. Write code that creates a com.sun.tools.javac.Main object
3. Notice that v8 doesn't have a parameter for an output
stream.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
=======================================
OrigMainTester.java:

import java.io.*;
import java.util.*;
import sun.tools.javac.Main;

public class OrigMainTester
{
  public static void main(String [] args)
  {
     ByteArrayOutputStream baos = new ByteArrayOutputStream
();
     try
	 {
			// create compiler
			Main compiler = new Main
(baos, "theCompiler");

			// run the compile
			boolean bStatus = compiler.compile
(args);
	 }
	 catch (Exception e)
	 {
		 e.printStackTrace();
	 }
  }
}

=======================================
Mainv8Tester.java:

import java.io.*;
import java.util.*;
import sun.tools.javac.v8.Main;

public class Mainv8Tester
{
  public static void main(String [] args)
  {
     try
	 {
			// create compiler
			Main compiler = new Main
("theCompiler", false); // no error stream!!

			// run the compile
			boolean bStatus = compiler.compile
(args);
	 }
	 catch (Exception e)
	 {
		 e.printStackTrace();
	 }
  }
}


---------- END SOURCE ----------
(Review ID: 137792) 
======================================================================