JDK-4587487 : com.sun.tools.javadoc.Main.execute ignores PrintWriters
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-12-10
  • Updated: 2002-06-27
  • Resolved: 2002-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.1 hopperFixed
Related Reports
Relates :  
Description

Name: nt126004			Date: 12/10/2001


java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)


When using com.sun.tools.javadoc.Main.execute(
    java.lang.String programName,
    java.io.PrintWriter errWriter,
    java.io.PrintWriter warnWriter,
    java.io.PrintWriter noticeWriter,
    java.lang.String defaultDocletClassName,
    java.lang.String[] args)

it seems that the errWriter,warnWriter and noticeWriter parameters are
ignored.


int result = Main.execute("myDocletClass",
    new java.io.PrintWriter(new java.io.ByteArrayOutputStream()),
    new java.io.PrintWriter(new java.io.ByteArrayOutputStream()),
    new java.io.PrintWriter(new java.io.ByteArrayOutputStream()),
    "myDocletClassName","MyJavaFile.java");

should print:

Loading source file MyJavaFile.java...
Constructing Javadoc information...

to stdout, right?

The following programm shows the bug:

import java.io.*;
import com.sun.tools.javadoc.Main;

public class Test {

	public static void main(String[] args) {

		ByteArrayOutputStream redirectedOutput = new
ByteArrayOutputStream();
		PrintStream originalOutput = System.out;
		// redirect System.out to a buffer
		System.setOut(new PrintStream(redirectedOutput));

		// execute javadoc
		int result = Main.execute(
			"StandardDoclet",
			new PrintWriter(new ByteArrayOutputStream()),
			new PrintWriter(new ByteArrayOutputStream()),
			new PrintWriter(new ByteArrayOutputStream()),
			"com.sun.tools.doclets.standard.Standard",
			new String[] {"Test.java"}
		);

		// test whether javadoc did any output to System.out
		if (redirectedOutput.toByteArray().length > 0) {
			originalOutput.println("Bug still exists.");
		} else {
			originalOutput.println("Bug fixed.");
		}
	}
}

  To run the Test just compile it with javac and run it. The classpath must
contain the JAVA_HOME/lib/tools.jar file.
(Review ID: 136921) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper FIXED IN: hopper INTEGRATED IN: hopper
14-06-2004

WORK AROUND Name: nt126004 Date: 12/10/2001 Customer Workaround : Redirect the System.out stream using the System.setOut(PrintStream) method before executing Main.execute(...) ======================================================================
11-06-2004

PUBLIC COMMENTS ..
10-06-2004

EVALUATION I have fixed this on the tool side. I have opened 4644257 for the corresponding bugs on the doclet side. There is a regression test in the generics workspace marked @ignore pending 4644257. ###@###.### 2002-02-27
27-02-2002