Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/jdk/javadoc/tool/8025693/Test.java
40971 views
1
/*
2
* Copyright (c) 2013, 2016, 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 8025693
27
* @summary javadoc should ignore <clinit> methods found in classes on classpath
28
* @modules jdk.javadoc/jdk.javadoc.internal.tool
29
*/
30
31
import java.io.*;
32
33
public class Test {
34
public static void main(String[] args) throws Exception {
35
new Test().run();
36
}
37
38
final File baseFile = new File("src/Base.java");
39
final String baseText =
40
"""
41
package p;
42
public class Base { static { } }
43
""";
44
45
final File srcFile = new File("src/C.java");
46
final String srcText =
47
"""
48
package p;
49
/** comment */
50
public abstract class C extends Base { }
51
""";
52
53
void run() throws Exception {
54
File classesDir = new File("classes");
55
classesDir.mkdirs();
56
writeFile(baseFile, baseText);
57
String[] javacArgs = {
58
"-d", classesDir.getPath(),
59
baseFile.getPath()
60
};
61
com.sun.tools.javac.Main.compile(javacArgs);
62
63
writeFile(srcFile, srcText);
64
String[] args = {
65
"-d", "api",
66
"-classpath", classesDir.getPath(),
67
"-package", "p",
68
srcFile.getPath()
69
};
70
71
ByteArrayOutputStream baos = new ByteArrayOutputStream();
72
PrintStream ps = new PrintStream(baos);
73
PrintStream prev = System.err;
74
System.setErr(ps);
75
try {
76
int rc = jdk.javadoc.internal.tool.Main.execute(args);
77
} finally {
78
System.err.flush();
79
System.setErr(prev);
80
}
81
String out = baos.toString();
82
System.out.println(out);
83
84
String errorMessage = "java.lang.IllegalArgumentException: <clinit>";
85
if (out.contains(errorMessage))
86
throw new Exception("error message found: " + errorMessage);
87
}
88
89
void writeFile(File file, String body) throws IOException {
90
file.getParentFile().mkdirs();
91
try (FileWriter out = new FileWriter(file)) {
92
out.write(body);
93
}
94
}
95
}
96
97
98