Java 类com.sun.jdi.PrimitiveType 实例源码

项目:incubator-netbeans    文件:EvaluatorVisitor.java   
public static ReferenceType adjustBoxingType(ReferenceType type, PrimitiveType primitiveType,
                                              EvaluationContext evaluationContext) {
    Class typeClass = null;
    if (primitiveType instanceof BooleanType) {
        typeClass = Boolean.class;
    } else
    if (primitiveType instanceof ByteType) {
        typeClass = Byte.class;
    } else
    if (primitiveType instanceof CharType) {
        typeClass = Character.class;
    } else
    if (primitiveType instanceof ShortType) {
        typeClass = Short.class;
    } else
    if (primitiveType instanceof IntegerType) {
        typeClass = Integer.class;
    } else
    if (primitiveType instanceof LongType) {
        typeClass = Long.class;
    } else
    if (primitiveType instanceof FloatType) {
        typeClass = Float.class;
    } else
    if (primitiveType instanceof DoubleType) {
        typeClass = Double.class;
    }
    if (typeClass != null) {
        type = evaluationContext.getVMCache().getClass(typeClass.getName());
    }
    return type;
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
/** @return true if t2 is an extension of t1 */
private static boolean extendsType(PrimitiveType t1, PrimitiveType t2) {
    // BooleanType, ByteType and CharType can be matched together only.
    if (t2 instanceof ShortType) {
        return t2 instanceof ByteType || t2 instanceof ShortType;
    }
    if (t2 instanceof IntegerType) {
        return t2 instanceof ByteType || t2 instanceof ShortType || t2 instanceof IntegerType;
    }
    if (t2 instanceof LongType) {
        return t2 instanceof ByteType || t2 instanceof ShortType ||
               t2 instanceof IntegerType || t2 instanceof LongType;
    }
    if (t2 instanceof FloatType) {
        return !(t2 instanceof BooleanType || t2 instanceof CharType || t2 instanceof DoubleType);
    }
    if (t2 instanceof DoubleType) {
        return !(t2 instanceof BooleanType || t2 instanceof CharType);
    }
    return false;
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
/**
 * 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));
        }
    }
}
项目:openjdk-jdk10    文件:VirtualMachineImpl.java   
PrimitiveType primitiveTypeMirror(byte tag) {
    switch (tag) {
        case JDWP.Tag.BOOLEAN:
            return theBooleanType();
        case JDWP.Tag.BYTE:
            return theByteType();
        case JDWP.Tag.CHAR:
            return theCharType();
        case JDWP.Tag.SHORT:
            return theShortType();
        case JDWP.Tag.INT:
            return theIntegerType();
        case JDWP.Tag.LONG:
            return theLongType();
        case JDWP.Tag.FLOAT:
            return theFloatType();
        case JDWP.Tag.DOUBLE:
            return theDoubleType();
        default:
            throw new IllegalArgumentException("Unrecognized primitive tag " + tag);
    }
}
项目:openjdk-jdk10    文件:ArrayTypeImpl.java   
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);
    }
}
项目:openjdk9    文件:ArrayTypeImpl.java   
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);
    }
}
项目:openjdk9    文件:ArrayTypeImpl.java   
int getModifiers() {
    /*
     * For object arrays, the return values for Interface
     * Accessible.isPrivate(), Accessible.isProtected(),
     * etc... are the same as would be returned for the
     * component type.  Fetch the modifier bits from the
     * component type and use those.
     *
     * For primitive arrays, the modifiers are always
     *   VMModifiers.FINAL | VMModifiers.PUBLIC
     *
     * Reference com.sun.jdi.Accessible.java.
     */
    try {
        Type t = componentType();
        if (t instanceof PrimitiveType) {
            return VMModifiers.FINAL | VMModifiers.PUBLIC;
        } else {
            ReferenceType rt = (ReferenceType)t;
            return rt.modifiers();
        }
    } catch (ClassNotLoadedException cnle) {
        cnle.printStackTrace();
    }
    return -1;
}
项目:jive    文件:EventFactoryAdapter.java   
private IValue resolvePrimitive(final com.sun.jdi.Value value)
{
  if (value == null)
  {
    return valueFactory().createNullValue();
  }
  final com.sun.jdi.Type t = value.type();
  if (t instanceof PrimitiveType)
  {
    if (t instanceof CharType)
    {
      return valueFactory().createPrimitiveValue(escapeStringValue(value.toString()));
    }
    return valueFactory().createPrimitiveValue(value.toString());
  }
  return null;
}
项目:incubator-netbeans    文件:VariableMirrorTranslator.java   
private static void setValueToFinalField(ObjectReference obj, String name, ClassType clazz, Value fv, VirtualMachine vm, ThreadReference thread) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ClassNotPreparedExceptionWrapper, ClassNotLoadedException, ObjectCollectedExceptionWrapper, IncompatibleThreadStateException, UnsupportedOperationExceptionWrapper, InvalidTypeException, InvalidObjectException {
    ObjectReference fieldRef = getDeclaredOrInheritedField(clazz, name, vm, thread);
    if (fieldRef == null) {
        InvalidObjectException ioex = new InvalidObjectException("No field "+name+" of class "+clazz);
        throw ioex;
    }
    // field.setAccessible(true);
    ClassType fieldClassType = (ClassType) ValueWrapper.type(fieldRef);
    com.sun.jdi.Method setAccessibleMethod = ClassTypeWrapper.concreteMethodByName(
            fieldClassType, "setAccessible", "(Z)V");
    try {
        ObjectReferenceWrapper.invokeMethod(fieldRef, thread, setAccessibleMethod,
                                            Collections.singletonList(vm.mirrorOf(true)),
                                            ClassType.INVOKE_SINGLE_THREADED);
        // field.set(newInstance, fv);
        com.sun.jdi.Method setMethod = ClassTypeWrapper.concreteMethodByName(
                fieldClassType, "set", "(Ljava/lang/Object;Ljava/lang/Object;)V");
        if (fv instanceof PrimitiveValue) {
            PrimitiveType pt = (PrimitiveType) ValueWrapper.type(fv);
            ReferenceType fieldBoxingClass = EvaluatorVisitor.adjustBoxingType(clazz, pt, null);
            fv = EvaluatorVisitor.box((PrimitiveValue) fv, fieldBoxingClass, thread, null);
        }
        List<Value> args = Arrays.asList(new Value[] { obj, fv });
        ObjectReferenceWrapper.invokeMethod(fieldRef, thread, setMethod,
                                            args,
                                            ClassType.INVOKE_SINGLE_THREADED);
    } catch (InvocationException iex) {
        throw new InvalidObjectException(
                "Problem setting value "+fv+" to field "+name+" of class "+clazz+
                " : "+iex.exception());
    }
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
private static boolean extendsType(Type argType, Type methodType) {
    if (methodType instanceof ReferenceType && argType instanceof ReferenceType) {
        return extendsType((ReferenceType) argType, (ReferenceType) methodType);
    } else if (methodType instanceof PrimitiveType && argType instanceof PrimitiveType) {
        return extendsType((PrimitiveType) argType, (PrimitiveType) methodType);
    }
    return false;
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
private String toString(Tree arg0, Mirror v, EvaluationContext evaluationContext) {
    if (v instanceof PrimitiveValue) {
        PrimitiveValue pv = (PrimitiveValue) v;
        PrimitiveType t = (PrimitiveType) pv.type();
        if (t instanceof ByteType) {
            return Byte.toString(pv.byteValue());
        }
        if (t instanceof BooleanType) {
            return Boolean.toString(pv.booleanValue());
        }
        if (t instanceof CharType) {
            return Character.toString(pv.charValue());
        }
        if (t instanceof ShortType) {
            return Short.toString(pv.shortValue());
        }
        if (t instanceof IntegerType) {
            return Integer.toString(pv.intValue());
        }
        if (t instanceof LongType) {
            return Long.toString(pv.longValue());
        }
        if (t instanceof FloatType) {
            return Float.toString(pv.floatValue());
        }
        if (t instanceof DoubleType) {
            return Double.toString(pv.doubleValue());
        }
        throw new IllegalStateException("Unknown primitive type: "+t);
    }
    if (v == null) {
        return "" + null;
    }
    ObjectReference ov = (ObjectReference) v;
    if (ov instanceof ArrayReference) {
        return "#" + ov.uniqueID() +
            " " + ov.type().name() +
            "(length=" + ((ArrayReference) ov).length() + ")";
    }
    if (ov instanceof StringReference) {
        return ((StringReference) ov).value();
    }
    // Call toString() method:
    List<? extends TypeMirror> typeArguments = Collections.emptyList();
    Method method;
    try {
        method = getConcreteMethod((ReferenceType) ov.type(), "toString", typeArguments);
    } catch (UnsuitableArgumentsException uaex) {
        throw new IllegalStateException(uaex);
    }
    ((ClassType) ov.type()).methodsByName("toString");
    List<Value> argVals = Collections.emptyList();
    Value sv = invokeMethod(arg0, method, false, null, ov, argVals, evaluationContext, false);
    if (sv instanceof StringReference) {
        return ((StringReference) sv).value();
    } else if (sv == null) {
        return null;
    } else {
        return "Result of toString() call on "+ov+" is not a String, but: "+sv; // NOI18N - should not ever happen.
    }
}
项目:openjdk-jdk10    文件:ArrayTypeImpl.java   
void getModifiers() {
    if (modifiers != -1) {
        return;
    }
    /*
     * For object arrays, the return values for Interface
     * Accessible.isPrivate(), Accessible.isProtected(),
     * etc... are the same as would be returned for the
     * component type.  Fetch the modifier bits from the
     * component type and use those.
     *
     * For primitive arrays, the modifiers are always
     *   VMModifiers.FINAL | VMModifiers.PUBLIC
     *
     * Reference com.sun.jdi.Accessible.java.
     */
    try {
        Type t = componentType();
        if (t instanceof PrimitiveType) {
            modifiers = VMModifiers.FINAL | VMModifiers.PUBLIC;
        } else {
            ReferenceType rt = (ReferenceType)t;
            modifiers = rt.modifiers();
        }
    } catch (ClassNotLoadedException cnle) {
        cnle.printStackTrace();
    }
}
项目:form-follows-function    文件:F3Wrapper.java   
public static F3Type wrap(F3VirtualMachine f3vm, Type type) {
    if (type == null) {
        return null;
    }

    if (type instanceof VoidType) {
        return f3vm.voidType((VoidType)type);
    } else if (type instanceof PrimitiveType) {
        if (type instanceof BooleanType) {
            return f3vm.booleanType((BooleanType)type);
        } else if (type instanceof CharType) {
            return f3vm.charType((CharType)type);
        } else if (type instanceof ByteType) {
            return f3vm.byteType((ByteType)type);
        } else if (type instanceof ShortType) {
            return f3vm.shortType((ShortType)type);
        } else if (type instanceof IntegerType) {
            return f3vm.integerType((IntegerType)type);
        } else if (type instanceof LongType) {
            return f3vm.longType((LongType)type);
        } else if (type instanceof FloatType) {
            return f3vm.floatType((FloatType)type);
        } else if (type instanceof DoubleType) {
            return f3vm.doubleType((DoubleType)type);
        } else {
            throw new IllegalArgumentException("illegal primitive type : " + type);
        }
    } else if (type instanceof ReferenceType) {
        return wrap(f3vm, (ReferenceType)type);
    } else {
        throw new IllegalArgumentException("illegal type: " + type);
    }
}
项目:EclipseTracer    文件:ArrayViewsManager.java   
/**
 * Factory method
 * 
 * @param parent
 *            the parent SWT composite in which the view of this controller
 *            should be created
 * @param history
 *            the actual history
 * @return created {@link AbstractHistoryController}
 */
public AbstractArrayController createArrayController(
        final Composite parent,
        final ArrayExpression exp, final FieldImpl field) {
    final AbstractArrayController newController;
    if (exp.getType(field) instanceof PrimitiveType) {
        switch (mode) {
        case ArraysMainController.MODE_SERIES:
            newController = new NumericArrayController(parent, exp, field, properties);
            break;
        case ArraysMainController.MODE_HISTOGRAM:
            newController = new BarChartArrayController(parent, exp, field, properties);
            break;
        default:
            newController = null;                   
        }
    }
    else {
        newController = new NonNumericArrayController(parent, exp, field, properties);
    }
    if (newController != null) {
        historyControllers.add(newController);          
        newController.getView().getBtnClose().addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {                  
                historyControllers.remove(newController);
                adjustWidth();
            }
        });
    }
    return newController;
}
项目:incubator-netbeans    文件:EvaluatorVisitor.java   
public static Value unbox(ObjectReference val, PrimitiveType type,
                          ThreadReference thread,
                          EvaluationContext context) throws InvalidTypeException,
                                                            ClassNotLoadedException,
                                                            IncompatibleThreadStateException,
                                                            InvocationException {
    ReferenceType rt = val.referenceType();
    String classType = rt.name();
    PrimitiveValue pv;
    if (classType.equals("java.lang.Boolean")) {
        pv = invokeUnboxingMethod(val, "booleanValue", thread, context);
    } else if (classType.equals("java.lang.Byte")) {
        pv = invokeUnboxingMethod(val, "byteValue", thread, context);
    } else if (classType.equals("java.lang.Character")) {
        pv = invokeUnboxingMethod(val, "charValue", thread, context);
    } else if (classType.equals("java.lang.Short")) {
        pv = invokeUnboxingMethod(val, "shortValue", thread, context);
    } else if (classType.equals("java.lang.Integer")) {
        pv = invokeUnboxingMethod(val, "intValue", thread, context);
    } else if (classType.equals("java.lang.Long")) {
        pv = invokeUnboxingMethod(val, "longValue", thread, context);
    } else if (classType.equals("java.lang.Float")) {
        pv = invokeUnboxingMethod(val, "floatValue", thread, context);
    } else if (classType.equals("java.lang.Double")) {
        pv = invokeUnboxingMethod(val, "doubleValue", thread, context);
    //throw new RuntimeException("Invalid type while unboxing: " + type.signature());    // never happens
    } else {
        return val;
    }
    VirtualMachine vm = pv.virtualMachine();
    if (type instanceof BooleanType && !(pv instanceof BooleanValue)) {
        return vm.mirrorOf(pv.booleanValue());
    }
    if (type instanceof ByteType && !(pv instanceof ByteValue)) {
        return vm.mirrorOf(pv.byteValue());
    }
    if (type instanceof CharType && !(pv instanceof CharValue)) {
        return vm.mirrorOf(pv.charValue());
    }
    if (type instanceof ShortType && !(pv instanceof ShortValue)) {
        return vm.mirrorOf(pv.shortValue());
    }
    if (type instanceof IntegerType && !(pv instanceof IntegerValue)) {
        return vm.mirrorOf(pv.intValue());
    }
    if (type instanceof LongType && !(pv instanceof LongValue)) {
        return vm.mirrorOf(pv.longValue());
    }
    if (type instanceof FloatType && !(pv instanceof FloatValue)) {
        return vm.mirrorOf(pv.floatValue());
    }
    if (type instanceof DoubleType && !(pv instanceof DoubleValue)) {
        return vm.mirrorOf(pv.doubleValue());
    }
    return pv;
}
项目:form-follows-function    文件:F3PrimitiveType.java   
public F3PrimitiveType(F3VirtualMachine f3vm, PrimitiveType underlying) {
    super(f3vm, underlying);
}
项目:form-follows-function    文件:F3PrimitiveType.java   
@Override
protected PrimitiveType underlying() {
    return (PrimitiveType) super.underlying();
}
项目:EclipseTracer    文件:Watchpoint.java   
/***
 * 
 * @return true if the {@link Type} returned by {@link #getJavaType()} is a {@link PrimitiveType}
 */
public boolean isPrimitiveType() {
    return getJavaType() instanceof PrimitiveType;
}