• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Type类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.jdi.Type的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Type类属于com.sun.jdi包,在下文中一共展示了Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: boxType

import com.sun.jdi.Type; //导入依赖的package包/类
private static Type boxType(Type t) {
    if (t instanceof ClassType) {
        String name = ((ClassType) t).name();
        if (name.equals("java.lang.Boolean")) {
            t = t.virtualMachine().mirrorOf(true).type();
        } else if (name.equals("java.lang.Byte")) {
            t = t.virtualMachine().mirrorOf((byte) 10).type();
        } else if (name.equals("java.lang.Character")) {
            t = t.virtualMachine().mirrorOf('a').type();
        } else if (name.equals("java.lang.Integer")) {
            t = t.virtualMachine().mirrorOf(10).type();
        } else if (name.equals("java.lang.Long")) {
            t = t.virtualMachine().mirrorOf(10l).type();
        } else if (name.equals("java.lang.Short")) {
            t = t.virtualMachine().mirrorOf((short)10).type();
        } else if (name.equals("java.lang.Float")) {
            t = t.virtualMachine().mirrorOf(10f).type();
        } else if (name.equals("java.lang.Double")) {
            t = t.virtualMachine().mirrorOf(10.0).type();
        }
    }
    return t;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:VariableMirrorTranslator.java


示例2: hasAllTypes

import com.sun.jdi.Type; //导入依赖的package包/类
public boolean hasAllTypes() {
    if (getInnerValue () == null) {
        return true;
    }
    Type t;
    synchronized (valueTypeLoaded) {
        if (!valueTypeLoaded[0]) {
            return false;
        }
        t = valueType;
    }
    if (t instanceof ClassType) {
        ClassType ct = (ClassType) t;
        if (!getDebugger().hasAllInterfaces(ct)) {
            return false;
        }
        synchronized (superClassLoaded) {
            if (!superClassLoaded[0]) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:AbstractObjectVariable.java


示例3: getAllInterfaces

import com.sun.jdi.Type; //导入依赖的package包/类
public List<JPDAClassType> getAllInterfaces() {
    if (getInnerValue () == null) {
        return null;
    }
    try {
        Type t = getCachedType();
        if (!(t instanceof ClassType)) {
            return null;
        }
        ClassType ct = (ClassType) t;
        return getDebugger().getAllInterfaces(ct);
    } catch (ObjectCollectedExceptionWrapper ocex) {
        return null;
    } catch (InternalExceptionWrapper ex) {
        return null;
    } catch (VMDisconnectedExceptionWrapper e) {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AbstractObjectVariable.java


示例4: hasChildren

import com.sun.jdi.Type; //导入依赖的package包/类
/**
 * Test whether the value has referenced objects.
 *
 * @param value
 *            the value.
 * @param includeStatic
 *            whether or not the static fields are visible.
 * @return true if this value is reference objects.
 */
public static boolean hasChildren(Value value, boolean includeStatic) {
    if (value == null) {
        return false;
    }
    Type type = value.type();
    if (type instanceof ArrayType) {
        return ((ArrayReference) value).length() > 0;
    }
    return value.type() instanceof ReferenceType && ((ReferenceType) type).allFields().stream()
            .filter(t -> includeStatic || !t.isStatic()).toArray().length > 0;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:21,代码来源:VariableUtils.java


示例5: handleSetValueForObject

import com.sun.jdi.Type; //导入依赖的package包/类
private Value handleSetValueForObject(String name, String belongToClass, String valueString,
        ObjectReference container, Map<String, Object> options) throws InvalidTypeException, ClassNotLoadedException {
    Value newValue;
    if (container instanceof ArrayReference) {
        ArrayReference array = (ArrayReference) container;
        Type eleType = ((ArrayType) array.referenceType()).componentType();
        newValue = setArrayValue(array, eleType, Integer.parseInt(name), valueString, options);
    } else {
        if (StringUtils.isBlank(belongToClass)) {
            Field field = container.referenceType().fieldByName(name);
            if (field != null) {
                if (field.isStatic()) {
                    newValue = this.setStaticFieldValue(container.referenceType(), field, name, valueString, options);
                } else {
                    newValue = this.setObjectFieldValue(container, field, name, valueString, options);
                }
            } else {
                throw new IllegalArgumentException(
                        String.format("SetVariableRequest: Variable %s cannot be found.", name));
            }
        } else {
            newValue = setFieldValueWithConflict(container, container.referenceType().allFields(), name, belongToClass, valueString, options);
        }
    }
    return newValue;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:27,代码来源:SetVariableRequestHandler.java


示例6: unboxType

import com.sun.jdi.Type; //导入依赖的package包/类
private static Type unboxType(Type t) {
    if (t instanceof ClassType) {
        String name = ((ClassType) t).name();
        if (name.equals("java.lang.Boolean")) {
            t = t.virtualMachine().mirrorOf(true).type();
        } else if (name.equals("java.lang.Byte")) {
            t = t.virtualMachine().mirrorOf((byte) 10).type();
        } else if (name.equals("java.lang.Character")) {
            t = t.virtualMachine().mirrorOf('a').type();
        } else if (name.equals("java.lang.Integer")) {
            t = t.virtualMachine().mirrorOf(10).type();
        } else if (name.equals("java.lang.Long")) {
            t = t.virtualMachine().mirrorOf(10l).type();
        } else if (name.equals("java.lang.Short")) {
            t = t.virtualMachine().mirrorOf((short)10).type();
        } else if (name.equals("java.lang.Float")) {
            t = t.virtualMachine().mirrorOf(10f).type();
        } else if (name.equals("java.lang.Double")) {
            t = t.virtualMachine().mirrorOf(10.0).type();
        }
    }
    return t;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:EvaluatorVisitor.java


示例7: getArrayType

import com.sun.jdi.Type; //导入依赖的package包/类
private ArrayType getArrayType(NewArrayTree arg0, Type type, int depth, EvaluationContext evaluationContext) {
    String arrayClassName;
    if (depth < BRACKETS.length()/2) {
        arrayClassName = type.name() + BRACKETS.substring(0, 2*depth);
    } else {
        arrayClassName = type.name() + BRACKETS;
        for (int i = BRACKETS.length()/2; i < depth; i++) {
            arrayClassName += "[]"; // NOI18N
        }
    }
    ReferenceType rt = getOrLoadClass(type.virtualMachine(), arrayClassName, evaluationContext);
    if (rt == null) {
        Assert.error(arg0, "unknownType", arrayClassName);
    }
    return (ArrayType) rt;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:EvaluatorVisitor.java


示例8: getSubArrayType

import com.sun.jdi.Type; //导入依赖的package包/类
private Type getSubArrayType(Tree arg0, Type type, EvaluationContext evaluationContext) {
    String name = type.name();
    if (name.endsWith("[]")) {
        name = name.substring(0, name.length() - 2);
        if (!name.endsWith("[]")) {
            Type pType = getPrimitiveType(name, type.virtualMachine());
            if (pType != null) {
                return pType;
            }
        }
        type = getOrLoadClass(type.virtualMachine(), name, evaluationContext);
        if (type == null) {
            Assert.error(arg0, "unknownType", name);
        }
    }
    return type;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:EvaluatorVisitor.java


示例9: visitArrayType

import com.sun.jdi.Type; //导入依赖的package包/类
@Override
public Mirror visitArrayType(ArrayTypeTree arg0, EvaluationContext evaluationContext) {
    Mirror arrayType = arg0.getType().accept(this, evaluationContext);
    if (!(arrayType instanceof Type)) {
        return arrayType;
    }
    Type type = (Type) arrayType;
    String arrayClassName = type.name()+"[]";
    ReferenceType aType = getOrLoadClass(type.virtualMachine(), arrayClassName, evaluationContext);
    if (aType != null) {
        return aType;
    } else {
        Assert.error(arg0, "unknownType", arrayClassName);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:EvaluatorVisitor.java


示例10: autoboxArguments

import com.sun.jdi.Type; //导入依赖的package包/类
/**
 * Auto-boxes or un-boxes arguments of a method.
 */
static void autoboxArguments(List<Type> types, List<Value> argVals,
                             ThreadReference evaluationThread,
                             EvaluationContext evaluationContext) throws InvalidTypeException,
                                                                         ClassNotLoadedException,
                                                                         IncompatibleThreadStateException,
                                                                         InvocationException {
    if (types.size() != argVals.size()) {
        return ;
    }
    int n = types.size();
    for (int i = 0; i < n; i++) {
        Type t = types.get(i);
        Value v = argVals.get(i);
        if (v instanceof ObjectReference && t instanceof PrimitiveType) {
            argVals.set(i, unbox((ObjectReference) v, (PrimitiveType) t, evaluationThread, evaluationContext));
        }
        if (v instanceof PrimitiveValue && t instanceof ReferenceType) {
            argVals.set(i, box((PrimitiveValue) v, (ReferenceType) t, evaluationThread, evaluationContext));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:EvaluatorVisitor.java


示例11: findType

import com.sun.jdi.Type; //导入依赖的package包/类
Type findType(String signature) throws ClassNotLoadedException {
    Type type;
    if (signature.length() == 1) {
        /* OTI FIX: Must be a primitive type or the void type */
        char sig = signature.charAt(0);
        if (sig == 'V') {
            type = vm.theVoidType();
        } else {
            type = vm.primitiveTypeMirror((byte)sig);
        }
    } else {
        // Must be a reference type.
        ClassLoaderReferenceImpl loader =
                   (ClassLoaderReferenceImpl)classLoader();
        if ((loader == null) ||
            (isPrimitiveArray(signature)) //Work around 4450091
            ) {
            // Caller wants type of boot class field
            type = vm.findBootType(signature);
        } else {
            // Caller wants type of non-boot class field
            type = loader.findType(signature);
        }
    }
    return type;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ReferenceTypeImpl.java


示例12: findComponentType

import com.sun.jdi.Type; //导入依赖的package包/类
Type findComponentType(String signature) throws ClassNotLoadedException {
    byte tag = (byte)signature.charAt(0);
    if (PacketStream.isObjectTag(tag)) {
        // It's a reference type
        JNITypeParser parser = new JNITypeParser(componentSignature());
        List<ReferenceType> list = vm.classesByName(parser.typeName());
        Iterator<ReferenceType> iter = list.iterator();
        while (iter.hasNext()) {
            ReferenceType type = iter.next();
            ClassLoaderReference cl = type.classLoader();
            if ((cl == null)?
                     (classLoader() == null) :
                     (cl.equals(classLoader()))) {
                return type;
            }
        }
        // Component class has not yet been loaded
        throw new ClassNotLoadedException(componentTypeName());
    } else {
        // It's a primitive type
        return vm.primitiveTypeMirror(tag);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ArrayTypeImpl.java


示例13: isComponentAssignable

import com.sun.jdi.Type; //导入依赖的package包/类
static boolean isComponentAssignable(Type destination, Type source) {
    if (source instanceof PrimitiveType) {
        // Assignment of primitive arrays requires identical
        // component types.
        return source.equals(destination);
    } else {
        if (destination instanceof PrimitiveType) {
            return false;
        }

        ReferenceTypeImpl refSource = (ReferenceTypeImpl)source;
        ReferenceTypeImpl refDestination = (ReferenceTypeImpl)destination;
        // Assignment of object arrays requires availability
        // of widening conversion of component types
        return refSource.isAssignableTo(refDestination);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ArrayTypeImpl.java


示例14: isAssignableTo

import com.sun.jdi.Type; //导入依赖的package包/类
boolean isAssignableTo(ReferenceType destType) {
    if (destType instanceof ArrayType) {
        try {
            Type destComponentType = ((ArrayType)destType).componentType();
            return isComponentAssignable(destComponentType, componentType());
        } catch (ClassNotLoadedException e) {
            // One or both component types has not yet been
            // loaded => can't assign
            return false;
        }
    } else if (destType instanceof InterfaceType) {
        // Only valid InterfaceType assignee is Cloneable
        return destType.name().equals("java.lang.Cloneable");
    } else {
        // Only valid ClassType assignee is Object
        return destType.name().equals("java.lang.Object");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ArrayTypeImpl.java


示例15: getFormatter

import com.sun.jdi.Type; //导入依赖的package包/类
private static IFormatter getFormatter(Map<? extends IFormatter, Integer> formatterMap, Type type,
                                       Map<String, Object> options) {
    List<? extends IFormatter> formatterList =
            formatterMap.keySet().stream().filter(t -> t.acceptType(type, options))
                    .sorted((a, b) ->
                            -Integer.compare(formatterMap.get(a), formatterMap.get(b))).collect(Collectors.toList());
    if (formatterList.isEmpty()) {
        throw new UnsupportedOperationException(String.format("There is no related formatter for type %s.",
                type == null ? "null" : type.name()));
    }
    return formatterList.get(0);
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:13,代码来源:VariableFormatter.java


示例16: getSubExpressionType

import com.sun.jdi.Type; //导入依赖的package包/类
private Type getSubExpressionType(Tree t) {
    Type type = subExpressionTypes.get(t);
    if (type != null) {
        return type;
    } else {
        if (t.getKind() == Tree.Kind.PARENTHESIZED) {
            return getSubExpressionType(((ParenthesizedTree) t).getExpression());
        }
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:EvaluatorVisitor.java


示例17: findEnclosingTypeWithMethod

import com.sun.jdi.Type; //导入依赖的package包/类
private ReferenceType findEnclosingTypeWithMethod(ReferenceType type,
                                                  String enclosingClass,
                                                  String methodName,
                                                  List<? extends TypeMirror> paramTypes,
                                                  List<? extends Type> argTypes,
                                                  Method[] methodPtr,
                                                  VMCache vmCache) {
    ReferenceType etype = findEnclosingType(type, enclosingClass, vmCache);
    if (etype == null) {
        return null;
    }
    Method method;
    try {
        if (paramTypes != null) {
            method = getConcreteMethod(etype, methodName, null, paramTypes);
        } else {
            method = getConcreteMethod2(etype, methodName, argTypes);
        }
    } catch (UnsuitableArgumentsException uaex) {
        method = null;
    }
    if (method != null) {
        methodPtr[0] = method;
        return etype;
    } else {
        return type;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:EvaluatorVisitor.java


示例18: getConcreteMethod2

import com.sun.jdi.Type; //导入依赖的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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:EvaluatorVisitor.java


示例19: setStaticFieldValue

import com.sun.jdi.Type; //导入依赖的package包/类
private Value setStaticFieldValue(Type declaringType, Field field, String name, String value, Map<String, Object> options)
        throws ClassNotLoadedException, InvalidTypeException {
    if (field.isFinal()) {
        throw new UnsupportedOperationException(
                String.format("SetVariableRequest: Final field %s cannot be changed.", name));
    }
    if (!(declaringType instanceof ClassType)) {
        throw new UnsupportedOperationException(
                String.format("SetVariableRequest: Field %s in interface cannot be changed.", name));
    }
    return setValueProxy(field.type(), value, newValue -> ((ClassType) declaringType).setValue(field, newValue), options);
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:13,代码来源:SetVariableRequestHandler.java


示例20: getPrimitiveType

import com.sun.jdi.Type; //导入依赖的package包/类
private Type getPrimitiveType(String name, VirtualMachine vm) {
    if (name.equals(Boolean.TYPE.getName())) {
        return vm.mirrorOf(true).type();
    }
    if (name.equals((Byte.TYPE.getName()))) {
        return vm.mirrorOf((byte) 0).type();
    }
    if (name.equals((Character.TYPE.getName()))) {
        return vm.mirrorOf('a').type();
    }
    if (name.equals((Double.TYPE.getName()))) {
        return vm.mirrorOf(0.).type();
    }
    if (name.equals((Float.TYPE.getName()))) {
        return vm.mirrorOf(0f).type();
    }
    if (name.equals((Integer.TYPE.getName()))) {
        return vm.mirrorOf(0).type();
    }
    if (name.equals((Long.TYPE.getName()))) {
        return vm.mirrorOf(0l).type();
    }
    if (name.equals((Short.TYPE.getName()))) {
        return vm.mirrorOf((short) 0).type();
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:EvaluatorVisitor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SettingsModelString类代码示例发布时间:2022-05-22
下一篇:
Java Formatter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap