Hello I'm trying to write an extension of the standard doclet together with custom taglets in the same JAR file. The custom taglets and doclet need to share information. But I faced the following difficulties:
When the Taglet.init(DocletEnvironment,Doclet) method is invoked, the doclet argument given by the caller is the internal HtmlDoclet wrapped by StandardDoclet, not my custom StandardDoclet subtype. So I can not get my doclet and taglet in touch that way. The lazy workaround - shared static fields - does not work because the taglet is loaded in a different class loader than the doclet. So even if I change a static field value from the taglet, the doclet never see that change. This is not a multi-threading issue; I tested with volatile static field. I also verified that the class loaders for the same class were different depending on whether the class of my JAR file is accessed from the doclet or from the taglet. I tried to wrap DocletEnvironment in order to return a customised ForwardingJavaFileManager, in an attempt to control which ClassLoader is used for loading the taglet. But the standard doclet does not seem to accept customized DocletEnvironment, as suggested by the error that I got: java.lang.ClassCastException: org.opengis.tools.doclet.ForwardingDocletEnvironment cannot be cast to jdk.javadoc/jdk.javadoc.internal.tool.DocEnvImpl at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.WorkArounds.<init>(WorkArounds.java:101) at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.run(AbstractDoclet.java:108) at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.run(StandardDoclet.java:72) (...snip...) The jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager class has public void addCustomTag(Taglet) method which seems perfect for my need, but I found no public API for accessing this functionality. Is there a public way for a doclet to know its registered taglets, or any other workaround that I may have missed? If not, would the following evolution of Javadoc tools be possible? * When extending the StandardDoclet, the doclet given in Taglet.init(...) method should be the user StandardDoclet instance instead than the JDK internal HtmlDoclet. * Alternatively, a public API for addCustomTag(…) functionality would also work. Regards, Martin