8201817: Taglet.init should be called with the "primary" doclet
Reviewed-by: ksrini
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java Wed May 02 19:26:44 2018 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/StandardDoclet.java Wed May 02 11:11:06 2018 -0700
@@ -44,7 +44,7 @@
private final HtmlDoclet htmlDoclet;
public StandardDoclet() {
- htmlDoclet = new HtmlDoclet();
+ htmlDoclet = new HtmlDoclet(this);
}
@Override
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java Wed May 02 19:26:44 2018 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java Wed May 02 11:11:06 2018 -0700
@@ -31,6 +31,7 @@
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
+import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Reporter;
import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet;
@@ -59,8 +60,8 @@
*/
public class HtmlDoclet extends AbstractDoclet {
- public HtmlDoclet() {
- configuration = new HtmlConfiguration(this);
+ public HtmlDoclet(Doclet parent) {
+ configuration = new HtmlConfiguration(parent);
}
@Override // defined by Doclet
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java Wed May 02 19:26:44 2018 +0200
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java Wed May 02 11:11:06 2018 -0700
@@ -42,6 +42,9 @@
import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Reporter;
+import jdk.javadoc.doclet.StandardDoclet;
+import jdk.javadoc.doclet.Taglet;
+import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet;
import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager;
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@@ -356,7 +359,15 @@
/**
* Constructs the configurations needed by the doclet.
*
- * @param doclet the doclet that created this configuration
+ * @apiNote
+ * The {@code doclet} parameter is used when {@link Taglet#init(DocletEnvironment, Doclet)
+ * initializing tags}.
+ * Some doclets (such as the {@link StandardDoclet), may delegate to another
+ * (such as the {@link HtmlDoclet}). In such cases, the primary doclet (i.e
+ * {@code StandardDoclet}) should be provided here, and not any internal
+ * class like {@code HtmlDoclet}.
+ *
+ * @param doclet the doclet for this run of javadoc
*/
public BaseConfiguration(Doclet doclet) {
this.doclet = doclet;
--- a/test/langtools/jdk/javadoc/doclet/testUserTaglet/TestUserTaglet.java Wed May 02 19:26:44 2018 +0200
+++ b/test/langtools/jdk/javadoc/doclet/testUserTaglet/TestUserTaglet.java Wed May 02 11:11:06 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 8176836
+ * @bug 8176836 8201817
* @summary Provide Taglet with context
* @library ../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -52,7 +52,7 @@
checkOutput("pkg/C.html", true,
"<li>Element: CLASS C",
"<li>Element supertypes: [java.lang.Object]",
- "<li>Doclet: class jdk.javadoc.internal.doclets.formats.html.HtmlDoclet"
+ "<li>Doclet: class jdk.javadoc.doclet.StandardDoclet"
);
}
}