当前位置: 首页>>代码示例>>Java>>正文


Java ClassType.methodsByName方法代码示例

本文整理汇总了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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:OomDebugTest.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:UnBoxingEvaluator.java

示例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());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:UnBoxingEvaluator.java

示例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());
    }   
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:42,代码来源:ClassTypeTest.java


注:本文中的com.sun.jdi.ClassType.methodsByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。