Revisting old topic about subclassing Standard....
Hi,
I think this has been talked about a million times, but I just want to be sure I have it right. Basically I want to use the Standard doclet, but just tweak it a little. The Sun site says to either modify a copy of the source directly, or to subclass Standard and other "appropriate" classes.
I've tried subclassing and as soon as I try to deviate at all, I either get:
ClassCastException because of DocImpl.compareTo(...)
or I get some error about the toolkit classes being locked.
I don't really want to modify the source directly, and I can't use 3rd party tools. Am I essentially out of luck?
Thanks for any help.
[666 byte] By [
JaySima] at [2007-11-27 0:16:48]

# 1
By "locked" do you mean this message:
The Doclet Toolkit can only be used by HtmlDoclet
You can bypass this in doclets/internal/toolkit/AbstractDoclet.java
by removing the constraint imposed by this method:
/**
* Verify that the only doclet that is using this toolkit is
* {@value #TOOLKIT_DOCLET_NAME}.
*/
private boolean isValidDoclet(AbstractDoclet doclet) {
if (! doclet.getClass().getName().equals(TOOLKIT_DOCLET_NAME)) {
configuration.message.error("doclet.Toolkit_Usage_Violation",
TOOLKIT_DOCLET_NAME);
return false;
}
return true;
}
Does that help?
# 3
Replacing the class in the tools.jar file certainly would work.
If you really want to override that class without modifying tools.jar, I believe it is possible, but somewhat awkward. I have used this technique for overriding other classes, but have not tried it for overriding AbstractDoclet.class.
You would modify AbstractDoclet.java, then you must run javadoc by calling java on javadoc.Main and put AbstractDoclet.class on the classpath *ahead* of tools.jar, as follows:
$JAVA_HOME/bin/java \
-classpath $PATH_TO_CLASS/AbstractDoclet.class:$JAVA_HOME/lib/tools.jar \
-Xmx20M \
com.sun.tools.javadoc.Main \
-sourcepath src \
com.myPackage
Putting your class ahead of tools.jar ensures that javadoc will find it first.
Please let us know if this works.
-Doug