United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4587487 : com.sun.tools.javadoc.Main.execute ignores PrintWriters

Details
Type:
Bug
Submit Date:
2001-12-10
Status:
Resolved
Updated Date:
2002-06-27
Project Name:
JDK
Resolved Date:
2002-03-08
Component:
tools
OS:
generic
Sub-Component:
javadoc(tool)
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.1 (hopper)

Related Reports
Relates:

Sub Tasks

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


                                     
2004-06-14
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(...)
======================================================================
                                     
2004-06-11
PUBLIC COMMENTS

..
                                     
2004-06-10
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
                                     
2002-02-27



Hardware and Software, Engineered to Work Together