--- a/langtools/src/share/classes/com/sun/tools/doclint/Checker.java Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclint/Checker.java Mon Jan 21 11:16:28 2013 -0800
@@ -92,10 +92,11 @@
boolean foundInheritDoc = false;
boolean foundReturn = false;
- enum Flag {
+ public enum Flag {
TABLE_HAS_CAPTION,
HAS_ELEMENT,
- HAS_TEXT
+ HAS_TEXT,
+ REPORTED_BAD_INLINE
}
static class TagStackItem {
@@ -195,7 +196,8 @@
@Override
public Void visitText(TextTree tree, Void ignore) {
- if (!tree.getBody().trim().isEmpty()) {
+ if (hasNonWhitespace(tree)) {
+ checkAllowsText(tree);
markEnclosingTag(Flag.HAS_TEXT);
}
return null;
@@ -203,6 +205,7 @@
@Override
public Void visitEntity(EntityTree tree, Void ignore) {
+ checkAllowsText(tree);
markEnclosingTag(Flag.HAS_TEXT);
String name = tree.getName().toString();
if (name.startsWith("#")) {
@@ -218,6 +221,18 @@
return null;
}
+ void checkAllowsText(DocTree tree) {
+ TagStackItem top = tagStack.peek();
+ if (top != null
+ && top.tree.getKind() == DocTree.Kind.START_ELEMENT
+ && !top.tag.acceptsText()) {
+ if (top.flags.add(Flag.REPORTED_BAD_INLINE)) {
+ env.messages.error(HTML, tree, "dc.text.not.allowed",
+ ((StartElementTree) top.tree).getName());
+ }
+ }
+ }
+
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="HTML elements">
@@ -230,53 +245,22 @@
if (t == null) {
env.messages.error(HTML, tree, "dc.tag.unknown", treeName);
} else {
+ for (TagStackItem tsi: tagStack) {
+ if (tsi.tag.accepts(t)) {
+ while (tagStack.peek() != tsi) tagStack.pop();
+ break;
+ } else if (tsi.tag.endKind != HtmlTag.EndKind.OPTIONAL)
+ break;
+ }
+
+ checkStructure(tree, t);
+
// tag specific checks
switch (t) {
// check for out of sequence headers, such as <h1>...</h1> <h3>...</h3>
case H1: case H2: case H3: case H4: case H5: case H6:
checkHeader(tree, t);
break;
- // <p> inside <pre>
- case P:
- TagStackItem top = tagStack.peek();
- if (top != null && top.tag == HtmlTag.PRE)
- env.messages.warning(HTML, tree, "dc.tag.p.in.pre");
- break;
- }
-
- // check that only block tags and inline tags are used,
- // and that blocks tags are not used within inline tags
- switch (t.blockType) {
- case INLINE:
- break;
- case BLOCK:
- TagStackItem top = tagStack.peek();
- if (top != null && top.tag != null && top.tag.blockType == HtmlTag.BlockType.INLINE) {
- switch (top.tree.getKind()) {
- case START_ELEMENT: {
- Name name = ((StartElementTree) top.tree).getName();
- env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.element",
- treeName, name);
- break;
- }
- case LINK:
- case LINK_PLAIN: {
- String name = top.tree.getKind().tagName;
- env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.tag",
- treeName, name);
- break;
- }
- default:
- env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.other",
- treeName);
- }
- }
- break;
- case OTHER:
- env.messages.error(HTML, tree, "dc.tag.not.allowed", treeName);
- break;
- default:
- throw new AssertionError();
}
if (t.flags.contains(HtmlTag.Flag.NO_NEST)) {
@@ -324,6 +308,58 @@
}
}
+ private void checkStructure(StartElementTree tree, HtmlTag t) {
+ Name treeName = tree.getName();
+ TagStackItem top = tagStack.peek();
+ switch (t.blockType) {
+ case BLOCK:
+ if (top == null || top.tag.accepts(t))
+ return;
+
+ switch (top.tree.getKind()) {
+ case START_ELEMENT: {
+ if (top.tag.blockType == HtmlTag.BlockType.INLINE) {
+ Name name = ((StartElementTree) top.tree).getName();
+ env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.element",
+ treeName, name);
+ return;
+ }
+ }
+ break;
+
+ case LINK:
+ case LINK_PLAIN: {
+ String name = top.tree.getKind().tagName;
+ env.messages.error(HTML, tree, "dc.tag.not.allowed.inline.tag",
+ treeName, name);
+ return;
+ }
+ }
+ break;
+
+ case INLINE:
+ if (top == null || top.tag.accepts(t))
+ return;
+ break;
+
+ case LIST_ITEM:
+ case TABLE_ITEM:
+ if (top != null) {
+ // reset this flag so subsequent bad inline content gets reported
+ top.flags.remove(Flag.REPORTED_BAD_INLINE);
+ if (top.tag.accepts(t))
+ return;
+ }
+ break;
+
+ case OTHER:
+ env.messages.error(HTML, tree, "dc.tag.not.allowed", treeName);
+ return;
+ }
+
+ env.messages.error(HTML, tree, "dc.tag.not.allowed.here", treeName);
+ }
+
private void checkHeader(StartElementTree tree, HtmlTag tag) {
// verify the new tag
if (getHeaderLevel(tag) > getHeaderLevel(currHeaderTag) + 1) {
@@ -378,10 +414,6 @@
&& !top.flags.contains(Flag.HAS_ELEMENT)) {
env.messages.warning(HTML, tree, "dc.tag.empty", treeName);
}
- if (t.flags.contains(HtmlTag.Flag.NO_TEXT)
- && top.flags.contains(Flag.HAS_TEXT)) {
- env.messages.error(HTML, tree, "dc.text.not.allowed", treeName);
- }
tagStack.pop();
done = true;
break;
@@ -763,7 +795,7 @@
for (DocTree d: list) {
switch (d.getKind()) {
case TEXT:
- if (!((TextTree) d).getBody().trim().isEmpty())
+ if (hasNonWhitespace((TextTree) d))
return;
break;
default:
@@ -772,6 +804,16 @@
}
env.messages.warning(SYNTAX, tree, "dc.empty", tree.getKind().tagName);
}
+
+ boolean hasNonWhitespace(TextTree tree) {
+ String s = tree.getBody();
+ for (int i = 0; i < s.length(); i++) {
+ if (!Character.isWhitespace(s.charAt(i)))
+ return true;
+ }
+ return false;
+ }
+
// </editor-fold>
}
--- a/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java Mon Jan 21 11:16:28 2013 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -122,7 +122,7 @@
if (javacFiles.isEmpty()) {
if (!needHelp)
- System.out.println("no files given");
+ out.println("no files given");
}
JavacTool tool = JavacTool.create();
@@ -179,11 +179,11 @@
}
} else if (arg.equals(STATS)) {
env.messages.setStatsEnabled(true);
- } else if (arg.matches("-bootclasspath") && i + 1 < args.length) {
+ } else if (arg.equals("-bootclasspath") && i + 1 < args.length) {
javacBootClassPath = splitPath(args[++i]);
- } else if (arg.matches("-classpath") && i + 1 < args.length) {
+ } else if (arg.equals("-classpath") && i + 1 < args.length) {
javacClassPath = splitPath(args[++i]);
- } else if (arg.matches("-sourcepath") && i + 1 < args.length) {
+ } else if (arg.equals("-sourcepath") && i + 1 < args.length) {
javacSourcePath = splitPath(args[++i]);
} else if (arg.equals(XMSGS_OPTION)) {
env.messages.setOptions(null);
@@ -234,6 +234,8 @@
out.println(" equivalent to -Xmsgs:all/protected, meaning that");
out.println(" all messages are reported for protected and public");
out.println(" declarations only. ");
+ out.println(" -stats");
+ out.println(" Report statistics on the reported issues.");
out.println(" -h -help --help -usage -?");
out.println(" Show this message.");
out.println("");
@@ -247,7 +249,7 @@
List<File> splitPath(String path) {
List<File> files = new ArrayList<File>();
- for (String f: path.split(File.separator)) {
+ for (String f: path.split(File.pathSeparator)) {
if (f.length() > 0)
files.add(new File(f));
}
--- a/langtools/src/share/classes/com/sun/tools/doclint/Entity.java Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclint/Entity.java Mon Jan 21 11:16:28 2013 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -43,7 +43,7 @@
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.</b></p>
*/
-enum Entity {
+public enum Entity {
nbsp(160),
iexcl(161),
cent(162),
--- a/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java Mon Jan 21 11:16:28 2013 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2013, 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
@@ -57,16 +57,22 @@
B(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
- BLOCKQUOTE,
+ BIG(BlockType.INLINE, EndKind.REQUIRED,
+ EnumSet.of(Flag.EXPECT_CONTENT)),
+
+ BLOCKQUOTE(BlockType.BLOCK, EndKind.REQUIRED,
+ EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
BODY(BlockType.OTHER, EndKind.REQUIRED),
BR(BlockType.INLINE, EndKind.NONE,
attrs(AttrKind.USE_CSS, CLEAR)),
- CAPTION(EnumSet.of(Flag.EXPECT_CONTENT)),
+ CAPTION(BlockType.TABLE_ITEM, EndKind.REQUIRED,
+ EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
- CENTER,
+ CENTER(BlockType.BLOCK, EndKind.REQUIRED,
+ EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
CITE(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
@@ -74,17 +80,23 @@
CODE(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
- DD(BlockType.BLOCK, EndKind.OPTIONAL,
- EnumSet.of(Flag.EXPECT_CONTENT)),
+ DD(BlockType.LIST_ITEM, EndKind.OPTIONAL,
+ EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
- DIV,
+ DIV(BlockType.BLOCK, EndKind.REQUIRED,
+ EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
DL(BlockType.BLOCK, EndKind.REQUIRED,
- EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
- attrs(AttrKind.USE_CSS, COMPACT)),
+ EnumSet.of(Flag.EXPECT_CONTENT),
+ attrs(AttrKind.USE_CSS, COMPACT)) {
+ @Override
+ public boolean accepts(HtmlTag t) {
+ return (t == DT) || (t == DD);
+ }
+ },
- DT(BlockType.BLOCK, EndKind.OPTIONAL,
- EnumSet.of(Flag.EXPECT_CONTENT)),
+ DT(BlockType.LIST_ITEM, EndKind.OPTIONAL,
+ EnumSet.of(Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)),
EM(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.NO_NEST)),
@@ -97,12 +109,12 @@
FRAMESET(BlockType.OTHER, EndKind.REQUIRED),
- H1,
- H2,
- H3,
- H4,
- H5,
- H6,
+ H1(BlockType.BLOCK, EndKind.REQUIRED),
+ H2(BlockType.BLOCK, EndKind.REQUIRED),
+ H3(BlockType.BLOCK, EndKind.REQUIRED),
+ H4(BlockType.BLOCK, EndKind.REQUIRED),
+ H5(BlockType.BLOCK, EndKind.REQUIRED),
+ H6(BlockType.BLOCK, EndKind.REQUIRED),
HEAD(BlockType.OTHER, EndKind.REQUIRED),
@@ -118,31 +130,54 @@
attrs(AttrKind.OBSOLETE, NAME),
attrs(AttrKind.USE_CSS, ALIGN, HSPACE, VSPACE, BORDER)),
- LI(BlockType.BLOCK, EndKind.OPTIONAL),
+ LI(BlockType.LIST_ITEM, EndKind.OPTIONAL,
+ EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE)),
LINK(BlockType.OTHER, EndKind.NONE),
- MENU,
+ MENU(BlockType.BLOCK, EndKind.REQUIRED) {
+ @Override
+ public boolean accepts(HtmlTag t) {
+ return (t == LI);
+ }
+ },
META(BlockType.OTHER, EndKind.NONE),
NOFRAMES(BlockType.OTHER, EndKind.REQUIRED),
- NOSCRIPT(BlockType.OTHER, EndKind.REQUIRED),
+ NOSCRIPT(BlockType.BLOCK, EndKind.REQUIRED),
OL(BlockType.BLOCK, EndKind.REQUIRED,
- EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
- attrs(AttrKind.USE_CSS, START, TYPE)),
+ EnumSet.of(Flag.EXPECT_CONTENT),
+ attrs(AttrKind.USE_CSS, START, TYPE)){
+ @Override
+ public boolean accepts(HtmlTag t) {
+ return (t == LI);
+ }
+ },
P(BlockType.BLOCK, EndKind.OPTIONAL,
EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.USE_CSS, ALIGN)),
- PRE(EnumSet.of(Flag.EXPECT_CONTENT)),
+ PRE(BlockType.BLOCK, EndKind.REQUIRED,
+ EnumSet.of(Flag.EXPECT_CONTENT)) {
+ @Override
+ public boolean accepts(HtmlTag t) {
+ switch (t) {
+ case IMG: case BIG: case SMALL: case SUB: case SUP:
+ return false;
+ default:
+ return (t.blockType == BlockType.INLINE);
+ }
+ }
+ },
SCRIPT(BlockType.OTHER, EndKind.REQUIRED),
- SMALL(BlockType.INLINE, EndKind.REQUIRED),
+ SMALL(BlockType.INLINE, EndKind.REQUIRED,
+ EnumSet.of(Flag.EXPECT_CONTENT)),
SPAN(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT)),
@@ -157,37 +192,70 @@
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
TABLE(BlockType.BLOCK, EndKind.REQUIRED,
- EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
+ EnumSet.of(Flag.EXPECT_CONTENT),
attrs(AttrKind.OK, SUMMARY, Attr.FRAME, RULES, BORDER,
CELLPADDING, CELLSPACING),
- attrs(AttrKind.USE_CSS, ALIGN, WIDTH, BGCOLOR)),
+ attrs(AttrKind.USE_CSS, ALIGN, WIDTH, BGCOLOR)) {
+ @Override
+ public boolean accepts(HtmlTag t) {
+ switch (t) {
+ case CAPTION:
+ case THEAD: case TBODY: case TFOOT:
+ case TR: // HTML 3.2
+ return true;
+ default:
+ return false;
+ }
+ }
+ },
- TBODY(BlockType.BLOCK, EndKind.REQUIRED,
- EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
- attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)),
+ TBODY(BlockType.TABLE_ITEM, EndKind.REQUIRED,
+ EnumSet.of(Flag.EXPECT_CONTENT),
+ attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
+ @Override
+ public boolean accepts(HtmlTag t) {
+ return (t == TR);
+ }
+ },
- TD(BlockType.BLOCK, EndKind.OPTIONAL,
+ TD(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
+ EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
ALIGN, CHAR, CHAROFF, VALIGN),
attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
- TFOOT(BlockType.BLOCK, EndKind.REQUIRED,
- attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)),
+ TFOOT(BlockType.TABLE_ITEM, EndKind.REQUIRED,
+ attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
+ @Override
+ public boolean accepts(HtmlTag t) {
+ return (t == TR);
+ }
+ },
- TH(BlockType.BLOCK, EndKind.OPTIONAL,
+ TH(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
+ EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE),
attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS,
ALIGN, CHAR, CHAROFF, VALIGN),
attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)),
- THEAD(BlockType.BLOCK, EndKind.REQUIRED,
- attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)),
+ THEAD(BlockType.TABLE_ITEM, EndKind.REQUIRED,
+ attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN)) {
+ @Override
+ public boolean accepts(HtmlTag t) {
+ return (t == TR);
+ }
+ },
TITLE(BlockType.OTHER, EndKind.REQUIRED),
- TR(BlockType.BLOCK, EndKind.OPTIONAL,
- EnumSet.of(Flag.NO_TEXT),
+ TR(BlockType.TABLE_ITEM, EndKind.OPTIONAL,
attrs(AttrKind.OK, ALIGN, CHAR, CHAROFF, VALIGN),
- attrs(AttrKind.USE_CSS, BGCOLOR)),
+ attrs(AttrKind.USE_CSS, BGCOLOR)) {
+ @Override
+ public boolean accepts(HtmlTag t) {
+ return (t == TH) || (t == TD);
+ }
+ },
TT(BlockType.INLINE, EndKind.REQUIRED,
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
@@ -196,8 +264,13 @@
EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)),
UL(BlockType.BLOCK, EndKind.REQUIRED,
- EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_TEXT),
- attrs(AttrKind.USE_CSS, COMPACT, TYPE)),
+ EnumSet.of(Flag.EXPECT_CONTENT),
+ attrs(AttrKind.USE_CSS, COMPACT, TYPE)){
+ @Override
+ public boolean accepts(HtmlTag t) {
+ return (t == LI);
+ }
+ },
VAR(BlockType.INLINE, EndKind.REQUIRED);
@@ -207,6 +280,8 @@
public static enum BlockType {
BLOCK,
INLINE,
+ LIST_ITEM,
+ TABLE_ITEM,
OTHER;
}
@@ -220,9 +295,10 @@
}
public static enum Flag {
+ ACCEPTS_BLOCK,
+ ACCEPTS_INLINE,
EXPECT_CONTENT,
- NO_NEST,
- NO_TEXT
+ NO_NEST
}
public static enum Attr {
@@ -273,7 +349,7 @@
static final Map<String,Attr> index = new HashMap<String,Attr>();
static {
for (Attr t: values()) {
- index.put(t.name().toLowerCase(), t);
+ index.put(t.getText(), t);
}
}
}
@@ -300,22 +376,14 @@
public final Set<Flag> flags;
private final Map<Attr,AttrKind> attrs;
-
- HtmlTag() {
- this(BlockType.BLOCK, EndKind.REQUIRED);
- }
-
- HtmlTag(Set<Flag> flags) {
- this(BlockType.BLOCK, EndKind.REQUIRED, flags);
- }
-
HtmlTag(BlockType blockType, EndKind endKind, AttrMap... attrMaps) {
this(blockType, endKind, Collections.<Flag>emptySet(), attrMaps);
}
HtmlTag(BlockType blockType, EndKind endKind, Set<Flag> flags, AttrMap... attrMaps) {
this.blockType = blockType;
- this.endKind = endKind;this.flags = flags;
+ this.endKind = endKind;
+ this.flags = flags;
this.attrs = new EnumMap<Attr,AttrKind>(Attr.class);
for (Map<Attr,AttrKind> m: attrMaps)
this.attrs.putAll(m);
@@ -324,6 +392,35 @@
attrs.put(Attr.STYLE, AttrKind.OK);
}
+ public boolean accepts(HtmlTag t) {
+ if (flags.contains(Flag.ACCEPTS_BLOCK) && flags.contains(Flag.ACCEPTS_INLINE)) {
+ return (t.blockType == BlockType.BLOCK) || (t.blockType == BlockType.INLINE);
+ } else if (flags.contains(Flag.ACCEPTS_BLOCK)) {
+ return (t.blockType == BlockType.BLOCK);
+ } else if (flags.contains(Flag.ACCEPTS_INLINE)) {
+ return (t.blockType == BlockType.INLINE);
+ } else
+ switch (blockType) {
+ case BLOCK:
+ case INLINE:
+ return (t.blockType == BlockType.INLINE);
+ case OTHER:
+ // OTHER tags are invalid in doc comments, and will be
+ // reported separately, so silently accept/ignore any content
+ return true;
+ default:
+ // any combination which could otherwise arrive here
+ // ought to have been handled in an overriding method
+ throw new AssertionError(this + ":" + t);
+ }
+ }
+
+ public boolean acceptsText() {
+ // generally, anywhere we can put text we can also put inline tag
+ // so check if a typical inline tag is allowed
+ return accepts(B);
+ }
+
public String getText() {
return name().toLowerCase();
}
@@ -346,7 +443,7 @@
private static final Map<String,HtmlTag> index = new HashMap<String,HtmlTag>();
static {
for (HtmlTag t: values()) {
- index.put(t.name().toLowerCase(), t);
+ index.put(t.getText(), t);
}
}
--- a/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclint/resources/doclint.properties Mon Jan 21 11:16:28 2013 -0800
@@ -55,6 +55,7 @@
dc.tag.header.sequence.1 = header used out of sequence: <{0}>
dc.tag.header.sequence.2 = header used out of sequence: <{0}>
dc.tag.nested.not.allowed=nested tag not allowed: <{0}>
+dc.tag.not.allowed.here = tag not allowed here: <{0}>
dc.tag.not.allowed = element not allowed in documentation comments: <{0}>
dc.tag.not.allowed.inline.element = block element not allowed within inline element <{1}>: {0}
dc.tag.not.allowed.inline.tag = block element not allowed within @{1}: {0}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/CoverageExtras.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8006263
+ * @summary Supplementary test cases needed for doclint
+ */
+
+import com.sun.tools.doclint.Checker;
+import com.sun.tools.doclint.Entity;
+import com.sun.tools.doclint.HtmlTag;
+import com.sun.tools.doclint.Messages;
+import java.util.Objects;
+
+public class CoverageExtras {
+ public static void main(String... args) {
+ new CoverageExtras().run();
+ }
+
+ void run() {
+ check(HtmlTag.A, HtmlTag.valueOf("A"), HtmlTag.values());
+ check(HtmlTag.Attr.ABBR, HtmlTag.Attr.valueOf("ABBR"), HtmlTag.Attr.values());
+ check(HtmlTag.AttrKind.INVALID, HtmlTag.AttrKind.valueOf("INVALID"), HtmlTag.AttrKind.values());
+ check(HtmlTag.BlockType.BLOCK, HtmlTag.BlockType.valueOf("BLOCK"), HtmlTag.BlockType.values());
+ check(HtmlTag.EndKind.NONE, HtmlTag.EndKind.valueOf("NONE"), HtmlTag.EndKind.values());
+ check(HtmlTag.Flag.EXPECT_CONTENT, HtmlTag.Flag.valueOf("EXPECT_CONTENT"), HtmlTag.Flag.values());
+
+ check(Checker.Flag.TABLE_HAS_CAPTION, Checker.Flag.valueOf("TABLE_HAS_CAPTION"), Checker.Flag.values());
+
+ check(Entity.nbsp, Entity.valueOf("nbsp"), Entity.values());
+
+ check(Messages.Group.ACCESSIBILITY, Messages.Group.valueOf("ACCESSIBILITY"), Messages.Group.values());
+ }
+
+ <T extends Enum<T>> void check(T expect, T value, T[] values) {
+ if (!Objects.equals(expect, value)) {
+ error("Mismatch: '" + expect + "', '" + value + "'");
+ }
+ if (!Objects.equals(expect, values[0])) {
+ error("Mismatch: '" + expect + "', '" + values[0] + "'");
+ }
+ }
+
+ void error(String msg) {
+ System.err.println("Error: " + msg);
+ errors++;
+ }
+
+ int errors;
+}
--- a/langtools/test/tools/doclint/DocLintTester.java Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/test/tools/doclint/DocLintTester.java Mon Jan 21 11:16:28 2013 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, 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
@@ -26,6 +26,7 @@
import java.util.List;
import com.sun.tools.doclint.DocLint;
+import com.sun.tools.doclint.DocLint.BadArgs;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
@@ -45,6 +46,7 @@
public void run(String... args) throws Exception {
String testSrc = System.getProperty("test.src");
+ boolean badArgs = false;
File refFile = null;
List<String> opts = new ArrayList<String>();
List<File> files = new ArrayList<File>();
@@ -52,19 +54,25 @@
String arg = args[i];
if (arg.equals("-ref")) {
refFile = new File(testSrc, args[++i]);
+ } else if (arg.equals("-badargs")) {
+ badArgs = true;
} else if (arg.startsWith("-Xmsgs")) {
opts.add(arg);
+ } else if (arg.startsWith("-")) {
+ opts.add(arg);
+ if (i < args.length - 1 && !args[i+1].startsWith("-"))
+ opts.add(args[++i]);
} else
files.add(new File(testSrc, arg));
}
- check(opts, files, refFile);
+ check(opts, files, badArgs, refFile);
if (errors > 0)
throw new Exception(errors + " errors occurred");
}
- void check(List<String> opts, List<File> files, File refFile) throws Exception {
+ void check(List<String> opts, List<File> files, boolean expectBadArgs, File refFile) throws Exception {
List<String> args = new ArrayList<String>();
args.addAll(opts);
for (File file: files)
@@ -72,7 +80,14 @@
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
- new DocLint().run(pw, args.toArray(new String[args.size()]));
+ try {
+ new DocLint().run(pw, args.toArray(new String[args.size()]));
+ if (expectBadArgs)
+ error("expected exception not thrown");
+ } catch (BadArgs e) {
+ if (!expectBadArgs)
+ error("unexpected exception caught: " + e);
+ }
pw.flush();
String out = normalizeNewlines(removeFileNames(sw.toString())).trim();
if (out != null)
--- a/langtools/test/tools/doclint/HtmlTagsTest.java Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/test/tools/doclint/HtmlTagsTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -54,5 +54,17 @@
* <i> </b> </i>
*/
public void end_unexpected() { }
+
+ /**
+ * <ul> text <li> ... </li> </ul>
+ */
+ public void text_not_allowed() { }
+
+ /**
+ * <ul> <b>text</b> <li> ... </li> </ul>
+ */
+ public void inline_not_allowed() { }
+
+
}
--- a/langtools/test/tools/doclint/HtmlTagsTest.out Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/test/tools/doclint/HtmlTagsTest.out Mon Jan 21 11:16:28 2013 -0800
@@ -34,5 +34,11 @@
HtmlTagsTest.java:54: warning: empty <i> tag
* <i> </b> </i>
^
-11 errors
+HtmlTagsTest.java:59: error: text not allowed in <ul> element
+ * <ul> text <li> ... </li> </ul>
+ ^
+HtmlTagsTest.java:64: error: tag not allowed here: <b>
+ * <ul> <b>text</b> <li> ... </li> </ul>
+ ^
+13 errors
1 warning
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/BlockTagsTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8006251
+ * @summary test block tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs BlockTagsTest.java
+ */
+
+/** */
+public class BlockTagsTest {
+ /**
+ * <blockquote> abc </blockquote>
+ * <center> abc </center>
+ * <div> abc </div>
+ * <dl> <dt> abc <dd> def </dl>
+ * <div> abc </div>
+ * <h1> abc </h1>
+ * <h2> abc </h2>
+ * <h3> abc </h3>
+ * <h4> abc </h4>
+ * <h5> abc </h5>
+ * <h6> abc </h6>
+ * <hr>
+ * <menu> <li> abc </menu>
+ * <noscript> </noscript>
+ * <ol> <li> abc </ol>
+ * <p> abc </p>
+ * <pre> abc </pre>
+ * <table summary="abc"> <tr> <td> </table>
+ * <ul> <li> abc </ul>
+ */
+ public void supportedTags() { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/EntitiesTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8006263
+ * @summary Supplementary test cases needed for doclint
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs:-html EntitiesTest.java
+ * @run main DocLintTester -Xmsgs:html -ref EntitiesTest.out EntitiesTest.java
+ */
+
+/** */
+class EntitiesTest {
+
+ /**
+ *    
+ * ࡎ ࡎ ࡎ
+ */
+ void range_test() { }
+
+ /**
+ *  
+ * ¡ ¡
+ * ¢ ¢
+ * £ £
+ * ¤ ¤
+ * ¥ ¥
+ * ¦ ¦
+ * § §
+ * ¨ ¨
+ * © ©
+ * ª ª
+ * « «
+ * ¬ ¬
+ * ­ ­
+ * ® ®
+ * ¯ ¯
+ * ° °
+ * ± ±
+ * ² ²
+ * ³ ³
+ * ´ ´
+ * µ µ
+ * ¶ ¶
+ * · ·
+ * ¸ ¸
+ * ¹ ¹
+ * º º
+ * » »
+ * ¼ ¼
+ * ½ ½
+ * ¾ ¾
+ * ¿ ¿
+ * À À
+ * Á Á
+ * Â Â
+ * Ã Ã
+ * Ä Ä
+ * Å Å
+ * Æ Æ
+ * Ç Ç
+ * È È
+ * É É
+ * Ê Ê
+ * Ë Ë
+ * Ì Ì
+ * Í Í
+ * Î Î
+ * Ï Ï
+ * Ð Ð
+ * Ñ Ñ
+ * Ò Ò
+ * Ó Ó
+ * Ô Ô
+ * Õ Õ
+ * Ö Ö
+ * × ×
+ * Ø Ø
+ * Ù Ù
+ * Ú Ú
+ * Û Û
+ * Ü Ü
+ * Ý Ý
+ * Þ Þ
+ * ß ß
+ * à à
+ * á á
+ * â â
+ * ã ã
+ * ä ä
+ * å å
+ * æ æ
+ * ç ç
+ * è è
+ * é é
+ * ê ê
+ * ë ë
+ * ì ì
+ * í í
+ * î î
+ * ï ï
+ * ð ð
+ * ñ ñ
+ * ò ò
+ * ó ó
+ * ô ô
+ * õ õ
+ * ö ö
+ * ÷ ÷
+ * ø ø
+ * ù ù
+ * ú ú
+ * û û
+ * ü ü
+ * ý ý
+ * þ þ
+ * ÿ ÿ
+ * ƒ ƒ
+ * Α Α
+ * Β Β
+ * Γ Γ
+ * Δ Δ
+ * Ε Ε
+ * Ζ Ζ
+ * Η Η
+ * Θ Θ
+ * Ι Ι
+ * Κ Κ
+ * Λ Λ
+ * Μ Μ
+ * Ν Ν
+ * Ξ Ξ
+ * Ο Ο
+ * Π Π
+ * Ρ Ρ
+ * Σ Σ
+ * Τ Τ
+ * Υ Υ
+ * Φ Φ
+ * Χ Χ
+ * Ψ Ψ
+ * Ω Ω
+ * α α
+ * β β
+ * γ γ
+ * δ δ
+ * ε ε
+ * ζ ζ
+ * η η
+ * θ θ
+ * ι ι
+ * κ κ
+ * λ λ
+ * μ μ
+ * ν ν
+ * ξ ξ
+ * ο ο
+ * π π
+ * ρ ρ
+ * ς ς
+ * σ σ
+ * τ τ
+ * υ υ
+ * φ φ
+ * χ χ
+ * ψ ψ
+ * ω ω
+ * ϑ ϑ
+ * ϒ ϒ
+ * ϖ ϖ
+ * • •
+ * … …
+ * ′ ′
+ * ″ ″
+ * ‾ ‾
+ * ⁄ ⁄
+ * ℘ ℘
+ * ℑ ℑ
+ * ℜ ℜ
+ * ™ ™
+ * ℵ ℵ
+ * ← ←
+ * ↑ ↑
+ * → →
+ * ↓ ↓
+ * ↔ ↔
+ * ↵ ↵
+ * ⇐ ⇐
+ * ⇑ ⇑
+ * ⇒ ⇒
+ * ⇓ ⇓
+ * ⇔ ⇔
+ * ∀ ∀
+ * ∂ ∂
+ * ∃ ∃
+ * ∅ ∅
+ * ∇ ∇
+ * ∈ ∈
+ * ∉ ∉
+ * ∋ ∋
+ * ∏ ∏
+ * ∑ ∑
+ * − −
+ * ∗ ∗
+ * √ √
+ * ∝ ∝
+ * ∞ ∞
+ * ∠ ∠
+ * ∧ ∧
+ * ∨ ∨
+ * ∩ ∩
+ * ∪ ∪
+ * &_int; ∫
+ * ∴ ∴
+ * ∼ ∼
+ * ≅ ≅
+ * ≈ ≈
+ * ≠ ≠
+ * ≡ ≡
+ * ≤ ≤
+ * ≥ ≥
+ * ⊂ ⊂
+ * ⊃ ⊃
+ * ⊄ ⊄
+ * ⊆ ⊆
+ * ⊇ ⊇
+ * ⊕ ⊕
+ * ⊗ ⊗
+ * ⊥ ⊥
+ * ⋅ ⋅
+ * ⌈ ⌈
+ * ⌉ ⌉
+ * ⌊ ⌊
+ * ⌋ ⌋
+ * ⟨ 〈
+ * ⟩ 〉
+ * ◊ ◊
+ * ♠ ♠
+ * ♣ ♣
+ * ♥ ♥
+ * ♦ ♦
+ * " "
+ * & &
+ * < <
+ * > >
+ * Œ Œ
+ * œ œ
+ * Š Š
+ * š š
+ * Ÿ Ÿ
+ * ˆ ˆ
+ * ˜ ˜
+ *    
+ *    
+ *    
+ * ‌ ‌
+ * ‍ ‍
+ * ‎ ‎
+ * ‏ ‏
+ * – –
+ * — —
+ * ‘ ‘
+ * ’ ’
+ * ‚ ‚
+ * “ “
+ * ” ”
+ * „ „
+ * † †
+ * ‡ ‡
+ * ‰ ‰
+ * ‹ ‹
+ * › ›
+ * € €
+ */
+ void symbolic_entities() { }
+
+ /**
+ * &bad;
+ */
+ void bad_name() { }
+
+ /**
+ * 
+ * ࡏ
+ */
+ void out_of_range() { }
+
+ /**
+ * ―
+ * ⌫
+ * 
+ */
+ void sparse_negative() { }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/EntitiesTest.out Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,19 @@
+EntitiesTest.java:300: error: invalid entity &bad;
+ * &bad;
+ ^
+EntitiesTest.java:305: error: invalid entity 
+ * 
+ ^
+EntitiesTest.java:306: error: invalid entity ࡏ
+ * ࡏ
+ ^
+EntitiesTest.java:311: error: invalid entity ―
+ * ―
+ ^
+EntitiesTest.java:312: error: invalid entity ⌫
+ * ⌫
+ ^
+EntitiesTest.java:313: error: invalid entity 
+ * 
+ ^
+6 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/InlineTagsTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8006251
+ * @summary test inline tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs InlineTagsTest.java
+ */
+
+/** */
+public class InlineTagsTest {
+ /**
+ * <a href="#abc"> abc </a>
+ * <b> abc </b>
+ * <big> abc </big>
+ * <br>
+ * <cite> abc </cite>
+ * <code> abc </code>
+ * <em> abc </em>
+ * <font> abc </font>
+ * <i> abc </i>
+ * <img alt="image" src="image.png">
+ * <small> abc </small>
+ * <span> abc </span>
+ * <strong> abc </strong>
+ * <sub> abc </sub>
+ * <sup> abc </sup>
+ * <tt> abc </tt>
+ * <u> abc </u>
+ * <var> abc </var>
+ */
+ public void supportedTags() { }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/ListTagsTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8006251
+ * @summary test list tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs ListTagsTest.java
+ */
+
+/** */
+public class ListTagsTest {
+ /**
+ * <dl> <dt> abc <dd> def </dl>
+ * <ol> <li> abc </ol>
+ * <ul> <li> abc </ul>
+ */
+ public void supportedTags() { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/OtherTagsTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,24 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006251
+ * @summary test other tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs -ref OtherTagsTest.out OtherTagsTest.java
+ */
+
+/** */
+public class OtherTagsTest {
+ /**
+ * <body> <p> abc </body>
+ * <frame>
+ * <frameset> </frameset>
+ * <head> </head>
+ * <link>
+ * <meta>
+ * <noframes> </noframes>
+ * <script> </script>
+ * <title> </title>
+ */
+ public void knownInvalidTags() { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/OtherTagsTest.out Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,28 @@
+OtherTagsTest.java:13: error: element not allowed in documentation comments: <body>
+ * <body> <p> abc </body>
+ ^
+OtherTagsTest.java:14: error: element not allowed in documentation comments: <frame>
+ * <frame>
+ ^
+OtherTagsTest.java:15: error: element not allowed in documentation comments: <frameset>
+ * <frameset> </frameset>
+ ^
+OtherTagsTest.java:16: error: element not allowed in documentation comments: <head>
+ * <head> </head>
+ ^
+OtherTagsTest.java:17: error: element not allowed in documentation comments: <link>
+ * <link>
+ ^
+OtherTagsTest.java:18: error: element not allowed in documentation comments: <meta>
+ * <meta>
+ ^
+OtherTagsTest.java:19: error: element not allowed in documentation comments: <noframes>
+ * <noframes> </noframes>
+ ^
+OtherTagsTest.java:20: error: element not allowed in documentation comments: <script>
+ * <script> </script>
+ ^
+OtherTagsTest.java:21: error: element not allowed in documentation comments: <title>
+ * <title> </title>
+ ^
+9 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/TableTagsTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8006251
+ * @summary test table tags
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -Xmsgs TableTagsTest.java
+ */
+
+/** */
+public class TableTagsTest {
+ /**
+ * <table summary="abc"> <tr> <td> </table>
+ * <table summary="abc"> <tr> <th> </table>
+ * <table> <caption> abc </caption> <tr> <td> </table>
+ * <table summary="abc"> <thead> <tr> </thead> <tr> <td> </table>
+ * <table summary="abc"> <tbody> <tr> <td> </tbody> </table>
+ * <table summary="abc"> <tr> <td> <tfoot> <tr> </tfoot></table>
+ */
+ public void supportedTags() { }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/TagNotAllowed.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref TagNotAllowed.out TagNotAllowed.java
+ */
+
+/**
+ * <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
+ * <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
+ * <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
+ *
+ * <table summary=description> <b>abc</b> </table>
+ * <table summary=description> <thead> <b>abc</b> </thead> </table>
+ * <table summary=description> <tbody> <b>abc</b> </tbody> </table>
+ * <table summary=description> <tfoot> <b>abc</b> </tfoot> </table>
+ * <table summary=description> <tr> <b>abc</b> </tr> </table>
+ *
+ * <pre>
+ * <img alt="image" src="image.png">
+ * <p> para </p>
+ * <big> text </big>
+ * <small> text </small>
+ * <sub> text </sub>
+ * <sup> text </sup>
+ * </pre>
+ */
+public class TagNotAllowed { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/TagNotAllowed.out Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,61 @@
+TagNotAllowed.java:11: error: tag not allowed here: <b>
+ * <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
+ ^
+TagNotAllowed.java:11: error: tag not allowed here: <b>
+ * <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
+ ^
+TagNotAllowed.java:11: error: tag not allowed here: <b>
+ * <dl> <b>abc</b> <dt> term </dt> <b>def</b> <dd> description </dd> <b>ghi</b> </dl>
+ ^
+TagNotAllowed.java:12: error: tag not allowed here: <b>
+ * <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
+ ^
+TagNotAllowed.java:12: error: tag not allowed here: <b>
+ * <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
+ ^
+TagNotAllowed.java:12: error: tag not allowed here: <b>
+ * <ol> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ol>
+ ^
+TagNotAllowed.java:13: error: tag not allowed here: <b>
+ * <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
+ ^
+TagNotAllowed.java:13: error: tag not allowed here: <b>
+ * <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
+ ^
+TagNotAllowed.java:13: error: tag not allowed here: <b>
+ * <ul> <b>abc</b> <li> item </li> <b>def</b> <li> item </li> <b>ghi</b> </ul>
+ ^
+TagNotAllowed.java:15: error: tag not allowed here: <b>
+ * <table summary=description> <b>abc</b> </table>
+ ^
+TagNotAllowed.java:16: error: tag not allowed here: <b>
+ * <table summary=description> <thead> <b>abc</b> </thead> </table>
+ ^
+TagNotAllowed.java:17: error: tag not allowed here: <b>
+ * <table summary=description> <tbody> <b>abc</b> </tbody> </table>
+ ^
+TagNotAllowed.java:18: error: tag not allowed here: <b>
+ * <table summary=description> <tfoot> <b>abc</b> </tfoot> </table>
+ ^
+TagNotAllowed.java:19: error: tag not allowed here: <b>
+ * <table summary=description> <tr> <b>abc</b> </tr> </table>
+ ^
+TagNotAllowed.java:22: error: tag not allowed here: <img>
+ * <img alt="image" src="image.png">
+ ^
+TagNotAllowed.java:23: error: tag not allowed here: <p>
+ * <p> para </p>
+ ^
+TagNotAllowed.java:24: error: tag not allowed here: <big>
+ * <big> text </big>
+ ^
+TagNotAllowed.java:25: error: tag not allowed here: <small>
+ * <small> text </small>
+ ^
+TagNotAllowed.java:26: error: tag not allowed here: <sub>
+ * <sub> text </sub>
+ ^
+TagNotAllowed.java:27: error: tag not allowed here: <sup>
+ * <sup> text </sup>
+ ^
+20 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/TextNotAllowed.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,32 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8004832
+ * @summary Add new doclint package
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref TextNotAllowed.out TextNotAllowed.java
+ */
+
+/**
+ * <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
+ * <ol> abc <li> item </li> def <li> item </li> ghi </ol>
+ * <ul> abc <li> item </li> def <li> item </li> ghi </ul>
+ *
+ * <table summary=description> abc </table>
+ * <table summary=description> <thead> abc </thead> </table>
+ * <table summary=description> <tbody> abc </tbody> </table>
+ * <table summary=description> <tfoot> abc </tfoot> </table>
+ * <table summary=description> <tr> abc </tr> </table>
+ *
+ * <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
+ * <ol> & <li> item </li> < <li> item </li> > </ol>
+ * <ul> & <li> item </li> < <li> item </li> > </ul>
+ *
+ * <table summary=description> & </table>
+ * <table summary=description> <thead> & </thead> </table>
+ * <table summary=description> <tbody> & </tbody> </table>
+ * <table summary=description> <tfoot> & </tfoot> </table>
+ * <table summary=description> <tr> & </tr> </table>
+ *
+ */
+public class TextNotAllowed { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/TextNotAllowed.out Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,85 @@
+TextNotAllowed.java:11: error: text not allowed in <dl> element
+ * <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
+ ^
+TextNotAllowed.java:11: error: text not allowed in <dl> element
+ * <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
+ ^
+TextNotAllowed.java:11: error: text not allowed in <dl> element
+ * <dl> abc <dt> term </dt> def <dd> description </dd> ghi </dl>
+ ^
+TextNotAllowed.java:12: error: text not allowed in <ol> element
+ * <ol> abc <li> item </li> def <li> item </li> ghi </ol>
+ ^
+TextNotAllowed.java:12: error: text not allowed in <ol> element
+ * <ol> abc <li> item </li> def <li> item </li> ghi </ol>
+ ^
+TextNotAllowed.java:12: error: text not allowed in <ol> element
+ * <ol> abc <li> item </li> def <li> item </li> ghi </ol>
+ ^
+TextNotAllowed.java:13: error: text not allowed in <ul> element
+ * <ul> abc <li> item </li> def <li> item </li> ghi </ul>
+ ^
+TextNotAllowed.java:13: error: text not allowed in <ul> element
+ * <ul> abc <li> item </li> def <li> item </li> ghi </ul>
+ ^
+TextNotAllowed.java:13: error: text not allowed in <ul> element
+ * <ul> abc <li> item </li> def <li> item </li> ghi </ul>
+ ^
+TextNotAllowed.java:15: error: text not allowed in <table> element
+ * <table summary=description> abc </table>
+ ^
+TextNotAllowed.java:16: error: text not allowed in <thead> element
+ * <table summary=description> <thead> abc </thead> </table>
+ ^
+TextNotAllowed.java:17: error: text not allowed in <tbody> element
+ * <table summary=description> <tbody> abc </tbody> </table>
+ ^
+TextNotAllowed.java:18: error: text not allowed in <tfoot> element
+ * <table summary=description> <tfoot> abc </tfoot> </table>
+ ^
+TextNotAllowed.java:19: error: text not allowed in <tr> element
+ * <table summary=description> <tr> abc </tr> </table>
+ ^
+TextNotAllowed.java:21: error: text not allowed in <dl> element
+ * <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
+ ^
+TextNotAllowed.java:21: error: text not allowed in <dl> element
+ * <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
+ ^
+TextNotAllowed.java:21: error: text not allowed in <dl> element
+ * <dl> & <dt> term </dt> < <dd> description </dd> > </dl>
+ ^
+TextNotAllowed.java:22: error: text not allowed in <ol> element
+ * <ol> & <li> item </li> < <li> item </li> > </ol>
+ ^
+TextNotAllowed.java:22: error: text not allowed in <ol> element
+ * <ol> & <li> item </li> < <li> item </li> > </ol>
+ ^
+TextNotAllowed.java:22: error: text not allowed in <ol> element
+ * <ol> & <li> item </li> < <li> item </li> > </ol>
+ ^
+TextNotAllowed.java:23: error: text not allowed in <ul> element
+ * <ul> & <li> item </li> < <li> item </li> > </ul>
+ ^
+TextNotAllowed.java:23: error: text not allowed in <ul> element
+ * <ul> & <li> item </li> < <li> item </li> > </ul>
+ ^
+TextNotAllowed.java:23: error: text not allowed in <ul> element
+ * <ul> & <li> item </li> < <li> item </li> > </ul>
+ ^
+TextNotAllowed.java:25: error: text not allowed in <table> element
+ * <table summary=description> & </table>
+ ^
+TextNotAllowed.java:26: error: text not allowed in <thead> element
+ * <table summary=description> <thead> & </thead> </table>
+ ^
+TextNotAllowed.java:27: error: text not allowed in <tbody> element
+ * <table summary=description> <tbody> & </tbody> </table>
+ ^
+TextNotAllowed.java:28: error: text not allowed in <tfoot> element
+ * <table summary=description> <tfoot> & </tfoot> </table>
+ ^
+TextNotAllowed.java:29: error: text not allowed in <tr> element
+ * <table summary=description> <tr> & </tr> </table>
+ ^
+28 errors
--- a/langtools/test/tools/doclint/tidy/ParaInPre.out Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/test/tools/doclint/tidy/ParaInPre.out Mon Jan 21 11:16:28 2013 -0800
@@ -1,4 +1,4 @@
-ParaInPre.java:16: warning: unexpected use of <p> inside <pre> element
+ParaInPre.java:16: error: tag not allowed here: <p>
* <p>
^
-1 warning
+1 error
--- a/langtools/test/tools/doclint/tidy/TextNotAllowed.out Sun Jan 20 23:39:11 2013 -0800
+++ b/langtools/test/tools/doclint/tidy/TextNotAllowed.out Mon Jan 21 11:16:28 2013 -0800
@@ -1,19 +1,19 @@
TextNotAllowed.java:13: error: text not allowed in <table> element
* <table summary=description> abc </table>
- ^
+ ^
TextNotAllowed.java:14: error: text not allowed in <tbody> element
* <table summary=description> <tbody> abc </tbody> </table>
- ^
+ ^
TextNotAllowed.java:15: error: text not allowed in <tr> element
* <table summary=description> <tr> abc </tr> </table>
- ^
+ ^
TextNotAllowed.java:17: error: text not allowed in <dl> element
* <dl> abc </dl>
- ^
+ ^
TextNotAllowed.java:18: error: text not allowed in <ol> element
* <ol> abc </ol>
- ^
+ ^
TextNotAllowed.java:19: error: text not allowed in <ul> element
* <ul> abc </ul>
- ^
+ ^
6 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/tool/HelpTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8006263
+ * @summary Supplementary test cases needed for doclint
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref HelpTest.out
+ * @run main DocLintTester -ref HelpTest.out -h
+ * @run main DocLintTester -ref HelpTest.out -help
+ * @run main DocLintTester -ref HelpTest.out --help
+ * @run main DocLintTester -ref HelpTest.out -usage
+ * @run main DocLintTester -ref HelpTest.out -?
+ */
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/tool/HelpTest.out Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,43 @@
+Usage:
+ doclint [options] source-files...
+
+Options:
+ -Xmsgs
+ Same as -Xmsgs:all
+ -Xmsgs:values
+ Specify categories of issues to be checked, where 'values'
+ is a comma-separated list of any of the following:
+ reference show places where comments contain incorrect
+ references to Java source code elements
+ syntax show basic syntax errors within comments
+ html show issues with HTML tags and attributes
+ accessibility show issues for accessibility
+ missing show issues with missing documentation
+ all all of the above
+ Precede a value with '-' to negate it
+ Categories may be qualified by one of:
+ /public /protected /package /private
+ For positive categories (not beginning with '-')
+ the qualifier applies to that access level and above.
+ For negative categories (beginning with '-')
+ the qualifier applies to that access level and below.
+ If a qualifier is missing, the category applies to
+ all access levels.
+ For example, -Xmsgs:all,-syntax/private
+ This will enable all messages, except syntax errors
+ in the doc comments of private methods.
+ If no -Xmsgs options are provided, the default is
+ equivalent to -Xmsgs:all/protected, meaning that
+ all messages are reported for protected and public
+ declarations only.
+ -stats
+ Report statistics on the reported issues.
+ -h -help --help -usage -?
+ Show this message.
+
+The following javac options are also supported
+ -bootclasspath, -classpath, -sourcepath, -Xmaxerrs, -Xmaxwarns
+
+To run doclint on part of a project, put the compiled classes for your
+project on the classpath (or bootclasspath), then specify the source files
+to be checked on the command line.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/tool/MaxDiagsTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006263
+ * @summary Supplementary test cases needed for doclint
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref MaxDiagsTest.out -Xmaxerrs 2 -Xmaxwarns 2 MaxDiagsTest.java
+ * @run main DocLintTester -badargs -Xmaxerrs
+ * @run main DocLintTester -badargs -Xmaxwarns
+ * @run main DocLintTester -badargs -Xmaxerrs two -Xmaxwarns two MaxDiagsTest.java
+ */
+
+public class MaxDiagsTest {
+ /**
+ * � � � �
+ */
+ public void errors() { }
+
+ /** 4 undocumented signature items */
+ public int warnings(int a1, int a2) throws Exception { return 0; }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/tool/MaxDiagsTest.out Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,14 @@
+MaxDiagsTest.java:13: warning: no comment
+public class MaxDiagsTest {
+ ^
+MaxDiagsTest.java:15: error: invalid entity �
+ * � � � �
+ ^
+MaxDiagsTest.java:15: error: invalid entity �
+ * � � � �
+ ^
+MaxDiagsTest.java:20: warning: no @param for a1
+ public int warnings(int a1, int a2) throws Exception { return 0; }
+ ^
+2 errors
+2 warnings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/tool/PathsTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8006263
+ * @summary Supplementary test cases needed for doclint
+ */
+
+import com.sun.tools.doclint.DocLint;
+import com.sun.tools.doclint.DocLint.BadArgs;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.regex.Pattern;
+
+public class PathsTest {
+ public static void main(String... args) throws Exception {
+ new PathsTest().run();
+ }
+
+ void run() throws Exception {
+ String PS = File.pathSeparator;
+ writeFile("src1/p/A.java",
+ "package p; public class A { }");
+ compile("-d", "classes1", "src1/p/A.java");
+
+ writeFile("src2/q/B.java",
+ "package q; public class B extends p.A { }");
+ compile("-d", "classes2", "-classpath", "classes1", "src2/q/B.java");
+
+ writeFile("src/Test.java",
+ "/** &0; */ class Test extends q.B { }");
+
+ test("src/Test.java", "-sourcepath", "src1" + PS + "src2");
+ test("src/Test.java", "-classpath", "classes1" + PS + "classes2");
+ String sysBootClassPath = System.getProperty("sun.boot.class.path");
+ test("src/Test.java", "-bootclasspath",
+ sysBootClassPath + PS + "classes1" + PS + "classes2");
+
+ if (errors > 0)
+ throw new Exception(errors + " errors found");
+ }
+
+ Pattern pkgNotFound = Pattern.compile("package [a-z]+ does not exist");
+ Pattern badHtmlEntity = Pattern.compile("bad HTML entity");
+
+ void test(String file, String pathOpt, String path) throws BadArgs, IOException {
+ System.err.println("test " + pathOpt);
+ String out1 = doclint("-Xmsgs", file);
+ if (!pkgNotFound.matcher(out1).find())
+ error("message not found: " + pkgNotFound);
+
+ String out2 = doclint("-Xmsgs", pathOpt, path, file);
+ if (pkgNotFound.matcher(out2).find())
+ error("unexpected message found: " + pkgNotFound);
+ if (!badHtmlEntity.matcher(out1).find())
+ error("message not found: " + badHtmlEntity);
+
+ try {
+ doclint("-Xmsgs", pathOpt);
+ error("expected exception not thrown");
+ } catch (BadArgs e) {
+ System.err.println(e);
+ }
+ }
+
+ void compile(String... args) {
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("-d")) {
+ new File(args[++i]).mkdirs();
+ break;
+ }
+ }
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ int rc = com.sun.tools.javac.Main.compile(args, pw);
+ pw.close();
+ String out = sw.toString();
+ if (!out.isEmpty())
+ System.err.println(out);
+ if (rc != 0)
+ error("compilation failed: rc=" + rc);
+ }
+
+ String doclint(String... args) throws BadArgs, IOException {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ DocLint dl = new DocLint();
+ dl.run(pw, args);
+ pw.close();
+ String out = sw.toString();
+ if (!out.isEmpty())
+ System.err.println(out);
+ return out;
+ }
+
+ File writeFile(String path, String body) throws IOException {
+ File f = new File(path);
+ f.getParentFile().mkdirs();
+ try (FileWriter fw = new FileWriter(path)) {
+ fw.write(body);
+ }
+ return f;
+ }
+
+ void error(String msg) {
+ System.err.println("Error: " + msg);
+ errors++;
+ }
+
+ int errors;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/tool/RunTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8006263
+ * @summary Supplementary test cases needed for doclint
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.doclint.DocLint;
+import com.sun.tools.doclint.DocLint.BadArgs;
+import com.sun.tools.javac.api.JavacTool;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.security.Permission;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+public class RunTest {
+ static class SimpleSecurityManager extends SecurityManager {
+ boolean allowExit = false;
+
+ @Override
+ public void checkExit(int status) {
+ if (!allowExit)
+ throw new SecurityException("System.exit(" + status + ")");
+ }
+ @Override
+ public void checkPermission(Permission perm) { }
+
+ }
+
+ public static void main(String... args) throws Exception {
+ // if no security manager already installed, install one to
+ // prevent System.exit
+ SimpleSecurityManager secmgr = null;
+ if (System.getSecurityManager() == null) {
+ System.setSecurityManager(secmgr = new SimpleSecurityManager() { });
+ }
+
+ try {
+ new RunTest().run();
+ } finally {
+ if (secmgr != null)
+ secmgr.allowExit = true;
+ }
+ }
+
+ void run() throws Exception {
+ testMain();
+ testRun();
+ testInit();
+ testArgsNoFiles();
+
+ if (errors > 0)
+ throw new Exception(errors + " errors found");
+ }
+
+ void testMain() {
+ System.err.println("test main(String[])");
+ testMain(true, "-help");
+ testMain(false, "-unknownOption");
+ }
+
+ void testMain(boolean expectOK, String... args) {
+ try {
+ DocLint.main(args);
+ if (!expectOK)
+ error("expected SecurityException (from System.exit) not thrown");
+ } catch (SecurityException e) {
+ System.err.println(e);
+ if (expectOK)
+ error("unexpected SecurityException caught");
+ }
+ }
+
+ void testRun() throws BadArgs, IOException {
+ System.err.println("test run(String[])");
+ DocLint dl = new DocLint();
+ String[] args = { "-help" };
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baos);
+ PrintStream prev = System.out;
+ try {
+ System.setOut(ps);
+ dl.run(args);
+ } finally {
+ System.setOut(prev);
+ }
+ ps.close();
+ String stdout = baos.toString();
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ dl.run(pw, args);
+ pw.close();
+ String direct = sw.toString();
+
+ if (!stdout.equals(direct)) {
+ error("unexpected output");
+ System.err.println("EXPECT>>" + direct + "<<");
+ System.err.println("FOUND>>" + stdout + "<<");
+ }
+ }
+
+ void testInit() {
+ System.err.println("test init");
+ DocLint dl = new DocLint();
+ String name = dl.getName();
+ if (!Objects.equals(name, "doclint"))
+ error("unexpected result for DocLint.getName()");
+
+ List<? extends JavaFileObject> files =
+ Arrays.asList(createFile("Test.java", "/** &0; */ class Test{ }"));
+ String[] goodArgs = { "-Xmsgs" };
+ testInit(true, goodArgs, files);
+
+ String[] badArgs = { "-unknown" };
+ testInit(false, badArgs, files);
+ }
+
+ void testInit(boolean expectOK, String[] args, List<? extends JavaFileObject> files) {
+ JavacTool javac = JavacTool.create();
+ JavacTask task = javac.getTask(null, null, null, null, null, files);
+ try {
+ DocLint dl = new DocLint();
+ dl.init(task, args, true);
+ if (!expectOK)
+ error("expected IllegalArgumentException not thrown");
+ task.call();
+ } catch (IllegalArgumentException e) {
+ System.err.println(e);
+ if (expectOK)
+ error("unexpected IllegalArgumentException caught");
+ }
+ }
+
+ void testArgsNoFiles() throws BadArgs, IOException {
+ System.err.println("test args, no files");
+ DocLint dl = new DocLint();
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ dl.run(pw, "-Xmsgs");
+ pw.close();
+ String out = sw.toString();
+
+ String expect = "no files given";
+ if (!Objects.equals(out.trim(), expect)) {
+ error("unexpected output");
+ System.err.println("EXPECT>>" + expect + "<<");
+ System.err.println("FOUND>>" + out + "<<");
+ }
+
+ }
+
+ JavaFileObject createFile(String name, final String body) {
+ return new SimpleJavaFileObject(URI.create(name), JavaFileObject.Kind.SOURCE) {
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+ return body;
+ }
+ };
+ }
+
+ void error(String msg) {
+ System.err.println("Error: " + msg);
+ errors++;
+ }
+
+ int errors;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/tool/StatsTest.java Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8006263
+ * @summary Supplementary test cases needed for doclint
+ * @library ..
+ * @build DocLintTester
+ * @run main DocLintTester -ref StatsTest.out -stats -Xmsgs:all StatsTest.java
+ */
+
+// warning: missing comment
+public class StatsTest {
+ /**
+ * � � � �
+ */
+ public void errors() { }
+
+ /** 4 undocumented signature items */
+ public int warnings(int a1, int a2) throws Exception { return 0; }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/tool/StatsTest.out Mon Jan 21 11:16:28 2013 -0800
@@ -0,0 +1,43 @@
+StatsTest.java:11: warning: no comment
+public class StatsTest {
+ ^
+StatsTest.java:13: error: invalid entity �
+ * � � � �
+ ^
+StatsTest.java:13: error: invalid entity �
+ * � � � �
+ ^
+StatsTest.java:13: error: invalid entity �
+ * � � � �
+ ^
+StatsTest.java:13: error: invalid entity �
+ * � � � �
+ ^
+StatsTest.java:18: warning: no @param for a1
+ public int warnings(int a1, int a2) throws Exception { return 0; }
+ ^
+StatsTest.java:18: warning: no @param for a2
+ public int warnings(int a1, int a2) throws Exception { return 0; }
+ ^
+StatsTest.java:18: warning: no @return
+ public int warnings(int a1, int a2) throws Exception { return 0; }
+ ^
+StatsTest.java:18: warning: no @throws for java.lang.Exception
+ public int warnings(int a1, int a2) throws Exception { return 0; }
+ ^
+By group...
+ 5: missing
+ 4: html
+
+By diagnostic kind...
+ 5: warning
+ 4: error
+
+By message kind...
+ 4: invalid entity &{0};
+ 2: no @param for {0}
+ 1: no @return
+ 1: no @throws for {0}
+ 1: no comment
+4 errors
+5 warnings