HADOOP-11814. Reformat hadoop-annotations, o.a.h.classification.tools. Contributed by Li Lu.
This commit is contained in:
parent
cc25823546
commit
dc0282d64c
@ -38,7 +38,7 @@ public static LanguageVersion languageVersion() {
|
|||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
public static boolean start(RootDoc root) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
ExcludePrivateAnnotationsJDiffDoclet.class.getSimpleName());
|
ExcludePrivateAnnotationsJDiffDoclet.class.getSimpleName());
|
||||||
return JDiff.start(RootDocProcessor.process(root));
|
return JDiff.start(RootDocProcessor.process(root));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public static LanguageVersion languageVersion() {
|
|||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
public static boolean start(RootDoc root) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
ExcludePrivateAnnotationsStandardDoclet.class.getSimpleName());
|
ExcludePrivateAnnotationsStandardDoclet.class.getSimpleName());
|
||||||
return Standard.start(RootDocProcessor.process(root));
|
return Standard.start(RootDocProcessor.process(root));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,47 +48,47 @@
|
|||||||
* Based on code from http://www.sixlegs.com/blog/java/exclude-javadoc-tag.html.
|
* Based on code from http://www.sixlegs.com/blog/java/exclude-javadoc-tag.html.
|
||||||
*/
|
*/
|
||||||
class RootDocProcessor {
|
class RootDocProcessor {
|
||||||
|
|
||||||
static String stability = StabilityOptions.UNSTABLE_OPTION;
|
static String stability = StabilityOptions.UNSTABLE_OPTION;
|
||||||
static boolean treatUnannotatedClassesAsPrivate = false;
|
static boolean treatUnannotatedClassesAsPrivate = false;
|
||||||
|
|
||||||
public static RootDoc process(RootDoc root) {
|
public static RootDoc process(RootDoc root) {
|
||||||
return (RootDoc) process(root, RootDoc.class);
|
return (RootDoc) process(root, RootDoc.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object process(Object obj, Class<?> type) {
|
private static Object process(Object obj, Class<?> type) {
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Class<?> cls = obj.getClass();
|
Class<?> cls = obj.getClass();
|
||||||
if (cls.getName().startsWith("com.sun.")) {
|
if (cls.getName().startsWith("com.sun.")) {
|
||||||
return getProxy(obj);
|
return getProxy(obj);
|
||||||
} else if (obj instanceof Object[]) {
|
} else if (obj instanceof Object[]) {
|
||||||
Class<?> componentType = type.isArray() ? type.getComponentType()
|
Class<?> componentType = type.isArray() ? type.getComponentType()
|
||||||
: cls.getComponentType();
|
: cls.getComponentType();
|
||||||
Object[] array = (Object[]) obj;
|
Object[] array = (Object[]) obj;
|
||||||
Object[] newArray = (Object[]) Array.newInstance(componentType,
|
Object[] newArray = (Object[]) Array.newInstance(componentType,
|
||||||
array.length);
|
array.length);
|
||||||
for (int i = 0; i < array.length; ++i) {
|
for (int i = 0; i < array.length; ++i) {
|
||||||
newArray[i] = process(array[i], componentType);
|
newArray[i] = process(array[i], componentType);
|
||||||
}
|
}
|
||||||
return newArray;
|
return newArray;
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<Object, Object> proxies =
|
private static Map<Object, Object> proxies =
|
||||||
new WeakHashMap<Object, Object>();
|
new WeakHashMap<Object, Object>();
|
||||||
|
|
||||||
private static Object getProxy(Object obj) {
|
private static Object getProxy(Object obj) {
|
||||||
Object proxy = proxies.get(obj);
|
Object proxy = proxies.get(obj);
|
||||||
if (proxy == null) {
|
if (proxy == null) {
|
||||||
proxy = Proxy.newProxyInstance(obj.getClass().getClassLoader(),
|
proxy = Proxy.newProxyInstance(obj.getClass().getClassLoader(),
|
||||||
obj.getClass().getInterfaces(), new ExcludeHandler(obj));
|
obj.getClass().getInterfaces(), new ExcludeHandler(obj));
|
||||||
proxies.put(obj, proxy);
|
proxies.put(obj, proxy);
|
||||||
}
|
}
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ExcludeHandler implements InvocationHandler {
|
private static class ExcludeHandler implements InvocationHandler {
|
||||||
private Object target;
|
private Object target;
|
||||||
@ -96,116 +96,116 @@ private static class ExcludeHandler implements InvocationHandler {
|
|||||||
public ExcludeHandler(Object target) {
|
public ExcludeHandler(Object target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args)
|
public Object invoke(Object proxy, Method method, Object[] args)
|
||||||
throws Throwable {
|
throws Throwable {
|
||||||
String methodName = method.getName();
|
String methodName = method.getName();
|
||||||
if (target instanceof Doc) {
|
if (target instanceof Doc) {
|
||||||
if (methodName.equals("isIncluded")) {
|
if (methodName.equals("isIncluded")) {
|
||||||
Doc doc = (Doc) target;
|
Doc doc = (Doc) target;
|
||||||
return !exclude(doc) && doc.isIncluded();
|
return !exclude(doc) && doc.isIncluded();
|
||||||
}
|
}
|
||||||
if (target instanceof RootDoc) {
|
if (target instanceof RootDoc) {
|
||||||
if (methodName.equals("classes")) {
|
if (methodName.equals("classes")) {
|
||||||
return filter(((RootDoc) target).classes(), ClassDoc.class);
|
return filter(((RootDoc) target).classes(), ClassDoc.class);
|
||||||
} else if (methodName.equals("specifiedClasses")) {
|
} else if (methodName.equals("specifiedClasses")) {
|
||||||
return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class);
|
return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class);
|
||||||
} else if (methodName.equals("specifiedPackages")) {
|
} else if (methodName.equals("specifiedPackages")) {
|
||||||
return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class);
|
return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class);
|
||||||
}
|
}
|
||||||
} else if (target instanceof ClassDoc) {
|
} else if (target instanceof ClassDoc) {
|
||||||
if (isFiltered(args)) {
|
if (isFiltered(args)) {
|
||||||
if (methodName.equals("methods")) {
|
if (methodName.equals("methods")) {
|
||||||
return filter(((ClassDoc) target).methods(true), MethodDoc.class);
|
return filter(((ClassDoc) target).methods(true), MethodDoc.class);
|
||||||
} else if (methodName.equals("fields")) {
|
} else if (methodName.equals("fields")) {
|
||||||
return filter(((ClassDoc) target).fields(true), FieldDoc.class);
|
return filter(((ClassDoc) target).fields(true), FieldDoc.class);
|
||||||
} else if (methodName.equals("innerClasses")) {
|
} else if (methodName.equals("innerClasses")) {
|
||||||
return filter(((ClassDoc) target).innerClasses(true),
|
return filter(((ClassDoc) target).innerClasses(true),
|
||||||
ClassDoc.class);
|
ClassDoc.class);
|
||||||
} else if (methodName.equals("constructors")) {
|
} else if (methodName.equals("constructors")) {
|
||||||
return filter(((ClassDoc) target).constructors(true),
|
return filter(((ClassDoc) target).constructors(true),
|
||||||
ConstructorDoc.class);
|
ConstructorDoc.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (target instanceof PackageDoc) {
|
} else if (target instanceof PackageDoc) {
|
||||||
if (methodName.equals("allClasses")) {
|
if (methodName.equals("allClasses")) {
|
||||||
if (isFiltered(args)) {
|
if (isFiltered(args)) {
|
||||||
return filter(((PackageDoc) target).allClasses(true),
|
return filter(((PackageDoc) target).allClasses(true),
|
||||||
ClassDoc.class);
|
ClassDoc.class);
|
||||||
} else {
|
} else {
|
||||||
return filter(((PackageDoc) target).allClasses(), ClassDoc.class);
|
return filter(((PackageDoc) target).allClasses(), ClassDoc.class);
|
||||||
}
|
}
|
||||||
} else if (methodName.equals("annotationTypes")) {
|
} else if (methodName.equals("annotationTypes")) {
|
||||||
return filter(((PackageDoc) target).annotationTypes(),
|
return filter(((PackageDoc) target).annotationTypes(),
|
||||||
AnnotationTypeDoc.class);
|
AnnotationTypeDoc.class);
|
||||||
} else if (methodName.equals("enums")) {
|
} else if (methodName.equals("enums")) {
|
||||||
return filter(((PackageDoc) target).enums(),
|
return filter(((PackageDoc) target).enums(),
|
||||||
ClassDoc.class);
|
ClassDoc.class);
|
||||||
} else if (methodName.equals("errors")) {
|
} else if (methodName.equals("errors")) {
|
||||||
return filter(((PackageDoc) target).errors(),
|
return filter(((PackageDoc) target).errors(),
|
||||||
ClassDoc.class);
|
ClassDoc.class);
|
||||||
} else if (methodName.equals("exceptions")) {
|
} else if (methodName.equals("exceptions")) {
|
||||||
return filter(((PackageDoc) target).exceptions(),
|
return filter(((PackageDoc) target).exceptions(),
|
||||||
ClassDoc.class);
|
ClassDoc.class);
|
||||||
} else if (methodName.equals("interfaces")) {
|
} else if (methodName.equals("interfaces")) {
|
||||||
return filter(((PackageDoc) target).interfaces(),
|
return filter(((PackageDoc) target).interfaces(),
|
||||||
ClassDoc.class);
|
ClassDoc.class);
|
||||||
} else if (methodName.equals("ordinaryClasses")) {
|
} else if (methodName.equals("ordinaryClasses")) {
|
||||||
return filter(((PackageDoc) target).ordinaryClasses(),
|
return filter(((PackageDoc) target).ordinaryClasses(),
|
||||||
ClassDoc.class);
|
ClassDoc.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
if (methodName.equals("compareTo") || methodName.equals("equals")
|
if (methodName.equals("compareTo") || methodName.equals("equals")
|
||||||
|| methodName.equals("overrides")
|
|| methodName.equals("overrides")
|
||||||
|| methodName.equals("subclassOf")) {
|
|| methodName.equals("subclassOf")) {
|
||||||
args[0] = unwrap(args[0]);
|
args[0] = unwrap(args[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return process(method.invoke(target, args), method.getReturnType());
|
return process(method.invoke(target, args), method.getReturnType());
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw e.getTargetException();
|
throw e.getTargetException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean exclude(Doc doc) {
|
private static boolean exclude(Doc doc) {
|
||||||
AnnotationDesc[] annotations = null;
|
AnnotationDesc[] annotations = null;
|
||||||
if (doc instanceof ProgramElementDoc) {
|
if (doc instanceof ProgramElementDoc) {
|
||||||
annotations = ((ProgramElementDoc) doc).annotations();
|
annotations = ((ProgramElementDoc) doc).annotations();
|
||||||
} else if (doc instanceof PackageDoc) {
|
} else if (doc instanceof PackageDoc) {
|
||||||
annotations = ((PackageDoc) doc).annotations();
|
annotations = ((PackageDoc) doc).annotations();
|
||||||
}
|
}
|
||||||
if (annotations != null) {
|
if (annotations != null) {
|
||||||
for (AnnotationDesc annotation : annotations) {
|
for (AnnotationDesc annotation : annotations) {
|
||||||
String qualifiedTypeName = annotation.annotationType().qualifiedTypeName();
|
String qualifiedTypeName = annotation.annotationType().qualifiedTypeName();
|
||||||
if (qualifiedTypeName.equals(
|
if (qualifiedTypeName.equals(
|
||||||
InterfaceAudience.Private.class.getCanonicalName())
|
InterfaceAudience.Private.class.getCanonicalName())
|
||||||
|| qualifiedTypeName.equals(
|
|
||||||
InterfaceAudience.LimitedPrivate.class.getCanonicalName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (stability.equals(StabilityOptions.EVOLVING_OPTION)) {
|
|
||||||
if (qualifiedTypeName.equals(
|
|
||||||
InterfaceStability.Unstable.class.getCanonicalName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (stability.equals(StabilityOptions.STABLE_OPTION)) {
|
|
||||||
if (qualifiedTypeName.equals(
|
|
||||||
InterfaceStability.Unstable.class.getCanonicalName())
|
|
||||||
|| qualifiedTypeName.equals(
|
|| qualifiedTypeName.equals(
|
||||||
InterfaceStability.Evolving.class.getCanonicalName())) {
|
InterfaceAudience.LimitedPrivate.class.getCanonicalName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
if (stability.equals(StabilityOptions.EVOLVING_OPTION)) {
|
||||||
}
|
if (qualifiedTypeName.equals(
|
||||||
|
InterfaceStability.Unstable.class.getCanonicalName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (stability.equals(StabilityOptions.STABLE_OPTION)) {
|
||||||
|
if (qualifiedTypeName.equals(
|
||||||
|
InterfaceStability.Unstable.class.getCanonicalName())
|
||||||
|
|| qualifiedTypeName.equals(
|
||||||
|
InterfaceStability.Evolving.class.getCanonicalName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for (AnnotationDesc annotation : annotations) {
|
for (AnnotationDesc annotation : annotations) {
|
||||||
String qualifiedTypeName =
|
String qualifiedTypeName =
|
||||||
annotation.annotationType().qualifiedTypeName();
|
annotation.annotationType().qualifiedTypeName();
|
||||||
if (qualifiedTypeName.equals(
|
if (qualifiedTypeName.equals(
|
||||||
InterfaceAudience.Public.class.getCanonicalName())) {
|
InterfaceAudience.Public.class.getCanonicalName())) {
|
||||||
return false;
|
return false;
|
||||||
@ -217,27 +217,27 @@ private static boolean exclude(Doc doc) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object[] filter(Doc[] array, Class<?> componentType) {
|
private static Object[] filter(Doc[] array, Class<?> componentType) {
|
||||||
if (array == null || array.length == 0) {
|
if (array == null || array.length == 0) {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
List<Object> list = new ArrayList<Object>(array.length);
|
List<Object> list = new ArrayList<Object>(array.length);
|
||||||
for (Doc entry : array) {
|
for (Doc entry : array) {
|
||||||
if (!exclude(entry)) {
|
if (!exclude(entry)) {
|
||||||
list.add(process(entry, componentType));
|
list.add(process(entry, componentType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list.toArray((Object[]) Array.newInstance(componentType, list
|
return list.toArray((Object[]) Array.newInstance(componentType, list
|
||||||
.size()));
|
.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object unwrap(Object proxy) {
|
private Object unwrap(Object proxy) {
|
||||||
if (proxy instanceof Proxy)
|
if (proxy instanceof Proxy)
|
||||||
return ((ExcludeHandler) Proxy.getInvocationHandler(proxy)).target;
|
return ((ExcludeHandler) Proxy.getInvocationHandler(proxy)).target;
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFiltered(Object[] args) {
|
private boolean isFiltered(Object[] args) {
|
||||||
return args != null && Boolean.TRUE.equals(args[0]);
|
return args != null && Boolean.TRUE.equals(args[0]);
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,11 @@ public static void validOptions(String[][] options,
|
|||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
String opt = options[i][0].toLowerCase(Locale.ENGLISH);
|
String opt = options[i][0].toLowerCase(Locale.ENGLISH);
|
||||||
if (opt.equals(UNSTABLE_OPTION)) {
|
if (opt.equals(UNSTABLE_OPTION)) {
|
||||||
RootDocProcessor.stability = UNSTABLE_OPTION;
|
RootDocProcessor.stability = UNSTABLE_OPTION;
|
||||||
} else if (opt.equals(EVOLVING_OPTION)) {
|
} else if (opt.equals(EVOLVING_OPTION)) {
|
||||||
RootDocProcessor.stability = EVOLVING_OPTION;
|
RootDocProcessor.stability = EVOLVING_OPTION;
|
||||||
} else if (opt.equals(STABLE_OPTION)) {
|
} else if (opt.equals(STABLE_OPTION)) {
|
||||||
RootDocProcessor.stability = STABLE_OPTION;
|
RootDocProcessor.stability = STABLE_OPTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -54,9 +54,9 @@ public static String[][] filterOptions(String[][] options) {
|
|||||||
List<String[]> optionsList = new ArrayList<String[]>();
|
List<String[]> optionsList = new ArrayList<String[]>();
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
if (!options[i][0].equalsIgnoreCase(UNSTABLE_OPTION)
|
if (!options[i][0].equalsIgnoreCase(UNSTABLE_OPTION)
|
||||||
&& !options[i][0].equalsIgnoreCase(EVOLVING_OPTION)
|
&& !options[i][0].equalsIgnoreCase(EVOLVING_OPTION)
|
||||||
&& !options[i][0].equalsIgnoreCase(STABLE_OPTION)) {
|
&& !options[i][0].equalsIgnoreCase(STABLE_OPTION)) {
|
||||||
optionsList.add(options[i]);
|
optionsList.add(options[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String[][] filteredOptions = new String[optionsList.size()][];
|
String[][] filteredOptions = new String[optionsList.size()][];
|
||||||
|
@ -487,6 +487,9 @@ Release 2.8.0 - UNRELEASED
|
|||||||
HADOOP-11717. Support JWT tokens for web single sign on to the Hadoop
|
HADOOP-11717. Support JWT tokens for web single sign on to the Hadoop
|
||||||
servers. (Larry McCay via omalley)
|
servers. (Larry McCay via omalley)
|
||||||
|
|
||||||
|
HADOOP-11814. Reformat hadoop-annotations, o.a.h.classification.tools.
|
||||||
|
(Li Lu via wheat9)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-11785. Reduce the number of listStatus operation in distcp
|
HADOOP-11785. Reduce the number of listStatus operation in distcp
|
||||||
|
Loading…
Reference in New Issue
Block a user