-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
hopper
-
generic
-
generic
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)
======================================================================
- relates to
-
JDK-4644257 stddoclet: uses System.out and System.err instead of Messager printwriters
- Resolved