private static void setValueToVar(Variable var, Value value) { synchronized (mirrors) { mirrors.remove(var); } try { Method setValueMethod = var.getClass().getDeclaredMethod("setValue", Value.class); setValueMethod.setAccessible(true); setValueMethod.invoke(var, value); ValuePropertyEditor pe = VariablesPropertyEditorsModel.getExistingValuePropertyEditor(var); if (pe != null) { pe.setValue(var); } } catch (Exception ex) { Exceptions.printStackTrace(ex); } }
@Test public void testToString() throws Exception { Value i = this.getLocalValue("i"); assertEquals("NumericFormatter should be able to format int correctly.", "111", formatter.toString(i, new HashMap<>())); VirtualMachine vm = getVM(); assertEquals("NumericFormatter should be able to format double correctly.", "111.000000", formatter.toString(vm.mirrorOf(111.0), new HashMap<>())); assertEquals("NumericFormatter should be able to format float correctly.", "111.000000", formatter.toString(vm.mirrorOf(111.0f), new HashMap<>())); Map<String, Object> options = formatter.getDefaultOptions(); options.put(NUMERIC_PRECISION_OPTION, 1); assertEquals("NumericFormatter should be able to format double correctly.", "111.0", formatter.toString(vm.mirrorOf(111.0), options)); assertEquals("NumericFormatter should be able to format float correctly.", "111.0", formatter.toString(vm.mirrorOf(111.0f), options)); options.put(NUMERIC_PRECISION_OPTION, -1); assertEquals("NumericFormatter should be able to format double correctly.", "111.000000", formatter.toString(vm.mirrorOf(111.0), options)); }
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); } }
public AbstractVariable ( JPDADebuggerImpl debugger, Value value, String id ) { this.debugger = debugger; this.value = value; this.id = id; if (this.id == null) { this.id = Integer.toString(super.hashCode()); } }
@Test public void testToString() throws Exception { Value string = this.getLocalValue("str"); Map<String, Object> options = formatter.getDefaultOptions(); options.put(MAX_STRING_LENGTH_OPTION, 4); assertEquals("Should be able to format string type.", String.format("\"s...\" (id=%d)", ((ObjectReference) string).uniqueID()), formatter.toString(string, options)); options.put(MAX_STRING_LENGTH_OPTION, 5); assertEquals("Should be able to format string type.", String.format("\"st...\" (id=%d)", ((ObjectReference) string).uniqueID()), formatter.toString(string, options)); assertTrue("Should not trim long string by default", formatter.toString(string, new HashMap<>()).contains(((StringReference) string).value())); }
private static MethodArgument[] checkArgumentCount(MethodArgument[] argumentNames, List<Value> argValues, int size) { if (argumentNames == null || argumentNames.length != size) { argumentNames = new MethodArgument[size]; for (int i = 0; i < argumentNames.length; i++) { Value v = argValues.get(i); String type; if (v != null) { type = v.type().name(); } else { type = Object.class.getName(); } argumentNames[i] = new MethodArgument(NbBundle.getMessage(CallStackFrameImpl.class, "CTL_MethodArgument", (i+1)), type, null, null); } } return argumentNames; }
/** Creates a new instance of ReturnVariableImpl */ public ReturnVariableImpl( JPDADebuggerImpl debugger, Value returnValue, String parentID, String methodName ) { super ( debugger, returnValue, parentID + ".return " + methodName + "=" + getStringValue(returnValue) // To have good equals() ); this.methodName = methodName; }
/** Creates a new instance of ExceptionVariableImpl */ public ExceptionVariableImpl( JPDADebuggerImpl debugger, Value exceptionValue, String parentID, String exceptionClassName ) { super ( debugger, exceptionValue, parentID + ".throw " + exceptionClassName + "=" + ReturnVariableImpl.getStringValue(exceptionValue) // To have good equals() ); this.exceptionClassName = exceptionClassName; }
/** * Returns string representation of type of this variable. * * @return string representation of type of this variable. */ @Override public int getFieldsCount () { Value v = getInnerValue (); if (v == null) { return 0; } if (v instanceof ArrayReference) { return ArrayReferenceWrapper.length0((ArrayReference) v); } else { synchronized (fieldsLock) { if (fields == null || refreshFields) { initFields (); } return fields.length; } } }
/** * Get the string representations for an object. * * @param obj the value object * @param options extra information for printing * @return the string representations. */ @Override public String toString(Object obj, Map<String, Object> options) { Value value = (Value) obj; char signature0 = value.type().signature().charAt(0); if (signature0 == LONG || signature0 == INT || signature0 == SHORT || signature0 == BYTE) { return formatNumber(Long.parseLong(value.toString()), options); } else if (hasFraction(signature0)) { return formatFloatDouble(Double.parseDouble(value.toString()), options); } throw new UnsupportedOperationException(String.format("%s is not a numeric type.", value.type().name())); }
@Test public void testToString() throws Exception { Map<String, Object> options = formatter.getDefaultOptions(); Value charVar = getVM().mirrorOf('c'); assertEquals("Should be able to format char type.", "c", formatter.toString(charVar, options)); charVar = getVM().mirrorOf('C'); assertEquals("Should be able to format char type.", "C", formatter.toString(charVar, options)); charVar = getVM().mirrorOf('?'); assertEquals("Should be able to format char type.", "?", formatter.toString(charVar, options)); charVar = getVM().mirrorOf('中'); assertEquals("Should be able to format char type.", "中", formatter.toString(charVar, options)); }
private String getMessageFromField() throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, ClassNotPreparedExceptionWrapper { List<ReferenceType> throwableClasses = VirtualMachineWrapper.classesByName(exeption.virtualMachine(), Throwable.class.getName()); if (throwableClasses.isEmpty()) { return null; } Field detailMessageField = ReferenceTypeWrapper.fieldByName(throwableClasses.get(0), "detailMessage"); if (detailMessageField != null) { Value messageValue = ObjectReferenceWrapper.getValue(exeption, detailMessageField); if (messageValue instanceof StringReference) { message = StringReferenceWrapper.value((StringReference) messageValue); if (invocationMessage != null) { return invocationMessage + ": " + message; } else { return message; } } } return null; }
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; }
/** * 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)); } } }
private Value mirrorOf(VirtualMachine vm, Object value) { if (value instanceof Boolean) { return new BooleanVal(vm, ((Boolean)value).booleanValue()); } else if (value instanceof Character) { return new CharVal(vm, ((Character)value).charValue()); } else if (value instanceof Byte) { return new ByteVal(vm, ((Byte)value).byteValue()); } else if (value instanceof Integer) { return new IntVal(vm, ((Integer)value).intValue()); } else if (value instanceof Short) { return new ShortVal(vm, ((Short)value).shortValue()); } else if (value instanceof Long) { return new LongVal(vm, ((Long)value).longValue()); } else if (value instanceof Float) { return new FloatVal(vm, ((Float)value).floatValue()); } else if (value instanceof Double) { return new DoubleVal(vm, ((Double)value).doubleValue()); } else if (value instanceof String) { return vm.mirrorOf((String) value); } return null; }
@Override public Map<Field, Value> getValues(List<? extends Field> list) { List[] listByTypes = new List[types.length]; for (int i = 0; i < types.length; i++) { listByTypes[i] = new ArrayList(); ReferenceType t = types[i]; for (Field field : list) { String name = field.name(); if (field.equals(t.fieldByName(name))) { listByTypes[i].add(field); } } } Map<Field, Value> map = null; Map<Field, Value> singleMap = null; for (int i = 0; i < types.length; i++) { if (!listByTypes[i].isEmpty()) { Map<Field, Value> tmap = types[i].getValues(listByTypes[i]); if (singleMap == null) { singleMap = tmap; } else { if (map == null) { map = new HashMap<Field, Value>(list.size()); map.putAll(singleMap); } map.putAll(tmap); } } } if (map != null) { return map; } else { return singleMap; } }
@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); } }
@Override public boolean equals(Object obj) { if (!(obj instanceof JDIValue)) return false; Value v = ((JDIValue) obj).value; if (value == null) return v == null; if (value instanceof StringReference) { if (!(v instanceof StringReference)) return false; return ((StringReference) value).value().equals(((StringReference) v).value()); } if (value instanceof ArrayReference) { if (!(v instanceof ArrayReference)) return false; ArrayReference a1 = (ArrayReference) value; ArrayReference a2 = (ArrayReference) v; if (!a1.type().equals(a2.type())) return false; if (a1.length() != a2.length()) return false; int n = a1.length(); for (int i = 0; i < n; i++) { if (!new JDIValue(a1.getValue(i)).equals(new JDIValue(a2.getValue(i)))) { return false; } } return true; } return value.equals(v); }
@Test public void testValueOf() throws Exception { Map<String, Object> options = formatter.getDefaultOptions(); Value boolVar = getVM().mirrorOf(true); Value newValue = formatter.valueOf("true", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertTrue("should return boolean type", ((BooleanValue)newValue).value()); assertEquals("Should be able to restore boolean value.", "true", formatter.toString(newValue, options)); newValue = formatter.valueOf("True", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertTrue("should return boolean type", ((BooleanValue)newValue).value()); newValue = formatter.valueOf("false", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertFalse("should return boolean 'false'", ((BooleanValue)newValue).value()); newValue = formatter.valueOf("False", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertFalse("should return boolean 'false'", ((BooleanValue)newValue).value()); newValue = formatter.valueOf("abc", boolVar.type(), options); assertTrue("should return boolean type", newValue instanceof BooleanValue); assertFalse("should return boolean 'false'", ((BooleanValue)newValue).value()); }
@Override protected synchronized void setValue(Value value) throws InvalidExpressionException { if (evaluatedWatch != null) { // need to delegate to evaluatedWatch.setValue(value); try { Method setValueMethod = evaluatedWatch.getClass().getDeclaredMethod("setValue", Value.class); setValueMethod.setAccessible(true); setValueMethod.invoke(evaluatedWatch, value); } catch (Exception ex) { throw new InvalidExpressionException(ex); } } else { throw new InvalidExpressionException("Can not set value while evaluating."); } }
private void ungrabWindowFX(ClassType WindowClass, ObjectReference w, ThreadReference tr) throws Exception { // javafx.stage.Window w // w.focusGrabCounter // while (focusGrabCounter-- > 0) { // w.impl_getPeer().ungrabFocus(); OR: w.impl_peer.ungrabFocus(); // } Field focusGrabCounterField = WindowClass.fieldByName("focusGrabCounter"); if (focusGrabCounterField == null) { logger.info("Unable to release FX X grab, no focusGrabCounter field in "+w); return ; } Value focusGrabCounterValue = w.getValue(focusGrabCounterField); if (!(focusGrabCounterValue instanceof IntegerValue)) { logger.info("Unable to release FX X grab, focusGrabCounter does not have an integer value in "+w); return ; } int focusGrabCounter = ((IntegerValue) focusGrabCounterValue).intValue(); if (logger.isLoggable(Level.FINE)) { logger.fine("Focus grab counter of "+w+" is: "+focusGrabCounter); } while (focusGrabCounter-- > 0) { //Method impl_getPeerMethod = WindowClass.concreteMethodByName("impl_getPeer", ""); Field impl_peerField = WindowClass.fieldByName("impl_peer"); if (impl_peerField == null) { logger.info("Unable to release FX X grab, no impl_peer field in "+w); return ; } ObjectReference impl_peer = (ObjectReference) w.getValue(impl_peerField); if (impl_peer == null) { continue; } InterfaceType TKStageClass = (InterfaceType) w.virtualMachine().classesByName("com.sun.javafx.tk.TKStage").get(0); Method ungrabFocusMethod = TKStageClass.methodsByName("ungrabFocus", "()V").get(0); impl_peer.invokeMethod(tr, ungrabFocusMethod, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED); if (logger.isLoggable(Level.FINE)) { logger.fine("FX Window "+w+" was successfully ungrabbed."); } } }
private static ArrayReference createTargetBytes(VirtualMachine vm, byte[] bytes, ByteValue[] mirrorBytesCache) throws InvalidTypeException, ClassNotLoadedException, InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, UnsupportedOperationExceptionWrapper { ArrayType bytesArrayClass = getArrayClass(vm, "byte[]"); ArrayReference array = null; boolean disabledCollection = false; while (!disabledCollection) { array = ArrayTypeWrapper.newInstance(bytesArrayClass, bytes.length); try { ObjectReferenceWrapper.disableCollection(array); disabledCollection = true; } catch (ObjectCollectedExceptionWrapper ocex) { // Collected too soon, try again... } } List<Value> values = new ArrayList<Value>(bytes.length); for (int i = 0; i < bytes.length; i++) { byte b = bytes[i]; ByteValue mb = mirrorBytesCache[128 + b]; if (mb == null) { mb = VirtualMachineWrapper.mirrorOf(vm, b); mirrorBytesCache[128 + b] = mb; } values.add(mb); } ArrayReferenceWrapper.setValues(array, values); return array; }
/** * Method invocation support. * Shared by ClassType and InterfaceType * @param threadIntf the thread in which to invoke. * @param methodIntf method the {@link Method} to invoke. * @param origArguments the list of {@link Value} arguments bound to the * invoked method. Values from the list are assigned to arguments * in the order they appear in the method signature. * @param options the integer bit flag options. * @return a {@link Value} mirror of the invoked method's return value. * @throws java.lang.IllegalArgumentException if the method is not * a member of this type, if the size of the argument list * does not match the number of declared arguments for the method, or * if the method is not static or is a static initializer. * @throws InvalidTypeException if any argument in the * argument list is not assignable to the corresponding method argument * type. * @throws ClassNotLoadedException if any argument type has not yet been loaded * through the appropriate class loader. * @throws IncompatibleThreadStateException if the specified thread has not * been suspended by an event. * @throws InvocationException if the method invocation resulted in * an exception in the target VM. * @throws InvalidTypeException If the arguments do not meet this requirement -- * Object arguments must be assignment compatible with the argument * type. This implies that the argument type must be * loaded through the enclosing class's class loader. * Primitive arguments must be either assignment compatible with the * argument type or must be convertible to the argument type without loss * of information. See JLS section 5.2 for more information on assignment * compatibility. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { validateMirror(threadIntf); validateMirror(methodIntf); validateMirrorsOrNulls(origArguments); MethodImpl method = (MethodImpl) methodIntf; ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf; validateMethodInvocation(method); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); ValueImpl[] args = arguments.toArray(new ValueImpl[0]); InvocationResult ret; try { PacketStream stream = sendInvokeCommand(thread, method, args, options); ret = waitForReply(stream); } catch (JDWPException exc) { if (exc.errorCode() == JDWP.Error.INVALID_THREAD) { throw new IncompatibleThreadStateException(); } else { throw exc.toJDIException(); } } /* * There is an implict VM-wide suspend at the conclusion * of a normal (non-single-threaded) method invoke */ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) { vm.notifySuspend(); } if (ret.getException() != null) { throw new InvocationException(ret.getException()); } else { return ret.getResult(); } }
public Result evaluate(Expression<JavaExpression> expression, Context context, CompilationInfoHolder ciHolder) throws InvalidExpressionException { JavaExpression expr = expression.getPreprocessedObject(); if (expr == null) { expr = JavaExpression.parse(expression.getExpression(), JavaExpression.LANGUAGE_JAVA_1_5); expression.setPreprocessedObject(expr); } Value v = evaluateIn(expr, context.getCallStackFrame(), context.getStackFrame(), context.getStackDepth(), context.getContextObject(), ciHolder, debugger.methodCallsUnsupportedExc == null, new Runnable() { public void run() { context.notifyMethodToBeInvoked(); } }); return new Result(v); }
public Value evaluateIn (EvaluatorExpression expression, CallStackFrame csf, ObjectVariable var) throws InvalidExpressionException { Variable variable = evaluateGeneric(expression, csf, var); if (variable instanceof JDIVariable) { return ((JDIVariable) variable).getJDIValue(); } else { return null; } }
/** * Used by AbstractVariable. */ public Value invokeMethod ( ObjectReference reference, Method method, Value[] arguments ) throws InvalidExpressionException { return invokeMethod(null, reference, null, method, arguments, 0, null); }
public Value invokeMethod ( ObjectReference reference, Method method, Value[] arguments, int maxLength ) throws InvalidExpressionException { return invokeMethod(null, reference, null, method, arguments, maxLength, null); }
/** * Used by AbstractVariable. */ public Value invokeMethod ( JPDAThreadImpl thread, ObjectReference reference, Method method, Value[] arguments ) throws InvalidExpressionException { return invokeMethod(thread, reference, method, arguments, null); }
/** * Used by JPDAClassTypeImpl. */ public Value invokeMethod ( JPDAThreadImpl thread, ClassType classType, Method method, Value[] arguments ) throws InvalidExpressionException { return invokeMethod(thread, null, classType, method, arguments, 0, null); }
private static Map<Field, Value> getFieldValues(ObjectReference value, ReferenceType type, String... names) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, ClassNotPreparedExceptionWrapper { final int n = names.length; List<Field> fieldsToAskFor = new ArrayList<Field>(n); for (String name : names) { Field field = ReferenceTypeWrapper.fieldByName(type, name); if (field == null) { return null; } fieldsToAskFor.add(field); } Map<Field, Value> fieldValues = ObjectReferenceWrapper.getValues(value, fieldsToAskFor); return fieldValues; }
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()); } }
void writeValue(Value val) { try { writeValueChecked(val); } catch (InvalidTypeException exc) { // should never happen throw new RuntimeException( "Internal error: Invalid Tag/Type pair"); } }
JPDAObjectWatchImpl (JPDADebuggerImpl debugger, Watch watch, Value v) { super ( debugger, v, "" + watch + (v instanceof ObjectReference ? "^" : "") ); this.debugger = debugger; this.watch = watch; }
@SuppressWarnings({ "rawtypes", "unchecked" }) void invoke(String methodName, String methodSig, Value value) throws Exception { List args = new ArrayList(1); args.add(value); invoke(methodName, methodSig, args, value); }
void writeUntaggedValue(Value val) { try { writeUntaggedValueChecked(val); } catch (InvalidTypeException exc) { // should never happen throw new RuntimeException( "Internal error: Invalid Tag/Type pair"); } }
public Value returnValue() { if (!this.vm.canGetMethodReturnValues()) { throw new UnsupportedOperationException( "target does not support return values in MethodExit events"); } return returnVal; }
private void verifyTranslation (Object t, Object o, Object v) { switch (translationID) { case LOCALS_ID: if (t instanceof AbstractVariable) { AbstractVariable local = ((AbstractVariable) t); Value lv = local.getInnerValue(); if (lv == null && v != null || lv != null && !lv.equals(v)) { local.setInnerValue((Value) v); } return ; } default: throw new IllegalStateException(""+o); } }
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); }
/** Creates a new instance of FieldReadVariableImpl */ public FieldReadVariableImpl( JPDADebuggerImpl debugger, Value readValue, String parentID, Field fieldVar ) { super ( debugger, readValue, parentID + "." + fieldVar.getName() + "=" + ReturnVariableImpl.getStringValue(readValue) // To have good equals() ); this.fieldVar = fieldVar; }
static EvaluationContext.VariableInfo getInfo(JPDADebuggerImpl debugger, Value v) { Session s = debugger.getSession(); Evaluator e = s.lookupFirst(s.getCurrentLanguage(), Evaluator.class); if (e == null) { e = s.lookupFirst("Java", Evaluator.class); } if (!(e instanceof JavaEvaluator)) { return null; } return ((JavaEvaluator) e).getValueContainer(v); }