Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javadoc/6964914/TestStdDoclet.java
38813 views
1
/*
2
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 6964914
27
* @summary javadoc does not output number of warnings using user written doclet
28
*/
29
30
import java.io.*;
31
32
/**
33
* Dummy javadoc comment.
34
* @author jjg
35
* @see DoesNotExist
36
*/
37
public class TestStdDoclet {
38
public static void main(String... args) throws Exception {
39
new TestStdDoclet().run();
40
}
41
42
/**
43
* More dummy comments.
44
* @throws DoesNotExist oops, javadoc does not see this
45
* @see DoesNotExist
46
*/
47
void run() throws Exception {
48
File javaHome = new File(System.getProperty("java.home"));
49
if (javaHome.getName().equals("jre"))
50
javaHome = javaHome.getParentFile();
51
File javadoc = new File(new File(javaHome, "bin"), "javadoc");
52
File testSrc = new File(System.getProperty("test.src"));
53
54
// run javadoc in separate process to ensure doclet executed under
55
// normal user conditions w.r.t. classloader
56
String thisClassName = TestStdDoclet.class.getName();
57
Process p = new ProcessBuilder()
58
.command(javadoc.getPath(),
59
"-J-Xbootclasspath:" + System.getProperty("sun.boot.class.path"),
60
"-Xdoclint:none",
61
"-package",
62
new File(testSrc, thisClassName + ".java").getPath())
63
.redirectErrorStream(true)
64
.start();
65
66
int actualDocletWarnCount = 0;
67
int reportedDocletWarnCount = 0;
68
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
69
try {
70
String line;
71
while ((line = in.readLine()) != null) {
72
System.err.println(line);
73
if (line.contains("DoesNotExist"))
74
actualDocletWarnCount++;
75
if (line.matches("[0-9]+ warning(s)?"))
76
reportedDocletWarnCount =
77
Integer.valueOf(line.substring(0, line.indexOf(" ")));
78
}
79
} finally {
80
in.close();
81
}
82
int rc = p.waitFor();
83
if (rc != 0)
84
System.err.println("javadoc failed, rc:" + rc);
85
86
int expectedDocletWarnCount = 2;
87
checkEqual("actual", actualDocletWarnCount, "expected", expectedDocletWarnCount);
88
checkEqual("actual", actualDocletWarnCount, "reported", reportedDocletWarnCount);
89
}
90
91
/**
92
* Private method should not cause a warning.
93
* @see DoesNotExist
94
*/
95
private void checkEqual(String l1, int i1, String l2, int i2) throws Exception {
96
if (i1 != i2)
97
throw new Exception(l1 + " warn count, " + i1 + ", does not match "
98
+ l2 + " warn count, " + i2);
99
}
100
101
}
102
103