Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8247957: remove doclint support for HTML 4
8257204: Remove usage of -Xhtmlversion option from javac
8256313: JavaCompilation.gmk needs to be updated not to use --doclint-format html5 option
8258460: Remove --doclint-format option from javac
8256312: Valid anchor 'id' value not allowed

Reviewed-by: jjg, ihse
  • Loading branch information
Yoshiki Sato authored and jonathan-gibbons committed Jan 6, 2021
1 parent 80544e4 commit 28e1f4d9eebd148c4a7e5c83a5141e8acc7ccced
Showing with 494 additions and 891 deletions.
  1. +1 −1 make/common/JavaCompilation.gmk
  2. +0 −1 src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java
  3. +0 −5 src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java
  4. +0 −2 src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java
  5. +0 −3 src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties
  6. +0 −2 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java
  7. +32 −65 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java
  8. +0 −17 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/DocLint.java
  9. +1 −7 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Env.java
  10. +98 −101 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/HtmlTag.java
  11. +0 −49 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/HtmlVersion.java
  12. +6 −5 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/resources/doclint.properties
  13. +4 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/resources/doclint_ja.properties
  14. +4 −4 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/resources/doclint_zh_CN.properties
  15. +1 −1 test/langtools/jdk/javadoc/doclet/testHtmlTableStyles/TestHtmlTableStyles.java
  16. +8 −7 test/langtools/tools/doclint/AccessibilityTest.java
  17. +1 −1 test/langtools/tools/doclint/AccessibilityTest.out
  18. +0 −30 test/langtools/tools/doclint/AccessibilityTest5.java
  19. +0 −4 test/langtools/tools/doclint/AccessibilityTest5.out
  20. +4 −31 test/langtools/tools/doclint/AnchorTest.java
  21. +13 −31 test/langtools/tools/doclint/AnchorTest.out
  22. +4 −4 test/langtools/tools/doclint/AnchorTest2.java
  23. +1 −1 test/langtools/tools/doclint/AnchorTest2.out
  24. +1 −1 test/langtools/tools/doclint/AnchorTest2a.java
  25. +3 −3 test/langtools/tools/doclint/EndTagsTest.java
  26. +1 −1 test/langtools/tools/doclint/HtmlAttrsTest.java
  27. +4 −5 test/langtools/tools/doclint/HtmlAttrsTest.out
  28. +1 −1 test/langtools/tools/doclint/HtmlTagsTest.java
  29. +1 −4 test/langtools/tools/doclint/HtmlTagsTest.out
  30. +0 −41 test/langtools/tools/doclint/HtmlVersionTest.java
  31. +19 −19 test/langtools/tools/doclint/anchorTests/p/Test.java
  32. +6 −6 test/langtools/tools/doclint/anchorTests/p/Test.out
  33. +5 −3 test/langtools/tools/doclint/anchorTests/p/package-info.java
  34. +3 −1 test/langtools/tools/doclint/anchorTests/p/package-info.javac.out
  35. +8 −2 test/langtools/tools/doclint/anchorTests/p/package-info.out
  36. +5 −8 test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTest.java
  37. +117 −102 test/langtools/tools/doclint/html/{HtmlVersionTagsAttrsTestHtml5.out → HtmlVersionTagsAttrsTest.out}
  38. +0 −212 test/langtools/tools/doclint/html/HtmlVersionTagsAttrsTestHtml4.out
  39. +10 −0 test/langtools/tools/doclint/html/InlineTagTest.out
  40. +2 −2 test/langtools/tools/doclint/html/InlineTagsTest.java
  41. +1 −1 test/langtools/tools/doclint/html/OtherTagsTest.java
  42. +7 −4 test/langtools/tools/doclint/html/OtherTagsTest.out
  43. +22 −0 test/langtools/tools/doclint/html/TableTagTest.out
  44. +2 −2 test/langtools/tools/doclint/html/TableTagsTest.java
  45. +1 −1 test/langtools/tools/doclint/html/TagNotAllowed.java
  46. +17 −2 test/langtools/tools/doclint/html/TagNotAllowed.out
  47. +11 −11 test/langtools/tools/doclint/html/TextNotAllowed.java
  48. +20 −20 test/langtools/tools/doclint/html/TextNotAllowed.out
  49. +3 −3 test/langtools/tools/doclint/tidy/AnchorAlreadyDefined.java
  50. +1 −1 test/langtools/tools/doclint/tidy/AnchorAlreadyDefined.out
  51. +2 −2 test/langtools/tools/doclint/tidy/BadEnd.java
  52. +3 −3 test/langtools/tools/doclint/tidy/BadEnd.out
  53. +6 −5 test/langtools/tools/doclint/tidy/InvalidName.java
  54. +2 −2 test/langtools/tools/doclint/tidy/InvalidName.out
  55. +4 −4 test/langtools/tools/doclint/tidy/TextNotAllowed.java
  56. +6 −6 test/langtools/tools/doclint/tidy/TextNotAllowed.out
  57. +1 −4 test/langtools/tools/doclint/tidy/TrimmingEmptyTag.java
  58. +14 −23 test/langtools/tools/doclint/tidy/TrimmingEmptyTag.out
  59. +7 −10 test/langtools/tools/javac/doclint/DocLintFormatTest.java
@@ -269,7 +269,7 @@ define SetupJavaCompilationBody
# Tell javac to do exactly as told and no more
PARANOIA_FLAGS := -implicit:none -Xprefer:source -XDignore.symbol.file=true -encoding ascii

$1_FLAGS += -g -Xlint:all --doclint-format html5 $$($1_TARGET_RELEASE) $$(PARANOIA_FLAGS) $$(JAVA_WARNINGS_ARE_ERRORS)
$1_FLAGS += -g -Xlint:all $$($1_TARGET_RELEASE) $$(PARANOIA_FLAGS) $$(JAVA_WARNINGS_ARE_ERRORS)
$1_FLAGS += $$($1_JAVAC_FLAGS)

ifneq ($$($1_DISABLED_WARNINGS), )
@@ -41,7 +41,6 @@
public abstract class DocLint implements Plugin {
public static final String XMSGS_OPTION = "-Xmsgs";
public static final String XMSGS_CUSTOM_PREFIX = "-Xmsgs:";
public static final String XHTML_VERSION_PREFIX = "-XhtmlVersion:";
public static final String XCHECK_PACKAGE = "-XcheckPackage:";

private static ServiceLoader.Provider<DocLint> docLintProvider;
@@ -853,11 +853,6 @@ public List<String> getDocLintOpts() {
doclintOpts.add(DocLint.XCHECK_PACKAGE + checkPackages);
}

String format = options.get(Option.DOCLINT_FORMAT);
if (format != null) {
doclintOpts.add(DocLint.XHTML_VERSION_PREFIX + format);
}

return List.from(doclintOpts.toArray(new String[doclintOpts.size()]));
}

@@ -159,8 +159,6 @@ public void process(OptionHelper helper, String option, String arg) {
}
},

DOCLINT_FORMAT("--doclint-format", "opt.doclint.format", EXTENDED, BASIC, ONEOF, "html5"),

// -nowarn is retained for command-line backward compatibility
NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) {
@Override
@@ -286,9 +286,6 @@ javac.opt.Xdoclint.package.desc=\
expands to all sub-packages of the given package. Each <package> can be prefixed\n\
with '-' to disable checks for the specified package or packages.

javac.opt.doclint.format=\
Specify the format for documentation comments

javac.opt.Xstdout=\
Redirect standard output
javac.opt.X=\
@@ -798,8 +798,6 @@ public void initDocLint(List<String> opts, Set<String> customTagNames) {
doclintOpts.add(DocLint.XCUSTOM_TAGS_PREFIX + customTags);
}

doclintOpts.add(DocLint.XHTML_VERSION_PREFIX + "html5");

doclint = new DocLint();
doclint.init(docEnv.getDocTrees(), docEnv.getElementUtils(), docEnv.getTypeUtils(),
doclintOpts.toArray(new String[0]));
@@ -91,6 +91,7 @@
import com.sun.tools.javac.util.DefinedBy.Api;

import jdk.javadoc.internal.doclint.HtmlTag.AttrKind;
import jdk.javadoc.internal.doclint.HtmlTag.ElemKind;
import static jdk.javadoc.internal.doclint.Messages.Group.*;


@@ -324,8 +325,8 @@ public Void visitStartElement(StartElementTree tree, Void ignore) {
final HtmlTag t = HtmlTag.get(treeName);
if (t == null) {
env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
} else if (t.allowedVersion != HtmlVersion.ALL && t.allowedVersion != env.htmlVersion) {
env.messages.error(HTML, tree, "dc.tag.not.supported", treeName);
} else if (t.elemKind == ElemKind.HTML4) {
env.messages.error(HTML, tree, "dc.tag.not.supported.html5", treeName);
} else {
boolean done = false;
for (TagStackItem tsi: tagStack) {
@@ -413,8 +414,7 @@ public Void visitStartElement(StartElementTree tree, Void ignore) {
// so-called "self-closing" tags are only permitted in HTML 5, for void elements
// https://html.spec.whatwg.org/multipage/syntax.html#start-tags
private boolean isSelfClosingAllowed(HtmlTag tag) {
return env.htmlVersion == HtmlVersion.HTML5
&& tag.endKind == HtmlTag.EndKind.NONE;
return tag.endKind == HtmlTag.EndKind.NONE;
}

private void checkStructure(StartElementTree tree, HtmlTag t) {
@@ -535,7 +535,7 @@ public Void visitEndElement(EndElementTree tree, Void ignore) {

case SECTION:
case ARTICLE:
if (env.htmlVersion == HtmlVersion.HTML5 && !top.flags.contains(Flag.HAS_HEADING)) {
if (!top.flags.contains(Flag.HAS_HEADING)) {
env.messages.error(HTML, tree, "dc.tag.requires.heading", treeName);
}
break;
@@ -579,7 +579,8 @@ void warnIfEmpty(TagStackItem tsi, DocTree endTree) {
if (tsi.tag.flags.contains(HtmlTag.Flag.EXPECT_CONTENT)
&& !tsi.flags.contains(Flag.HAS_TEXT)
&& !tsi.flags.contains(Flag.HAS_ELEMENT)
&& !tsi.flags.contains(Flag.HAS_INLINE_TAG)) {
&& !tsi.flags.contains(Flag.HAS_INLINE_TAG)
&& !(tsi.tag.elemKind == ElemKind.HTML4)) {
DocTree tree = (endTree != null) ? endTree : tsi.tree;
Name treeName = ((StartElementTree) tsi.tree).getName();
env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
@@ -594,13 +595,10 @@ void warnIfEmpty(TagStackItem tsi, DocTree endTree) {
@Override @DefinedBy(Api.COMPILER_TREE) @SuppressWarnings("fallthrough")
public Void visitAttribute(AttributeTree tree, Void ignore) {
HtmlTag currTag = tagStack.peek().tag;
if (currTag != null) {
if (currTag != null && currTag.elemKind != ElemKind.HTML4) {
Name name = tree.getName();
HtmlTag.Attr attr = currTag.getAttr(name);
if (attr != null) {
if (env.htmlVersion == HtmlVersion.HTML4 && attr.name().contains("-")) {
env.messages.error(HTML, tree, "dc.attr.not.supported.html4", name);
}
boolean first = tagStack.peek().attrs.add(attr);
if (!first)
env.messages.error(HTML, tree, "dc.attr.repeated", name);
@@ -609,30 +607,29 @@ public Void visitAttribute(AttributeTree tree, Void ignore) {
// without checking the validity or applicability of the name
if (!name.toString().startsWith("on")) {
AttrKind k = currTag.getAttrKind(name);
switch (env.htmlVersion) {
switch (k) {
case OK:
break;
case OBSOLETE:
env.messages.warning(HTML, tree, "dc.attr.obsolete", name);
break;
case HTML4:
validateHtml4Attrs(tree, name, k);
env.messages.error(HTML, tree, "dc.attr.not.supported.html5", name);
break;

case HTML5:
validateHtml5Attrs(tree, name, k);
case INVALID:
env.messages.error(HTML, tree, "dc.attr.unknown", name);
break;
}
}

if (attr != null) {
switch (attr) {
case NAME:
if (currTag != HtmlTag.A) {
break;
}
// fallthrough
case ID:
String value = getAttrValue(tree);
if (value == null) {
env.messages.error(HTML, tree, "dc.anchor.value.missing");
} else {
if (!validName.matcher(value).matches()) {
if (!validId.matcher(value).matches()) {
env.messages.error(HTML, tree, "dc.invalid.anchor", value);
}
if (!checkAnchor(value)) {
@@ -674,12 +671,20 @@ public Void visitAttribute(AttributeTree tree, Void ignore) {
if (currTag == HtmlTag.TABLE) {
String v = getAttrValue(tree);
try {
if (env.htmlVersion == HtmlVersion.HTML5
&& (v == null || (!v.isEmpty() && Integer.parseInt(v) != 1))) {
env.messages.error(HTML, tree, "dc.attr.table.border.html5", attr);
if (v == null || (!v.isEmpty() && Integer.parseInt(v) != 1)) {
env.messages.error(HTML, tree, "dc.attr.table.border.not.valid", attr);
}
} catch (NumberFormatException ex) {
env.messages.error(HTML, tree, "dc.attr.table.border.not.number", attr);
}
} else if (currTag == HtmlTag.IMG) {
String v = getAttrValue(tree);
try {
if (v == null || (!v.isEmpty() && Integer.parseInt(v) != 0)) {
env.messages.error(HTML, tree, "dc.attr.img.border.not.valid", attr);
}
} catch (NumberFormatException ex) {
env.messages.error(HTML, tree, "dc.attr.table.border.html5", attr);
env.messages.error(HTML, tree, "dc.attr.img.border.not.number", attr);
}
}
break;
@@ -701,44 +706,6 @@ public Void visitAttribute(AttributeTree tree, Void ignore) {
return null;
}

private void validateHtml4Attrs(AttributeTree tree, Name name, AttrKind k) {
switch (k) {
case ALL:
case HTML4:
break;

case INVALID:
env.messages.error(HTML, tree, "dc.attr.unknown", name);
break;

case OBSOLETE:
env.messages.warning(HTML, tree, "dc.attr.obsolete", name);
break;

case USE_CSS:
env.messages.warning(HTML, tree, "dc.attr.obsolete.use.css", name);
break;

case HTML5:
env.messages.error(HTML, tree, "dc.attr.not.supported.html4", name);
break;
}
}

private void validateHtml5Attrs(AttributeTree tree, Name name, AttrKind k) {
switch (k) {
case ALL:
case HTML5:
break;

case INVALID:
case OBSOLETE:
case USE_CSS:
case HTML4:
env.messages.error(HTML, tree, "dc.attr.not.supported.html5", name);
break;
}
}

private boolean checkAnchor(String name) {
Element e = getEnclosingPackageOrClass(env.currElement);
@@ -765,8 +732,8 @@ private Element getEnclosingPackageOrClass(Element e) {
return e;
}

// http://www.w3.org/TR/html401/types.html#type-name
private static final Pattern validName = Pattern.compile("[A-Za-z][A-Za-z0-9-_:.]*");
// https://html.spec.whatwg.org/#the-id-attribute
private static final Pattern validId = Pattern.compile("[^\\s]+");

private static final Pattern validNumber = Pattern.compile("-?[0-9]+");

@@ -83,7 +83,6 @@ public class DocLint extends com.sun.tools.doclint.DocLint {
public static final String XMSGS_CUSTOM_PREFIX = "-Xmsgs:";
private static final String STATS = "-stats";
public static final String XCUSTOM_TAGS_PREFIX = "-XcustomTags:";
public static final String XHTML_VERSION_PREFIX = "-XhtmlVersion:";
public static final String XCHECK_PACKAGE = "-XcheckPackage:";
public static final String SEPARATOR = ",";

@@ -223,14 +222,6 @@ void processArgs(String... args) throws BadArgs {
env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));
} else if (arg.startsWith(XCUSTOM_TAGS_PREFIX)) {
env.setCustomTags(arg.substring(arg.indexOf(":") + 1));
} else if (arg.startsWith(XHTML_VERSION_PREFIX)) {
String argsVersion = arg.substring(arg.indexOf(":") + 1);
HtmlVersion htmlVersion = HtmlVersion.getHtmlVersion(argsVersion);
if (htmlVersion != null) {
env.setHtmlVersion(htmlVersion);
} else {
throw new BadArgs("dc.bad.value.for.option", arg, argsVersion);
}
} else if (arg.equals("-h") || arg.equals("-help") || arg.equals("--help")
|| arg.equals("-?") || arg.equals("-usage")) {
needHelp = true;
@@ -345,14 +336,6 @@ private void processArgs(Env env, String... args) {
env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));
} else if (arg.startsWith(XCUSTOM_TAGS_PREFIX)) {
env.setCustomTags(arg.substring(arg.indexOf(":") + 1));
} else if (arg.startsWith(XHTML_VERSION_PREFIX)) {
String argsVersion = arg.substring(arg.indexOf(":") + 1);
HtmlVersion htmlVersion = HtmlVersion.getHtmlVersion(argsVersion);
if (htmlVersion != null) {
env.setHtmlVersion(htmlVersion);
} else {
throw new IllegalArgumentException(argsVersion);
}
} else if (arg.startsWith(XCHECK_PACKAGE)) {
env.setCheckPackages(arg.substring(arg.indexOf(":") + 1));
} else
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2020, 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
@@ -98,8 +98,6 @@ else if (mods.contains(Modifier.PRIVATE))
Set<Pattern> includePackages;
Set<Pattern> excludePackages;

HtmlVersion htmlVersion = HtmlVersion.HTML4;

// Utility classes
DocTrees trees;
Elements elements;
@@ -190,10 +188,6 @@ static boolean validatePackages(String packages) {
return true;
}

void setHtmlVersion(HtmlVersion version) {
htmlVersion = version;
}

/** Set the current declaration and its doc comment. */
void setCurrent(TreePath path, DocCommentTree comment) {
currPath = path;

0 comments on commit 28e1f4d

Please sign in to comment.