本文整理汇总了Java中com.sun.jdi.ClassType.methodsByName方法的典型用法代码示例。如果您正苦于以下问题:Java ClassType.methodsByName方法的具体用法?Java ClassType.methodsByName怎么用?Java ClassType.methodsByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.ClassType
的用法示例。
在下文中一共展示了ClassType.methodsByName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getConstructorForClass
import com.sun.jdi.ClassType; //导入方法依赖的package包/类
private Method getConstructorForClass(ClassType clsType) {
List<Method> methods = clsType.methodsByName("<init>");
if (methods.size() != 1) {
throw new RuntimeException("FAIL. Expected only one, the default, constructor");
}
return methods.get(0);
}
示例2: convertToPrimitive
import com.sun.jdi.ClassType; //导入方法依赖的package包/类
private static Value convertToPrimitive(EvaluationContextImpl context, ObjectReference value, final String conversionMethodName,
String conversionMethodSignature) throws EvaluateException {
final DebugProcessImpl process = context.getDebugProcess();
final ClassType wrapperClass = (ClassType)value.referenceType();
final List<Method> methods = wrapperClass.methodsByName(conversionMethodName, conversionMethodSignature);
if (methods.size() == 0) {
throw new EvaluateException("Cannot convert to primitive value of type " + value.type() + ": Unable to find method " +
conversionMethodName + conversionMethodSignature);
}
return process.invokeMethod(context, value, methods.get(0), Collections.emptyList());
}
示例3: convertToPrimitive
import com.sun.jdi.ClassType; //导入方法依赖的package包/类
private static Value convertToPrimitive(EvaluationContextImpl context, ObjectReference value, final String conversionMethodName,
String conversionMethodSignature) throws EvaluateException {
final DebugProcessImpl process = context.getDebugProcess();
final ClassType wrapperClass = (ClassType)value.referenceType();
final List<Method> methods = wrapperClass.methodsByName(conversionMethodName, conversionMethodSignature);
if (methods.size() == 0) {
throw new EvaluateException("Cannot convert to primitive value of type " + value.type() + ": Unable to find method " +
conversionMethodName + conversionMethodSignature);
}
final Method method = methods.get(0);
return process.invokeMethod(context, value, method, new ArrayList());
}
示例4: testObjectMethods
import com.sun.jdi.ClassType; //导入方法依赖的package包/类
@Test
public void testObjectMethods() {
ClassType objectType = getCoreClassType("java.lang.Object");
ClassType stringType = getCoreClassType("java.lang.String");
ClassType classType = getCoreClassType("java.lang.Class");
Type integerType = getVM().mirrorOf(0).type();
Type booleanType = getVM().mirrorOf(false).type();
// test few methods of java.lang.Object
try {
List<Method> methodList;
methodList = objectType.methodsByName("toString");
Assert.assertEquals(1, methodList.size());
Method toString = methodList.get(0);
Assert.assertEquals(true, toString.argumentTypes().isEmpty());
Assert.assertEquals(stringType, toString.returnType());
methodList = objectType.methodsByName("hashCode");
Assert.assertEquals(1, methodList.size());
Method hashCode = methodList.get(0);
Assert.assertEquals(true, hashCode.argumentTypeNames().isEmpty());
Assert.assertEquals(integerType, hashCode.returnType());
methodList = objectType.methodsByName("equals");
Assert.assertEquals(1, methodList.size());
Method equals = methodList.get(0);
Assert.assertEquals(1, equals.argumentTypeNames().size());
Assert.assertEquals(objectType, equals.argumentTypes().get(0));
Assert.assertEquals(booleanType, equals.returnType());
methodList = objectType.methodsByName("getClass");
Assert.assertEquals(1, methodList.size());
Method getClass = methodList.get(0);
Assert.assertEquals(0, getClass.argumentTypes().size());
Assert.assertEquals(classType, getClass.returnType());
} catch (ClassNotLoadedException cnle) {
Assert.fail(cnle.getMessage());
}
}