8006263: Supplementary test cases needed for doclint
authorjjg
Mon, 21 Jan 2013 10:00:46 -0800
changeset 15370 c1c9a9e11b26
parent 15369 2ae199ad2e5d
child 15371 8f719dc43e1f
8006263: Supplementary test cases needed for doclint Reviewed-by: mcimadamore Contributed-by: peter.jensen@oracle.com
langtools/src/share/classes/com/sun/tools/doclint/Checker.java
langtools/src/share/classes/com/sun/tools/doclint/DocLint.java
langtools/src/share/classes/com/sun/tools/doclint/Entity.java
langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java
langtools/test/tools/doclint/CoverageExtras.java
langtools/test/tools/doclint/DocLintTester.java
langtools/test/tools/doclint/html/EntitiesTest.java
langtools/test/tools/doclint/html/EntitiesTest.out
langtools/test/tools/doclint/tool/HelpTest.java
langtools/test/tools/doclint/tool/HelpTest.out
langtools/test/tools/doclint/tool/MaxDiagsTest.java
langtools/test/tools/doclint/tool/MaxDiagsTest.out
langtools/test/tools/doclint/tool/PathsTest.java
langtools/test/tools/doclint/tool/RunTest.java
langtools/test/tools/doclint/tool/StatsTest.java
langtools/test/tools/doclint/tool/StatsTest.out
--- a/langtools/src/share/classes/com/sun/tools/doclint/Checker.java	Fri Jan 18 15:38:14 2013 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclint/Checker.java	Mon Jan 21 10:00:46 2013 -0800
@@ -92,7 +92,7 @@
     boolean foundInheritDoc = false;
     boolean foundReturn = false;
 
-    enum Flag {
+    public enum Flag {
         TABLE_HAS_CAPTION,
         HAS_ELEMENT,
         HAS_TEXT
--- a/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java	Fri Jan 18 15:38:14 2013 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclint/DocLint.java	Mon Jan 21 10:00:46 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	Fri Jan 18 15:38:14 2013 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclint/Entity.java	Mon Jan 21 10:00:46 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	Fri Jan 18 15:38:14 2013 +0000
+++ b/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java	Mon Jan 21 10:00:46 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
@@ -273,7 +273,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);
             }
         }
     }
@@ -346,7 +346,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);
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/CoverageExtras.java	Mon Jan 21 10:00:46 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	Fri Jan 18 15:38:14 2013 +0000
+++ b/langtools/test/tools/doclint/DocLintTester.java	Mon Jan 21 10:00:46 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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/EntitiesTest.java	Mon Jan 21 10:00:46 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 {
+
+    /**
+     * &#32;  &#x20;
+     * &#2126; &#x84e; &#x84E;
+     */
+    void range_test() { }
+
+    /**
+    * &nbsp; &#160;
+    * &iexcl; &#161;
+    * &cent; &#162;
+    * &pound; &#163;
+    * &curren; &#164;
+    * &yen; &#165;
+    * &brvbar; &#166;
+    * &sect; &#167;
+    * &uml; &#168;
+    * &copy; &#169;
+    * &ordf; &#170;
+    * &laquo; &#171;
+    * &not; &#172;
+    * &shy; &#173;
+    * &reg; &#174;
+    * &macr; &#175;
+    * &deg; &#176;
+    * &plusmn; &#177;
+    * &sup2; &#178;
+    * &sup3; &#179;
+    * &acute; &#180;
+    * &micro; &#181;
+    * &para; &#182;
+    * &middot; &#183;
+    * &cedil; &#184;
+    * &sup1; &#185;
+    * &ordm; &#186;
+    * &raquo; &#187;
+    * &frac14; &#188;
+    * &frac12; &#189;
+    * &frac34; &#190;
+    * &iquest; &#191;
+    * &Agrave; &#192;
+    * &Aacute; &#193;
+    * &Acirc; &#194;
+    * &Atilde; &#195;
+    * &Auml; &#196;
+    * &Aring; &#197;
+    * &AElig; &#198;
+    * &Ccedil; &#199;
+    * &Egrave; &#200;
+    * &Eacute; &#201;
+    * &Ecirc; &#202;
+    * &Euml; &#203;
+    * &Igrave; &#204;
+    * &Iacute; &#205;
+    * &Icirc; &#206;
+    * &Iuml; &#207;
+    * &ETH; &#208;
+    * &Ntilde; &#209;
+    * &Ograve; &#210;
+    * &Oacute; &#211;
+    * &Ocirc; &#212;
+    * &Otilde; &#213;
+    * &Ouml; &#214;
+    * &times; &#215;
+    * &Oslash; &#216;
+    * &Ugrave; &#217;
+    * &Uacute; &#218;
+    * &Ucirc; &#219;
+    * &Uuml; &#220;
+    * &Yacute; &#221;
+    * &THORN; &#222;
+    * &szlig; &#223;
+    * &agrave; &#224;
+    * &aacute; &#225;
+    * &acirc; &#226;
+    * &atilde; &#227;
+    * &auml; &#228;
+    * &aring; &#229;
+    * &aelig; &#230;
+    * &ccedil; &#231;
+    * &egrave; &#232;
+    * &eacute; &#233;
+    * &ecirc; &#234;
+    * &euml; &#235;
+    * &igrave; &#236;
+    * &iacute; &#237;
+    * &icirc; &#238;
+    * &iuml; &#239;
+    * &eth; &#240;
+    * &ntilde; &#241;
+    * &ograve; &#242;
+    * &oacute; &#243;
+    * &ocirc; &#244;
+    * &otilde; &#245;
+    * &ouml; &#246;
+    * &divide; &#247;
+    * &oslash; &#248;
+    * &ugrave; &#249;
+    * &uacute; &#250;
+    * &ucirc; &#251;
+    * &uuml; &#252;
+    * &yacute; &#253;
+    * &thorn; &#254;
+    * &yuml; &#255;
+    * &fnof; &#402;
+    * &Alpha; &#913;
+    * &Beta; &#914;
+    * &Gamma; &#915;
+    * &Delta; &#916;
+    * &Epsilon; &#917;
+    * &Zeta; &#918;
+    * &Eta; &#919;
+    * &Theta; &#920;
+    * &Iota; &#921;
+    * &Kappa; &#922;
+    * &Lambda; &#923;
+    * &Mu; &#924;
+    * &Nu; &#925;
+    * &Xi; &#926;
+    * &Omicron; &#927;
+    * &Pi; &#928;
+    * &Rho; &#929;
+    * &Sigma; &#931;
+    * &Tau; &#932;
+    * &Upsilon; &#933;
+    * &Phi; &#934;
+    * &Chi; &#935;
+    * &Psi; &#936;
+    * &Omega; &#937;
+    * &alpha; &#945;
+    * &beta; &#946;
+    * &gamma; &#947;
+    * &delta; &#948;
+    * &epsilon; &#949;
+    * &zeta; &#950;
+    * &eta; &#951;
+    * &theta; &#952;
+    * &iota; &#953;
+    * &kappa; &#954;
+    * &lambda; &#955;
+    * &mu; &#956;
+    * &nu; &#957;
+    * &xi; &#958;
+    * &omicron; &#959;
+    * &pi; &#960;
+    * &rho; &#961;
+    * &sigmaf; &#962;
+    * &sigma; &#963;
+    * &tau; &#964;
+    * &upsilon; &#965;
+    * &phi; &#966;
+    * &chi; &#967;
+    * &psi; &#968;
+    * &omega; &#969;
+    * &thetasym; &#977;
+    * &upsih; &#978;
+    * &piv; &#982;
+    * &bull; &#8226;
+    * &hellip; &#8230;
+    * &prime; &#8242;
+    * &Prime; &#8243;
+    * &oline; &#8254;
+    * &frasl; &#8260;
+    * &weierp; &#8472;
+    * &image; &#8465;
+    * &real; &#8476;
+    * &trade; &#8482;
+    * &alefsym; &#8501;
+    * &larr; &#8592;
+    * &uarr; &#8593;
+    * &rarr; &#8594;
+    * &darr; &#8595;
+    * &harr; &#8596;
+    * &crarr; &#8629;
+    * &lArr; &#8656;
+    * &uArr; &#8657;
+    * &rArr; &#8658;
+    * &dArr; &#8659;
+    * &hArr; &#8660;
+    * &forall; &#8704;
+    * &part; &#8706;
+    * &exist; &#8707;
+    * &empty; &#8709;
+    * &nabla; &#8711;
+    * &isin; &#8712;
+    * &notin; &#8713;
+    * &ni; &#8715;
+    * &prod; &#8719;
+    * &sum; &#8721;
+    * &minus; &#8722;
+    * &lowast; &#8727;
+    * &radic; &#8730;
+    * &prop; &#8733;
+    * &infin; &#8734;
+    * &ang; &#8736;
+    * &and; &#8743;
+    * &or; &#8744;
+    * &cap; &#8745;
+    * &cup; &#8746;
+    * &_int; &#8747;
+    * &there4; &#8756;
+    * &sim; &#8764;
+    * &cong; &#8773;
+    * &asymp; &#8776;
+    * &ne; &#8800;
+    * &equiv; &#8801;
+    * &le; &#8804;
+    * &ge; &#8805;
+    * &sub; &#8834;
+    * &sup; &#8835;
+    * &nsub; &#8836;
+    * &sube; &#8838;
+    * &supe; &#8839;
+    * &oplus; &#8853;
+    * &otimes; &#8855;
+    * &perp; &#8869;
+    * &sdot; &#8901;
+    * &lceil; &#8968;
+    * &rceil; &#8969;
+    * &lfloor; &#8970;
+    * &rfloor; &#8971;
+    * &lang; &#9001;
+    * &rang; &#9002;
+    * &loz; &#9674;
+    * &spades; &#9824;
+    * &clubs; &#9827;
+    * &hearts; &#9829;
+    * &diams; &#9830;
+    * &quot; &#34;
+    * &amp; &#38;
+    * &lt; &#60;
+    * &gt; &#62;
+    * &OElig; &#338;
+    * &oelig; &#339;
+    * &Scaron; &#352;
+    * &scaron; &#353;
+    * &Yuml; &#376;
+    * &circ; &#710;
+    * &tilde; &#732;
+    * &ensp; &#8194;
+    * &emsp; &#8195;
+    * &thinsp; &#8201;
+    * &zwnj; &#8204;
+    * &zwj; &#8205;
+    * &lrm; &#8206;
+    * &rlm; &#8207;
+    * &ndash; &#8211;
+    * &mdash; &#8212;
+    * &lsquo; &#8216;
+    * &rsquo; &#8217;
+    * &sbquo; &#8218;
+    * &ldquo; &#8220;
+    * &rdquo; &#8221;
+    * &bdquo; &#8222;
+    * &dagger; &#8224;
+    * &Dagger; &#8225;
+    * &permil; &#8240;
+    * &lsaquo; &#8249;
+    * &rsaquo; &#8250;
+    * &euro; &#8364;
+    */
+    void symbolic_entities() { }
+
+    /**
+     * &bad;
+     */
+    void bad_name() { }
+
+    /**
+     * &#31;
+     * &#2127;
+     */
+    void out_of_range() { }
+
+    /**
+     * &#8213;
+     * &#9003;
+     * &#xffff;
+     */
+    void sparse_negative() { }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/html/EntitiesTest.out	Mon Jan 21 10:00:46 2013 -0800
@@ -0,0 +1,19 @@
+EntitiesTest.java:300: error: invalid entity &bad;
+     * &bad;
+       ^
+EntitiesTest.java:305: error: invalid entity &#31;
+     * &#31;
+       ^
+EntitiesTest.java:306: error: invalid entity &#2127;
+     * &#2127;
+       ^
+EntitiesTest.java:311: error: invalid entity &#8213;
+     * &#8213;
+       ^
+EntitiesTest.java:312: error: invalid entity &#9003;
+     * &#9003;
+       ^
+EntitiesTest.java:313: error: invalid entity &#xffff;
+     * &#xffff;
+       ^
+6 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/doclint/tool/HelpTest.java	Mon Jan 21 10:00:46 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 10:00:46 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 10:00:46 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 {
+    /**
+     * &#0; &#0; &#0; &#0;
+     */
+    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 10:00:46 2013 -0800
@@ -0,0 +1,14 @@
+MaxDiagsTest.java:13: warning: no comment
+public class MaxDiagsTest {
+       ^
+MaxDiagsTest.java:15: error: invalid entity &#0;
+     * &#0; &#0; &#0; &#0;
+       ^
+MaxDiagsTest.java:15: error: invalid entity &#0;
+     * &#0; &#0; &#0; &#0;
+            ^
+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 10:00:46 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 10:00:46 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 10:00:46 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 {
+    /**
+     * &#0; &#0; &#0; &#0;
+     */
+    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 10:00:46 2013 -0800
@@ -0,0 +1,43 @@
+StatsTest.java:11: warning: no comment
+public class StatsTest {
+       ^
+StatsTest.java:13: error: invalid entity &#0;
+     * &#0; &#0; &#0; &#0;
+       ^
+StatsTest.java:13: error: invalid entity &#0;
+     * &#0; &#0; &#0; &#0;
+            ^
+StatsTest.java:13: error: invalid entity &#0;
+     * &#0; &#0; &#0; &#0;
+                 ^
+StatsTest.java:13: error: invalid entity &#0;
+     * &#0; &#0; &#0; &#0;
+                      ^
+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