Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/jdk/javadoc/tool/dupOk/DupOk.java
40971 views
1
/*
2
* Copyright (c) 2002, 2019, 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 4673477
27
* @summary The first definition found for each class should be documented
28
* @modules jdk.javadoc/jdk.javadoc.internal.tool
29
*/
30
31
import java.io.File;
32
import java.util.*;
33
34
import javax.lang.model.SourceVersion;
35
import javax.lang.model.element.Element;
36
import javax.lang.model.element.ElementKind;
37
import javax.lang.model.element.TypeElement;
38
import javax.lang.model.util.ElementFilter;
39
40
import jdk.javadoc.doclet.Doclet;
41
import jdk.javadoc.doclet.Reporter;
42
import jdk.javadoc.doclet.DocletEnvironment;
43
44
public class DupOk implements Doclet
45
{
46
public static void main(String[] args) {
47
File srcFile = new File(System.getProperty("test.src", "."));
48
String path1 = new File(srcFile, "sp1").getPath();
49
String path2 = new File(srcFile, "sp2").getPath();
50
String[] aargs = {
51
"-docletpath",
52
new File(System.getProperty("test.classes", ".")).getPath(),
53
"-doclet",
54
"DupOk",
55
"-sourcepath",
56
path1 + System.getProperty("path.separator") + path2,
57
"p"
58
};
59
// run javadoc on package p
60
if (jdk.javadoc.internal.tool.Main.execute(aargs) != 0)
61
throw new Error();
62
}
63
64
public boolean run(DocletEnvironment root) {
65
Set<TypeElement> classes = ElementFilter.typesIn(root.getIncludedElements());
66
if (classes.size() != 2)
67
throw new Error("1 " + Arrays.asList(classes));
68
for (TypeElement clazz : classes) {
69
if (getFields(clazz).size() != 1)
70
throw new Error("2 " + clazz + " " + getFields(clazz));
71
}
72
return true;
73
}
74
75
List<Element> getFields(TypeElement klass) {
76
List<Element> out = new ArrayList<>();
77
for (Element e : klass.getEnclosedElements()) {
78
if (e.getKind() == ElementKind.FIELD) {
79
out.add(e);
80
}
81
}
82
return out;
83
}
84
85
@Override
86
public String getName() {
87
return "Test";
88
}
89
90
@Override
91
public Set<Option> getSupportedOptions() {
92
return Collections.emptySet();
93
}
94
95
@Override
96
public SourceVersion getSupportedSourceVersion() {
97
return SourceVersion.latest();
98
}
99
100
@Override
101
public void init(Locale locale, Reporter reporter) {
102
return;
103
}
104
}
105
106