Skip to content

Commit b4d4884

Browse files
8267126: javadoc should show "line and caret" for diagnostics.
Reviewed-by: prappo
1 parent 461a3fe commit b4d4884

File tree

37 files changed

+832
-306
lines changed

37 files changed

+832
-306
lines changed

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WorkArounds.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import com.sun.tools.javac.comp.Env;
6161
import com.sun.tools.javac.model.JavacElements;
6262
import com.sun.tools.javac.util.Names;
63+
import com.sun.tools.javac.util.Options;
6364

6465
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
6566
import jdk.javadoc.internal.tool.ToolEnvironment;
@@ -536,4 +537,21 @@ public boolean isReflectivePreviewAPI(Element el) {
536537
return (sym.flags() & Flags.PREVIEW_REFLECTIVE) != 0;
537538
}
538539

540+
/**
541+
* Returns whether or not to permit dynamically loaded components to access
542+
* part of the javadoc internal API. The flag is the same (hidden) compiler
543+
* option that allows javac plugins and annotation processors to access
544+
* javac internal API.
545+
*
546+
* As with all workarounds, it is better to consider updating the public API,
547+
* rather than relying on undocumented features like this, that may be withdrawn
548+
* at any time, without notice.
549+
*
550+
* @return true if access is permitted to internal API
551+
*/
552+
public boolean accessInternalAPI() {
553+
Options compilerOptions = Options.instance(toolEnv.context);
554+
return compilerOptions.isSet("accessInternalAPI");
555+
}
556+
539557
}

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ public class TagletManager {
185185

186186
private final String tagletPath;
187187

188+
private final BaseConfiguration configuration;
189+
188190
/**
189191
* Constructs a new {@code TagletManager}.
190192
*
@@ -197,6 +199,7 @@ public TagletManager(BaseConfiguration configuration) {
197199
standardTagsLowercase = new HashSet<>();
198200
unseenCustomTags = new HashSet<>();
199201
allTaglets = new LinkedHashMap<>();
202+
this.configuration = configuration;
200203
BaseOptions options = configuration.getOptions();
201204
this.nosince = options.noSince();
202205
this.showversion = options.showVersion();
@@ -250,6 +253,15 @@ public void addCustomTag(String classname, JavaFileManager fileManager) {
250253
try {
251254
ClassLoader tagClassLoader;
252255
tagClassLoader = fileManager.getClassLoader(TAGLET_PATH);
256+
if (configuration.workArounds.accessInternalAPI()) {
257+
Module thisModule = getClass().getModule();
258+
Module tagletLoaderUnnamedModule = tagClassLoader.getUnnamedModule();
259+
List<String> pkgs = List.of(
260+
"jdk.javadoc.doclet",
261+
"jdk.javadoc.internal.doclets.toolkit",
262+
"jdk.javadoc.internal.doclets.formats.html");
263+
pkgs.forEach(p -> thisModule.addOpens(p, tagletLoaderUnnamedModule));
264+
}
253265
Class<? extends jdk.javadoc.doclet.Taglet> customTagClass =
254266
tagClassLoader.loadClass(classname).asSubclass(jdk.javadoc.doclet.Taglet.class);
255267
jdk.javadoc.doclet.Taglet instance = customTagClass.getConstructor().newInstance();

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
import javax.tools.JavaFileManager.Location;
9494
import javax.tools.StandardLocation;
9595

96+
import com.sun.source.doctree.BlockTagTree;
9697
import com.sun.source.doctree.DeprecatedTree;
9798
import com.sun.source.doctree.DocCommentTree;
9899
import com.sun.source.doctree.DocTree;
@@ -2632,10 +2633,10 @@ public List<? extends DocTree> getBlockTags(Element element, DocTree.Kind kind,
26322633

26332634
public List<? extends DocTree> getBlockTags(Element element, Taglet taglet) {
26342635
return getBlockTags(element, t -> {
2635-
if (taglet instanceof BaseTaglet bt) {
2636-
return bt.accepts(t);
2637-
} else if (t instanceof UnknownBlockTagTree tree) {
2638-
return tree.getTagName().equals(taglet.getName());
2636+
if (taglet instanceof BaseTaglet baseTaglet) {
2637+
return baseTaglet.accepts(t);
2638+
} else if (t instanceof BlockTagTree blockTagTree) {
2639+
return blockTagTree.getTagName().equals(taglet.getName());
26392640
} else {
26402641
return false;
26412642
}

src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ private Set<ModuleElement> getModuleRequires(ModuleElement mdle, boolean onlyTra
567567
if (!isMandated(mdle, rd) && onlyTransitive == rd.isTransitive()) {
568568
if (!haveModuleSources(dep)) {
569569
if (!warnedNoSources.contains(dep)) {
570-
messager.printWarning(dep, "main.module_source_not_found", dep.getQualifiedName());
570+
messager.printWarningUsingKey(dep, "main.module_source_not_found", dep.getQualifiedName());
571571
warnedNoSources.add(dep);
572572
}
573573
}

0 commit comments

Comments
 (0)