FULL PRODUCT VERSION :
java version "1.5.0_05"
java version "1.6.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b62)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b62, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
This problem happens on all operating systems
A DESCRIPTION OF THE PROBLEM :
The recommended way to include muti-line code samples that contain type parameters is to use <PRE> followed by {@code}. The first tag keeps the indentation/newlines intact, while the second prevents angle brackets '<' from being interpreted as HTML.
However, this combination of tags causes leading spaces to be stripped out, preventing the first line from being properly indented.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Save the following java code to HelloWorld.java and run javadoc on it
(javadoc HelloWorld.java -d docs). Then open docs/HelloWorld.html and notice the resulting first line of the code is not indented (but should be)
--------------------- HelloWorld.java ------------------------
/**
* Here is a code example:
*<PRE>{@code
static void expurgate(Collection<String> c) {
}
*}</PRE>
* End of example
*/
public class HelloWorld {
}
---------------------------- end of file -------------------------------
For more info, see {@code}:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javadoc.html#{@code }
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
(I don't know if this bug report will display the spacing here faithfully,
so I'll put a dot (.) where a leading space should actually appear)
This is what the generated web page should look like:
----------------------------------------------
Here is a code example:
....static void expurgate(Collection<String> c) {
....}
End of example
----------------------------------------------
ACTUAL -
This is what the generated web page actually looks like:
----------------------------------------------
Here is a code example:
static void expurgate(Collection<String> c) {
....}
End of example
----------------------------------------------
ERROR MESSAGES/STACK TRACES THAT OCCUR :
(none)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
See the "Steps to Reproduce" above.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
WORKAROUND: Now run javadoc on this -- notice the resulting first line is properly indented
--------------------- HelloWorld.java ------------------------
/**
* Here is a code example:
*<PRE>{@code \u0000 // Removes words
static void expurgate(Collection<String> c) {
}
*}</PRE>
* End of example
*/
public class HelloWorld {
}
---------------------------- end of file -------------------------------
NOTES:
The null character (\u0000) apparently prints as a zero-width character, which
enables the following spaces to not be stripped out.
Adding a newline between <PRE> and the first character (/) would cause an unwanted newline to appear in the output.