本文整理汇总了Java中com.sun.beans.finder.MethodFinder.findAccessibleMethod方法的典型用法代码示例。如果您正苦于以下问题:Java MethodFinder.findAccessibleMethod方法的具体用法?Java MethodFinder.findAccessibleMethod怎么用?Java MethodFinder.findAccessibleMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.beans.finder.MethodFinder
的用法示例。
在下文中一共展示了MethodFinder.findAccessibleMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPublicDeclaredMethods
import com.sun.beans.finder.MethodFinder; //导入方法依赖的package包/类
private static Method[] getPublicDeclaredMethods(Class<?> clz) {
// Looking up Class.getDeclaredMethods is relatively expensive,
// so we cache the results.
if (!ReflectUtil.isPackageAccessible(clz)) {
return new Method[0];
}
synchronized (declaredMethodCache) {
Method[] result = declaredMethodCache.get(clz);
if (result == null) {
result = clz.getMethods();
for (int i = 0; i < result.length; i++) {
Method method = result[i];
if (!method.getDeclaringClass().equals(clz)) {
result[i] = null; // ignore methods declared elsewhere
}
else {
try {
method = MethodFinder.findAccessibleMethod(method);
Class<?> type = method.getDeclaringClass();
result[i] = type.equals(clz) || type.isInterface()
? method
: null; // ignore methods from superclasses
}
catch (NoSuchMethodException exception) {
// commented out because of 6976577
// result[i] = null; // ignore inaccessible methods
}
}
}
declaredMethodCache.put(clz, result);
}
return result;
}
}
示例2: get
import com.sun.beans.finder.MethodFinder; //导入方法依赖的package包/类
static List<Method> get(Class<?> type) {
List<Method> list = null;
if (type != null) {
boolean inaccessible = !Modifier.isPublic(type.getModifiers());
for (Method method : type.getMethods()) {
if (method.getDeclaringClass().equals(type)) {
if (inaccessible) {
try {
method = MethodFinder.findAccessibleMethod(method);
if (!method.getDeclaringClass().isInterface()) {
method = null; // ignore methods from superclasses
}
} catch (NoSuchMethodException exception) {
// commented out because of 6976577
// method = null; // ignore inaccessible methods
}
}
if (method != null) {
if (list == null) {
list = new ArrayList<>();
}
list.add(method);
}
}
}
}
if (list != null) {
list.sort(MethodOrder.instance);
return Collections.unmodifiableList(list);
}
return Collections.emptyList();
}
示例3: get
import com.sun.beans.finder.MethodFinder; //导入方法依赖的package包/类
static List<Method> get(Class<?> type) {
List<Method> list = null;
if (type != null) {
boolean inaccessible = !Modifier.isPublic(type.getModifiers());
for (Method method : type.getMethods()) {
if (method.getDeclaringClass().equals(type)) {
if (inaccessible) {
try {
method = MethodFinder.findAccessibleMethod(method);
if (!method.getDeclaringClass().isInterface()) {
method = null; // ignore methods from superclasses
}
} catch (NoSuchMethodException exception) {
// commented out because of 6976577
// method = null; // ignore inaccessible methods
}
}
if (method != null) {
if (list == null) {
list = new ArrayList<>();
}
list.add(method);
}
}
}
}
return (list != null)
? Collections.unmodifiableList(list)
: Collections.emptyList();
}