author | bpatel |
Tue, 06 Mar 2018 10:45:47 -0800 | |
changeset 49139 | 771616d26ca1 |
parent 48521 | 30243cf1503e |
permissions | -rw-r--r-- |
8633
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
1 |
/* |
48521 | 2 |
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. |
8633
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
4 |
* |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
8 |
* |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
14 |
* |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
18 |
* |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
21 |
* questions. |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
22 |
*/ |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
23 |
|
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
24 |
/* |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
25 |
* @test |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
26 |
* @bug 6964914 |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
27 |
* @summary javadoc does not output number of warnings using user written doclet |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
28 |
*/ |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
29 |
|
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
30 |
import java.io.*; |
37637
b47af0433922
8154500: fix handling of jdk.launcher.patch.* in tests
jjg
parents:
36526
diff
changeset
|
31 |
import java.util.*; |
8633
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
32 |
|
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
33 |
/** |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
34 |
* Dummy javadoc comment. |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
35 |
* @author jjg |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
36 |
* @see DoesNotExist |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
37 |
*/ |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
38 |
public class TestStdDoclet { |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
39 |
public static void main(String... args) throws Exception { |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
40 |
new TestStdDoclet().run(); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
41 |
} |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
42 |
|
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
43 |
/** |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
44 |
* More dummy comments. |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
45 |
* @throws DoesNotExist oops, javadoc does not see this |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
46 |
* @see DoesNotExist |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
47 |
*/ |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
48 |
void run() throws Exception { |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
49 |
File javaHome = new File(System.getProperty("java.home")); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
50 |
File javadoc = new File(new File(javaHome, "bin"), "javadoc"); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
51 |
File testSrc = new File(System.getProperty("test.src")); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
52 |
|
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
53 |
// run javadoc in separate process to ensure doclet executed under |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
54 |
// normal user conditions w.r.t. classloader |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
55 |
String thisClassName = TestStdDoclet.class.getName(); |
37637
b47af0433922
8154500: fix handling of jdk.launcher.patch.* in tests
jjg
parents:
36526
diff
changeset
|
56 |
List<String> cmdArgs = new ArrayList<>(); |
b47af0433922
8154500: fix handling of jdk.launcher.patch.* in tests
jjg
parents:
36526
diff
changeset
|
57 |
cmdArgs.add(javadoc.getPath()); |
b47af0433922
8154500: fix handling of jdk.launcher.patch.* in tests
jjg
parents:
36526
diff
changeset
|
58 |
cmdArgs.addAll(Arrays.asList( |
23972
af37c1dbcb88
8039251: Test tools/javadoc/6964914/TestStdDoclet.java fails
ksrini
parents:
15354
diff
changeset
|
59 |
"-classpath", ".", // insulates us from ambient classpath |
15354 | 60 |
"-Xdoclint:none", |
8633
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
61 |
"-package", |
37637
b47af0433922
8154500: fix handling of jdk.launcher.patch.* in tests
jjg
parents:
36526
diff
changeset
|
62 |
new File(testSrc, thisClassName + ".java").getPath() |
b47af0433922
8154500: fix handling of jdk.launcher.patch.* in tests
jjg
parents:
36526
diff
changeset
|
63 |
)); |
b47af0433922
8154500: fix handling of jdk.launcher.patch.* in tests
jjg
parents:
36526
diff
changeset
|
64 |
Process p = new ProcessBuilder() |
b47af0433922
8154500: fix handling of jdk.launcher.patch.* in tests
jjg
parents:
36526
diff
changeset
|
65 |
.command(cmdArgs) |
8633
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
66 |
.redirectErrorStream(true) |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
67 |
.start(); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
68 |
|
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
69 |
int actualDocletWarnCount = 0; |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
70 |
int reportedDocletWarnCount = 0; |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
71 |
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
72 |
try { |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
73 |
String line; |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
74 |
while ((line = in.readLine()) != null) { |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
75 |
System.err.println(line); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
76 |
if (line.contains("DoesNotExist")) |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
77 |
actualDocletWarnCount++; |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
78 |
if (line.matches("[0-9]+ warning(s)?")) |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
79 |
reportedDocletWarnCount = |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
80 |
Integer.valueOf(line.substring(0, line.indexOf(" "))); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
23972
diff
changeset
|
81 |
} |
8633
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
82 |
} finally { |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
83 |
in.close(); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
84 |
} |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
85 |
int rc = p.waitFor(); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
86 |
if (rc != 0) |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
87 |
System.err.println("javadoc failed, rc:" + rc); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
88 |
|
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
89 |
int expectedDocletWarnCount = 2; |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
90 |
checkEqual("actual", actualDocletWarnCount, "expected", expectedDocletWarnCount); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
91 |
checkEqual("actual", actualDocletWarnCount, "reported", reportedDocletWarnCount); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
92 |
} |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
93 |
|
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
94 |
/** |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
95 |
* Private method should not cause a warning. |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
96 |
* @see DoesNotExist |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
97 |
*/ |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
98 |
private void checkEqual(String l1, int i1, String l2, int i2) throws Exception { |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
99 |
if (i1 != i2) |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
100 |
throw new Exception(l1 + " warn count, " + i1 + ", does not match " |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
101 |
+ l2 + " warn count, " + i2); |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
102 |
} |
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
103 |
|
41311e88ffb7
6964914: javadoc does not output number of warnings using user written doclet
jjg
parents:
diff
changeset
|
104 |
} |