本文整理汇总了Java中com.sun.jdi.ReferenceType.methodsByName方法的典型用法代码示例。如果您正苦于以下问题:Java ReferenceType.methodsByName方法的具体用法?Java ReferenceType.methodsByName怎么用?Java ReferenceType.methodsByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.ReferenceType
的用法示例。
在下文中一共展示了ReferenceType.methodsByName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConcreteMethod
import com.sun.jdi.ReferenceType; //导入方法依赖的package包/类
private static Method getConcreteMethod(ReferenceType type, String methodName,
String firstParamSignature,
List<? extends TypeMirror> typeArguments) throws UnsuitableArgumentsException {
List<Method> methods = type.methodsByName(methodName);
String signature = createSignature(firstParamSignature, typeArguments);
boolean constructor = "<init>".equals(methodName);
for (Method method : methods) {
if (!method.isAbstract() &&
(!constructor || type.equals(method.declaringType())) &&
equalMethodSignatures(method.signature(), signature)) {
return method;
}
}
if (methods.size() > 0) {
throw new UnsuitableArgumentsException();
}
return null;
}
示例2: getConcreteMethod2
import com.sun.jdi.ReferenceType; //导入方法依赖的package包/类
private static Method getConcreteMethod2(ReferenceType type, String methodName, List<? extends Type> typeArguments) throws UnsuitableArgumentsException {
List<Method> methods = type.methodsByName(methodName);
List<Method> possibleMethods = new ArrayList<Method>();
List<Method> methodsWithArgTypesNotLoaded = null;
boolean constructor = "<init>".equals(methodName);
for (Method method : methods) {
if (!method.isAbstract() &&
(!constructor || type.equals(method.declaringType()))) {
try {
if (equalTypes(method.argumentTypes(), typeArguments)) {
return method;
}
if (acceptTypes(method.argumentTypes(), typeArguments)) {
possibleMethods.add(method);
}
} catch (ClassNotLoadedException ex) {
if (method.argumentTypeNames().size() == typeArguments.size()) {
if (methodsWithArgTypesNotLoaded == null) {
methodsWithArgTypesNotLoaded = new ArrayList<Method>();
}
methodsWithArgTypesNotLoaded.add(method);
}
}
}
}
if (possibleMethods.isEmpty()) {
if (methods.size() > 0) {
if (methodsWithArgTypesNotLoaded != null) {
// Workaround for cases when we're not able to test method types.
return methodsWithArgTypesNotLoaded.get(0);
}
throw new UnsuitableArgumentsException();
}
return null;
}
return possibleMethods.get(0);
}