Skip to content

Commit 28e1f4d

Browse files
Yoshiki Satojonathan-gibbons
authored andcommitted
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
1 parent 80544e4 commit 28e1f4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+494
-891
lines changed

make/common/JavaCompilation.gmk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ define SetupJavaCompilationBody
269269
# Tell javac to do exactly as told and no more
270270
PARANOIA_FLAGS := -implicit:none -Xprefer:source -XDignore.symbol.file=true -encoding ascii
271271

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

275275
ifneq ($$($1_DISABLED_WARNINGS), )

src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
public abstract class DocLint implements Plugin {
4242
public static final String XMSGS_OPTION = "-Xmsgs";
4343
public static final String XMSGS_CUSTOM_PREFIX = "-Xmsgs:";
44-
public static final String XHTML_VERSION_PREFIX = "-XhtmlVersion:";
4544
public static final String XCHECK_PACKAGE = "-XcheckPackage:";
4645

4746
private static ServiceLoader.Provider<DocLint> docLintProvider;

src/jdk.compiler/share/classes/com/sun/tools/javac/main/Arguments.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,11 +853,6 @@ public List<String> getDocLintOpts() {
853853
doclintOpts.add(DocLint.XCHECK_PACKAGE + checkPackages);
854854
}
855855

856-
String format = options.get(Option.DOCLINT_FORMAT);
857-
if (format != null) {
858-
doclintOpts.add(DocLint.XHTML_VERSION_PREFIX + format);
859-
}
860-
861856
return List.from(doclintOpts.toArray(new String[doclintOpts.size()]));
862857
}
863858

src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ public void process(OptionHelper helper, String option, String arg) {
159159
}
160160
},
161161

162-
DOCLINT_FORMAT("--doclint-format", "opt.doclint.format", EXTENDED, BASIC, ONEOF, "html5"),
163-
164162
// -nowarn is retained for command-line backward compatibility
165163
NOWARN("-nowarn", "opt.nowarn", STANDARD, BASIC) {
166164
@Override

src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,6 @@ javac.opt.Xdoclint.package.desc=\
286286
expands to all sub-packages of the given package. Each <package> can be prefixed\n\
287287
with '-' to disable checks for the specified package or packages.
288288

289-
javac.opt.doclint.format=\
290-
Specify the format for documentation comments
291-
292289
javac.opt.Xstdout=\
293290
Redirect standard output
294291
javac.opt.X=\

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,6 @@ public void initDocLint(List<String> opts, Set<String> customTagNames) {
798798
doclintOpts.add(DocLint.XCUSTOM_TAGS_PREFIX + customTags);
799799
}
800800

801-
doclintOpts.add(DocLint.XHTML_VERSION_PREFIX + "html5");
802-
803801
doclint = new DocLint();
804802
doclint.init(docEnv.getDocTrees(), docEnv.getElementUtils(), docEnv.getTypeUtils(),
805803
doclintOpts.toArray(new String[0]));

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Checker.java

Lines changed: 32 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import com.sun.tools.javac.util.DefinedBy.Api;
9292

9393
import jdk.javadoc.internal.doclint.HtmlTag.AttrKind;
94+
import jdk.javadoc.internal.doclint.HtmlTag.ElemKind;
9495
import static jdk.javadoc.internal.doclint.Messages.Group.*;
9596

9697

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

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

536536
case SECTION:
537537
case ARTICLE:
538-
if (env.htmlVersion == HtmlVersion.HTML5 && !top.flags.contains(Flag.HAS_HEADING)) {
538+
if (!top.flags.contains(Flag.HAS_HEADING)) {
539539
env.messages.error(HTML, tree, "dc.tag.requires.heading", treeName);
540540
}
541541
break;
@@ -579,7 +579,8 @@ void warnIfEmpty(TagStackItem tsi, DocTree endTree) {
579579
if (tsi.tag.flags.contains(HtmlTag.Flag.EXPECT_CONTENT)
580580
&& !tsi.flags.contains(Flag.HAS_TEXT)
581581
&& !tsi.flags.contains(Flag.HAS_ELEMENT)
582-
&& !tsi.flags.contains(Flag.HAS_INLINE_TAG)) {
582+
&& !tsi.flags.contains(Flag.HAS_INLINE_TAG)
583+
&& !(tsi.tag.elemKind == ElemKind.HTML4)) {
583584
DocTree tree = (endTree != null) ? endTree : tsi.tree;
584585
Name treeName = ((StartElementTree) tsi.tree).getName();
585586
env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
@@ -594,13 +595,10 @@ void warnIfEmpty(TagStackItem tsi, DocTree endTree) {
594595
@Override @DefinedBy(Api.COMPILER_TREE) @SuppressWarnings("fallthrough")
595596
public Void visitAttribute(AttributeTree tree, Void ignore) {
596597
HtmlTag currTag = tagStack.peek().tag;
597-
if (currTag != null) {
598+
if (currTag != null && currTag.elemKind != ElemKind.HTML4) {
598599
Name name = tree.getName();
599600
HtmlTag.Attr attr = currTag.getAttr(name);
600601
if (attr != null) {
601-
if (env.htmlVersion == HtmlVersion.HTML4 && attr.name().contains("-")) {
602-
env.messages.error(HTML, tree, "dc.attr.not.supported.html4", name);
603-
}
604602
boolean first = tagStack.peek().attrs.add(attr);
605603
if (!first)
606604
env.messages.error(HTML, tree, "dc.attr.repeated", name);
@@ -609,30 +607,29 @@ public Void visitAttribute(AttributeTree tree, Void ignore) {
609607
// without checking the validity or applicability of the name
610608
if (!name.toString().startsWith("on")) {
611609
AttrKind k = currTag.getAttrKind(name);
612-
switch (env.htmlVersion) {
610+
switch (k) {
611+
case OK:
612+
break;
613+
case OBSOLETE:
614+
env.messages.warning(HTML, tree, "dc.attr.obsolete", name);
615+
break;
613616
case HTML4:
614-
validateHtml4Attrs(tree, name, k);
617+
env.messages.error(HTML, tree, "dc.attr.not.supported.html5", name);
615618
break;
616-
617-
case HTML5:
618-
validateHtml5Attrs(tree, name, k);
619+
case INVALID:
620+
env.messages.error(HTML, tree, "dc.attr.unknown", name);
619621
break;
620622
}
621623
}
622624

623625
if (attr != null) {
624626
switch (attr) {
625-
case NAME:
626-
if (currTag != HtmlTag.A) {
627-
break;
628-
}
629-
// fallthrough
630627
case ID:
631628
String value = getAttrValue(tree);
632629
if (value == null) {
633630
env.messages.error(HTML, tree, "dc.anchor.value.missing");
634631
} else {
635-
if (!validName.matcher(value).matches()) {
632+
if (!validId.matcher(value).matches()) {
636633
env.messages.error(HTML, tree, "dc.invalid.anchor", value);
637634
}
638635
if (!checkAnchor(value)) {
@@ -674,12 +671,20 @@ public Void visitAttribute(AttributeTree tree, Void ignore) {
674671
if (currTag == HtmlTag.TABLE) {
675672
String v = getAttrValue(tree);
676673
try {
677-
if (env.htmlVersion == HtmlVersion.HTML5
678-
&& (v == null || (!v.isEmpty() && Integer.parseInt(v) != 1))) {
679-
env.messages.error(HTML, tree, "dc.attr.table.border.html5", attr);
674+
if (v == null || (!v.isEmpty() && Integer.parseInt(v) != 1)) {
675+
env.messages.error(HTML, tree, "dc.attr.table.border.not.valid", attr);
676+
}
677+
} catch (NumberFormatException ex) {
678+
env.messages.error(HTML, tree, "dc.attr.table.border.not.number", attr);
679+
}
680+
} else if (currTag == HtmlTag.IMG) {
681+
String v = getAttrValue(tree);
682+
try {
683+
if (v == null || (!v.isEmpty() && Integer.parseInt(v) != 0)) {
684+
env.messages.error(HTML, tree, "dc.attr.img.border.not.valid", attr);
680685
}
681686
} catch (NumberFormatException ex) {
682-
env.messages.error(HTML, tree, "dc.attr.table.border.html5", attr);
687+
env.messages.error(HTML, tree, "dc.attr.img.border.not.number", attr);
683688
}
684689
}
685690
break;
@@ -701,44 +706,6 @@ public Void visitAttribute(AttributeTree tree, Void ignore) {
701706
return null;
702707
}
703708

704-
private void validateHtml4Attrs(AttributeTree tree, Name name, AttrKind k) {
705-
switch (k) {
706-
case ALL:
707-
case HTML4:
708-
break;
709-
710-
case INVALID:
711-
env.messages.error(HTML, tree, "dc.attr.unknown", name);
712-
break;
713-
714-
case OBSOLETE:
715-
env.messages.warning(HTML, tree, "dc.attr.obsolete", name);
716-
break;
717-
718-
case USE_CSS:
719-
env.messages.warning(HTML, tree, "dc.attr.obsolete.use.css", name);
720-
break;
721-
722-
case HTML5:
723-
env.messages.error(HTML, tree, "dc.attr.not.supported.html4", name);
724-
break;
725-
}
726-
}
727-
728-
private void validateHtml5Attrs(AttributeTree tree, Name name, AttrKind k) {
729-
switch (k) {
730-
case ALL:
731-
case HTML5:
732-
break;
733-
734-
case INVALID:
735-
case OBSOLETE:
736-
case USE_CSS:
737-
case HTML4:
738-
env.messages.error(HTML, tree, "dc.attr.not.supported.html5", name);
739-
break;
740-
}
741-
}
742709

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

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

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

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/DocLint.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public class DocLint extends com.sun.tools.doclint.DocLint {
8383
public static final String XMSGS_CUSTOM_PREFIX = "-Xmsgs:";
8484
private static final String STATS = "-stats";
8585
public static final String XCUSTOM_TAGS_PREFIX = "-XcustomTags:";
86-
public static final String XHTML_VERSION_PREFIX = "-XhtmlVersion:";
8786
public static final String XCHECK_PACKAGE = "-XcheckPackage:";
8887
public static final String SEPARATOR = ",";
8988

@@ -223,14 +222,6 @@ void processArgs(String... args) throws BadArgs {
223222
env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));
224223
} else if (arg.startsWith(XCUSTOM_TAGS_PREFIX)) {
225224
env.setCustomTags(arg.substring(arg.indexOf(":") + 1));
226-
} else if (arg.startsWith(XHTML_VERSION_PREFIX)) {
227-
String argsVersion = arg.substring(arg.indexOf(":") + 1);
228-
HtmlVersion htmlVersion = HtmlVersion.getHtmlVersion(argsVersion);
229-
if (htmlVersion != null) {
230-
env.setHtmlVersion(htmlVersion);
231-
} else {
232-
throw new BadArgs("dc.bad.value.for.option", arg, argsVersion);
233-
}
234225
} else if (arg.equals("-h") || arg.equals("-help") || arg.equals("--help")
235226
|| arg.equals("-?") || arg.equals("-usage")) {
236227
needHelp = true;
@@ -345,14 +336,6 @@ private void processArgs(Env env, String... args) {
345336
env.messages.setOptions(arg.substring(arg.indexOf(":") + 1));
346337
} else if (arg.startsWith(XCUSTOM_TAGS_PREFIX)) {
347338
env.setCustomTags(arg.substring(arg.indexOf(":") + 1));
348-
} else if (arg.startsWith(XHTML_VERSION_PREFIX)) {
349-
String argsVersion = arg.substring(arg.indexOf(":") + 1);
350-
HtmlVersion htmlVersion = HtmlVersion.getHtmlVersion(argsVersion);
351-
if (htmlVersion != null) {
352-
env.setHtmlVersion(htmlVersion);
353-
} else {
354-
throw new IllegalArgumentException(argsVersion);
355-
}
356339
} else if (arg.startsWith(XCHECK_PACKAGE)) {
357340
env.setCheckPackages(arg.substring(arg.indexOf(":") + 1));
358341
} else

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/Env.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -98,8 +98,6 @@ else if (mods.contains(Modifier.PRIVATE))
9898
Set<Pattern> includePackages;
9999
Set<Pattern> excludePackages;
100100

101-
HtmlVersion htmlVersion = HtmlVersion.HTML4;
102-
103101
// Utility classes
104102
DocTrees trees;
105103
Elements elements;
@@ -190,10 +188,6 @@ static boolean validatePackages(String packages) {
190188
return true;
191189
}
192190

193-
void setHtmlVersion(HtmlVersion version) {
194-
htmlVersion = version;
195-
}
196-
197191
/** Set the current declaration and its doc comment. */
198192
void setCurrent(TreePath path, DocCommentTree comment) {
199193
currPath = path;

0 commit comments

Comments
 (0)