本文整理汇总了Java中com.sun.jdi.InvalidTypeException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidTypeException类的具体用法?Java InvalidTypeException怎么用?Java InvalidTypeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidTypeException类属于com.sun.jdi包,在下文中一共展示了InvalidTypeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: autoboxArguments
import com.sun.jdi.InvalidTypeException; //导入依赖的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));
}
}
}
示例2: setValue
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
@Override
public void setValue(Value value) {
try {
if (fieldObject != null) {
fieldObject.setValue(field, value);
} else {
((ClassType) field.declaringType()).setValue(field, value);
}
} catch (IllegalArgumentException iaex) {
throw new IllegalStateException(new InvalidExpressionException (iaex));
} catch (InvalidTypeException itex) {
throw new IllegalStateException(new InvalidExpressionException (itex));
} catch (ClassNotLoadedException cnlex) {
throw new IllegalStateException(cnlex);
}
}
示例3: stop
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
public void stop(ObjectReference throwable) throws InvalidTypeException {
validateMirrorOrNull(throwable);
// Verify that the given object is a Throwable instance
List<ReferenceType> list = vm.classesByName("java.lang.Throwable");
ClassTypeImpl throwableClass = (ClassTypeImpl)list.get(0);
if ((throwable == null) ||
!throwableClass.isAssignableFrom(throwable)) {
throw new InvalidTypeException("Not an instance of Throwable");
}
try {
JDWP.ThreadReference.Stop.process(vm, this,
(ObjectReferenceImpl)throwable);
} catch (JDWPException exc) {
throw exc.toJDIException();
}
}
示例4: checkedCharValue
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
char checkedCharValue() throws InvalidTypeException {
if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
throw new InvalidTypeException("Can't convert " + value + " to char");
} else {
return super.checkedCharValue();
}
}
示例5: writeUntaggedValueChecked
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
void writeUntaggedValueChecked(Value val) throws InvalidTypeException {
byte tag = ValueImpl.typeValueKey(val);
if (isObjectTag(tag)) {
if (val == null) {
writeObjectRef(0);
} else {
if (!(val instanceof ObjectReference)) {
throw new InvalidTypeException();
}
writeObjectRef(((ObjectReferenceImpl)val).ref());
}
} else {
switch (tag) {
case JDWP.Tag.BYTE:
if(!(val instanceof ByteValue))
throw new InvalidTypeException();
writeByte(((PrimitiveValue)val).byteValue());
break;
case JDWP.Tag.CHAR:
if(!(val instanceof CharValue))
throw new InvalidTypeException();
writeChar(((PrimitiveValue)val).charValue());
break;
case JDWP.Tag.FLOAT:
if(!(val instanceof FloatValue))
throw new InvalidTypeException();
writeFloat(((PrimitiveValue)val).floatValue());
break;
case JDWP.Tag.DOUBLE:
if(!(val instanceof DoubleValue))
throw new InvalidTypeException();
writeDouble(((PrimitiveValue)val).doubleValue());
break;
case JDWP.Tag.INT:
if(!(val instanceof IntegerValue))
throw new InvalidTypeException();
writeInt(((PrimitiveValue)val).intValue());
break;
case JDWP.Tag.LONG:
if(!(val instanceof LongValue))
throw new InvalidTypeException();
writeLong(((PrimitiveValue)val).longValue());
break;
case JDWP.Tag.SHORT:
if(!(val instanceof ShortValue))
throw new InvalidTypeException();
writeShort(((PrimitiveValue)val).shortValue());
break;
case JDWP.Tag.BOOLEAN:
if(!(val instanceof BooleanValue))
throw new InvalidTypeException();
writeBoolean(((PrimitiveValue)val).booleanValue());
break;
}
}
}
示例6: validateMethodInvocation
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
void validateMethodInvocation(Method method, int options)
throws InvalidTypeException,
InvocationException {
/*
* Method must be in this object's class, a superclass, or
* implemented interface
*/
ReferenceTypeImpl declType = (ReferenceTypeImpl)method.declaringType();
if (!declType.isAssignableFrom(this)) {
throw new IllegalArgumentException("Invalid method");
}
if (declType instanceof ClassTypeImpl) {
validateClassMethodInvocation(method, options);
} else if (declType instanceof InterfaceTypeImpl) {
validateIfaceMethodInvocation(method, options);
} else {
throw new InvalidTypeException();
}
}
示例7: validateClassMethodInvocation
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
void validateClassMethodInvocation(Method method, int options)
throws InvalidTypeException,
InvocationException {
/*
* Method must be a non-constructor
*/
if (method.isConstructor()) {
throw new IllegalArgumentException("Cannot invoke constructor");
}
/*
* For nonvirtual invokes, method must have a body
*/
if (isNonVirtual(options)) {
if (method.isAbstract()) {
throw new IllegalArgumentException("Abstract method");
}
}
}
示例8: convertForAssignmentTo
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
ValueImpl convertForAssignmentTo(ValueContainer destination)
throws InvalidTypeException
{
/*
* TO DO: Centralize JNI signature knowledge
*/
if (destination.signature().length() > 1) {
throw new InvalidTypeException("Can't assign primitive value to object");
}
if ((destination.signature().charAt(0) == 'Z') &&
(type().signature().charAt(0) != 'Z')) {
throw new InvalidTypeException("Can't assign non-boolean value to a boolean");
}
if ((destination.signature().charAt(0) != 'Z') &&
(type().signature().charAt(0) == 'Z')) {
throw new InvalidTypeException("Can't assign boolean value to an non-boolean");
}
if ("void".equals(destination.typeName())) {
throw new InvalidTypeException("Can't assign primitive value to a void");
}
try {
PrimitiveTypeImpl primitiveType = (PrimitiveTypeImpl)destination.type();
return (ValueImpl)(primitiveType.convert(this));
} catch (ClassNotLoadedException e) {
throw new InternalException("Signature and type inconsistent for: " +
destination.typeName());
}
}
示例9: prepareForAssignment
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
static ValueImpl prepareForAssignment(Value value,
ValueContainer destination)
throws InvalidTypeException, ClassNotLoadedException {
if (value == null) {
/*
* TO DO: Centralize JNI signature knowledge
*/
if (destination.signature().length() == 1) {
throw new InvalidTypeException("Can't set a primitive type to null");
}
return null; // no further checking or conversion necessary
} else {
return ((ValueImpl)value).prepareForAssignmentTo(destination);
}
}
示例10: validateConstructorInvocation
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
void validateConstructorInvocation(Method method)
throws InvalidTypeException,
InvocationException {
/*
* Method must be in this class.
*/
ReferenceTypeImpl declType = (ReferenceTypeImpl)method.declaringType();
if (!declType.equals(this)) {
throw new IllegalArgumentException("Invalid constructor");
}
/*
* Method must be a constructor
*/
if (!method.isConstructor()) {
throw new IllegalArgumentException("Cannot create instance with non-constructor");
}
}
示例11: handleSetValueForObject
import com.sun.jdi.InvalidTypeException; //导入依赖的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;
}
示例12: setFieldValueWithConflict
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
private Value setFieldValueWithConflict(ObjectReference obj, List<Field> fields, String name, String belongToClass,
String value, Map<String, Object> options) throws ClassNotLoadedException, InvalidTypeException {
Field field;
// first try to resolve field by fully qualified name
List<Field> narrowedFields = fields.stream().filter(TypeComponent::isStatic)
.filter(t -> t.name().equals(name) && t.declaringType().name().equals(belongToClass))
.collect(Collectors.toList());
if (narrowedFields.isEmpty()) {
// second try to resolve field by formatted name
narrowedFields = fields.stream().filter(TypeComponent::isStatic)
.filter(t -> t.name().equals(name)
&& context.getVariableFormatter().typeToString(t.declaringType(), options).equals(belongToClass))
.collect(Collectors.toList());
}
if (narrowedFields.size() == 1) {
field = narrowedFields.get(0);
} else {
throw new UnsupportedOperationException(String.format("SetVariableRequest: Name conflicted for %s.", name));
}
return field.isStatic() ? setStaticFieldValue(field.declaringType(), field, name, value, options)
: this.setObjectFieldValue(obj, field, name, value, options);
}
示例13: doEffect
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
public void doEffect(RVal preVal, RVal postVal) throws InvalidTypeException, ClassNotLoadedException {
if (postVal instanceof ArrayValue) {
ArrayValue postArrVal = ((ArrayValue)postVal);
if (preVal.getValue() instanceof ArrayReference) {
ArrayReference preArrVal = (ArrayReference)preVal.getValue();
if (postArrVal.getValue() instanceof ArrayReference && ((ArrayReference)postArrVal.getValue()).uniqueID() == preArrVal.uniqueID()) {
// If it's the same array just with different values, we can reset the values directly.
postArrVal.resetTo(preArrVal);
return;
}
}
// We must reset the original array's values and reset to it.
postArrVal.resetTo((ArrayReference)postArrVal.getValue());
}
lval.setValue(postVal.getValue());
}
示例14: pauseMedia
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
private static void pauseMedia(ThreadReference tr, VirtualMachine vm) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException {
final ClassType audioClipClass = getClass(vm, tr, "com.sun.media.jfxmedia.AudioClip");
final ClassType mediaManagerClass = getClass(vm, tr, "com.sun.media.jfxmedia.MediaManager");
final InterfaceType mediaPlayerClass = getInterface(vm, tr, "com.sun.media.jfxmedia.MediaPlayer");
final ClassType playerStateEnum = getClass(vm, tr, "com.sun.media.jfxmedia.events.PlayerStateEvent$PlayerState");
if (audioClipClass != null) {
Method stopAllClips = audioClipClass.concreteMethodByName("stopAllClips", "()V");
audioClipClass.invokeMethod(tr, stopAllClips, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
}
if (mediaManagerClass != null && mediaPlayerClass != null && playerStateEnum != null) {
Method getAllPlayers = mediaManagerClass.concreteMethodByName("getAllMediaPlayers", "()Ljava/util/List;");
ObjectReference plList = (ObjectReference)mediaManagerClass.invokeMethod(tr, getAllPlayers, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
if (plList != null) {
ClassType listType = (ClassType)plList.referenceType();
Method iterator = listType.concreteMethodByName("iterator", "()Ljava/util/Iterator;");
ObjectReference plIter = (ObjectReference)plList.invokeMethod(tr, iterator, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
ClassType iterType = (ClassType)plIter.referenceType();
Method hasNext = iterType.concreteMethodByName("hasNext", "()Z");
Method next = iterType.concreteMethodByName("next", "()Ljava/lang/Object;");
Field playingState = playerStateEnum.fieldByName("PLAYING");
Method getState = mediaPlayerClass.methodsByName("getState", "()Lcom/sun/media/jfxmedia/events/PlayerStateEvent$PlayerState;").get(0);
Method pausePlayer = mediaPlayerClass.methodsByName("pause", "()V").get(0);
boolean hasNextFlag = false;
do {
BooleanValue v = (BooleanValue)plIter.invokeMethod(tr, hasNext, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
hasNextFlag = v.booleanValue();
if (hasNextFlag) {
ObjectReference player = (ObjectReference)plIter.invokeMethod(tr, next, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
ObjectReference curState = (ObjectReference)player.invokeMethod(tr, getState, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
if (playingState.equals(curState)) {
player.invokeMethod(tr, pausePlayer, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
pausedPlayers.add(player);
}
}
} while (hasNextFlag);
}
}
}
示例15: resumeMedia
import com.sun.jdi.InvalidTypeException; //导入依赖的package包/类
private static void resumeMedia(ThreadReference tr, VirtualMachine vm) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException {
if (!pausedPlayers.isEmpty()) {
final InterfaceType mediaPlayerClass = getInterface(vm, tr, "com.sun.media.jfxmedia.MediaPlayer");
List<Method> play = mediaPlayerClass.methodsByName("play", "()V");
if (play.isEmpty()) {
return;
}
Method p = play.iterator().next();
for(ObjectReference pR : pausedPlayers) {
pR.invokeMethod(tr, p, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
}
}
}