Skip to content

Commit 8f9c11f

Browse files
committed
[JDK11] JDiff Support JDK11.
1 parent 3f638c2 commit 8f9c11f

File tree

9 files changed

+1036
-1
lines changed

9 files changed

+1036
-1
lines changed

hadoop-common-project/hadoop-annotations/pom.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,45 @@
7575
</plugins>
7676
</build>
7777
</profile>
78+
<profile>
79+
<id>jdk17</id>
80+
<activation>
81+
<jdk>[17,)</jdk>
82+
</activation>
83+
<build>
84+
<plugins>
85+
<plugin>
86+
<groupId>org.codehaus.mojo</groupId>
87+
<artifactId>build-helper-maven-plugin</artifactId>
88+
<executions>
89+
<execution>
90+
<id>add-java17-sources</id>
91+
<phase>generate-sources</phase>
92+
<goals>
93+
<goal>add-source</goal>
94+
</goals>
95+
<configuration>
96+
<sources>
97+
<source>${basedir}/src/main/java17</source>
98+
</sources>
99+
</configuration>
100+
</execution>
101+
</executions>
102+
</plugin>
103+
<plugin>
104+
<groupId>org.apache.maven.plugins</groupId>
105+
<artifactId>maven-compiler-plugin</artifactId>
106+
<configuration>
107+
<release>17</release>
108+
<compilerArgs>
109+
<arg>--add-modules</arg>
110+
<arg>jdk.javadoc</arg>
111+
</compilerArgs>
112+
</configuration>
113+
</plugin>
114+
</plugins>
115+
</build>
116+
</profile>
78117
</profiles>
79118

80119
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.classification.tools;
19+
20+
import jdk.javadoc.doclet.DocletEnvironment;
21+
import jdk.javadoc.doclet.Reporter;
22+
import javax.lang.model.SourceVersion;
23+
24+
import jdiff.JDiff;
25+
26+
/**
27+
* <a href="https://docs.oracle.com/en/java/javase/17/docs/api/jdk.javadoc/jdk/javadoc/doclet/Doclet.html">Doclet</a>
28+
* for excluding elements that are annotated with
29+
* {@link org.apache.hadoop.classification.InterfaceAudience.Private} or
30+
* {@link org.apache.hadoop.classification.InterfaceAudience.LimitedPrivate}.
31+
* It delegates to the JDiff Doclet, and takes the same options.
32+
*/
33+
public class ExcludePrivateAnnotationsJDiffDoclet {
34+
35+
public static SourceVersion languageVersion() {
36+
return SourceVersion.RELEASE_17;
37+
}
38+
39+
public static boolean start(DocletEnvironment root) {
40+
System.out.println(
41+
ExcludePrivateAnnotationsJDiffDoclet.class.getSimpleName());
42+
return JDiff.start(RootDocProcessor.process(root));
43+
}
44+
45+
public static int optionLength(String option) {
46+
Integer length = StabilityOptions.optionLength(option);
47+
if (length != null) {
48+
return length;
49+
}
50+
return JDiff.optionLength(option);
51+
}
52+
53+
public static boolean validOptions(String[][] options,
54+
Reporter reporter) {
55+
StabilityOptions.validOptions(options, reporter);
56+
String[][] filteredOptions = StabilityOptions.filterOptions(options);
57+
return JDiff.validOptions(filteredOptions, reporter);
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.classification.tools;
19+
20+
import jdk.javadoc.doclet.Doclet;
21+
import jdk.javadoc.doclet.DocletEnvironment;
22+
import jdk.javadoc.doclet.Reporter;
23+
import javax.lang.model.SourceVersion;
24+
import javax.lang.model.element.Element;
25+
26+
import jdk.javadoc.doclet.StandardDoclet;
27+
28+
import java.util.Locale;
29+
import java.util.Set;
30+
31+
/**
32+
* <a href="https://docs.oracle.com/en/java/javase/17/docs/api/jdk.javadoc/jdk/javadoc/doclet/Doclet.html">Doclet</a>
33+
* for excluding elements that are annotated with
34+
* {@link org.apache.hadoop.classification.InterfaceAudience.Private} or
35+
* {@link org.apache.hadoop.classification.InterfaceAudience.LimitedPrivate}.
36+
* It delegates to the Standard Doclet, and takes the same options.
37+
*/
38+
public class ExcludePrivateAnnotationsStandardDoclet implements Doclet {
39+
40+
private final StandardDoclet delegate = new StandardDoclet();
41+
private Reporter reporter;
42+
private Locale locale;
43+
44+
public static SourceVersion languageVersion() {
45+
return SourceVersion.RELEASE_17;
46+
}
47+
48+
public static boolean start(DocletEnvironment root) {
49+
System.out.println(ExcludePrivateAnnotationsStandardDoclet.class.getSimpleName());
50+
if (root.getSpecifiedElements().isEmpty()) {
51+
return true;
52+
}
53+
return new StandardDoclet().run(root);
54+
}
55+
56+
public static int optionLength(String option) {
57+
Integer length = StabilityOptions.optionLength(option);
58+
if (length != null) {
59+
return length;
60+
}
61+
for (Doclet.Option o : new StandardDoclet().getSupportedOptions()) {
62+
for (String name : o.getNames()) {
63+
if (name.equals(option)) {
64+
return o.getArgumentCount() + 1;
65+
}
66+
}
67+
}
68+
return 0;
69+
}
70+
71+
public static boolean validOptions(String[][] options, Reporter reporter) {
72+
StabilityOptions.validOptions(options, reporter);
73+
return true;
74+
}
75+
76+
@Override
77+
public void init(Locale locale, Reporter reporter) {
78+
this.locale = locale;
79+
this.reporter = reporter;
80+
delegate.init(locale, reporter);
81+
}
82+
83+
@Override
84+
public String getName() {
85+
return getClass().getSimpleName();
86+
}
87+
88+
@Override
89+
public Set<Option> getSupportedOptions() {
90+
Set<Option> s = new java.util.HashSet<>(delegate.getSupportedOptions());
91+
s.add(new Option() {
92+
@Override
93+
public int getArgumentCount() {
94+
return 0;
95+
}
96+
97+
@Override
98+
public String getDescription() {
99+
return "";
100+
}
101+
102+
@Override
103+
public Kind getKind() {
104+
return Kind.OTHER;
105+
}
106+
107+
@Override
108+
public java.util.List<String> getNames() {
109+
return java.util.Collections.singletonList("-unstable");
110+
}
111+
112+
@Override
113+
public String getParameters() {
114+
return "";
115+
}
116+
117+
@Override
118+
public boolean process(String opt, java.util.List<String> args) {
119+
StabilityOptions.setLevel(StabilityOptions.Level.UNSTABLE);
120+
return true;
121+
}
122+
});
123+
s.add(new Option() {
124+
@Override
125+
public int getArgumentCount() {
126+
return 0;
127+
}
128+
129+
@Override
130+
public String getDescription() {
131+
return "";
132+
}
133+
134+
@Override
135+
public Kind getKind() {
136+
return Kind.OTHER;
137+
}
138+
139+
@Override
140+
public java.util.List<String> getNames() {
141+
return java.util.Collections.singletonList("-evolving");
142+
}
143+
144+
@Override
145+
public String getParameters() {
146+
return "";
147+
}
148+
149+
@Override
150+
public boolean process(String opt, java.util.List<String> args) {
151+
StabilityOptions.setLevel(StabilityOptions.Level.EVOLVING);
152+
return true;
153+
}
154+
});
155+
return s;
156+
}
157+
158+
@Override
159+
public SourceVersion getSupportedSourceVersion() {
160+
return SourceVersion.RELEASE_17;
161+
}
162+
163+
@Override
164+
public boolean run(DocletEnvironment environment) {
165+
StabilityOptions.applyToRootProcessor();
166+
DocletEnvironment ignored = RootDocProcessor.process(environment);
167+
168+
if (environment.getIncludedElements().isEmpty()) {
169+
return true;
170+
}
171+
return delegate.run(environment);
172+
}
173+
}

0 commit comments

Comments
 (0)