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


Java Type类代码示例

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


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


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