{"record":{"id":"cdbf616a4b36cda2","repo":"JetBrains/intellij-community","slug":"unable-to-set-value","errorCode":null,"errorMessage":"Unable to set value","messagePattern":"Unable to set value","errorType":"exception","errorClass":"EvaluateException","httpStatus":null,"severity":"error","filePath":"java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java","lineNumber":273,"sourceCode":"      else {\n        final Long frameId = ReflectionUtil.getField(frame.getClass(), frame, long.class, \"id\");\n        final VirtualMachine vm = frame.virtualMachine();\n        final Method stateMethod = vm.getClass().getDeclaredMethod(\"state\");\n        stateMethod.setAccessible(true);\n\n        Object slotInfoArray = createSlotInfoArraySet(variable.slot(), value);\n\n        Object ps;\n        final Object vmState = stateMethod.invoke(vm);\n        synchronized (vmState) {\n          ps = ourEnqueueMethodSet.invoke(null, vm, frame.thread(), frameId, slotInfoArray);\n        }\n\n        ourWaitForReplyMethodSet.invoke(null, vm, ps);\n      }\n    }\n    catch (Exception e) {\n      throw new EvaluateException(\"Unable to set value\", e);\n    }\n  }\n\n  private static Object createSlotInfoArraySet(int slot, Value value)\n    throws IllegalAccessException, InvocationTargetException, InstantiationException {\n    Object arrayInstance = Array.newInstance(ourSlotInfoClassSet, 1);\n    Array.set(arrayInstance, 0, slotInfoConstructorSet.newInstance(slot, value));\n    return arrayInstance;\n  }\n\n  private static Object createSlotInfoArray(Collection<? extends DecompiledLocalVariable> vars) throws Exception {\n    final Object arrayInstance = Array.newInstance(ourSlotInfoClass, vars.size());\n\n    int idx = 0;\n    for (DecompiledLocalVariable var : vars) {\n      final Object info = slotInfoConstructor.newInstance(var.slot(), (byte)var.signature().charAt(0));\n      Array.set(arrayInstance, idx++, info);\n    }","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/debugger/impl/src/com/intellij/debugger/jdi/LocalVariablesUtil.java#L255-L291","documentation":"Thrown by LocalVariablesUtil when setting a value of a decompiled local variable fails. This path uses reflection to drive the JDI SlotInfo/set protocol for variables with no local-variable table (classes compiled without debug info); any reflective or invocation failure is wrapped in EvaluateException('Unable to set value').","triggerScenarios":"Calling the setValue path for a DecompiledLocalVariable: it reflects into the VM state object, builds a SlotInfo array via createSlotInfoArraySet(variable.slot(), value), invokes the enqueue/WaitForReply JDI internals; ClassNotFoundException/IllegalAccessException/InvocationTargetException from the reflection setup or the reflective call itself is caught by 'catch (Exception e)' and rethrown as EvaluateException.","commonSituations":"Debugging classes compiled without -g (no local variable table) so the debugger decompiles variables; assigning to such a variable in the Variables view or evaluator while the JDI internals reject the value type for the slot; JDI implementation differences across JDK versions breaking the reflective protocol.","solutions":["Recompile the debuggee with debug info (-g or gradle/maven debug flag) so real LocalVariables exist instead of decompiled slots","Ensure the assigned value's type exactly matches the variable's expected type (no implicit conversions in slot assignment)","Update the IDE — reflective JDI internals change between JDK versions and are patched per-JDK"],"exampleFix":"# before\njavac Main.java  # no -g, decompiled slots\n\n# after\njavac -g Main.java","handlingStrategy":"try-catch","validationCode":"// before assigning to a decompiled variable\nif (!(variable instanceof DecompiledLocalVariable)) {\n  frame.setValue(variable, value);\n} else {\n  // ensure value type matches slot type exactly; otherwise wrap/cast first\n}","typeGuard":"boolean isSafeSlotAssignment(DecompiledLocalVariable v, Value value) {\n  return value == null || v.typeName().equals(value.type().name());\n}","tryCatchPattern":"try {\n  LocalVariablesUtil.setValue(frame, variable, value);\n} catch (EvaluateException e) {\n  // 'Unable to set value': report slot/type mismatch, suggest recompiling with -g\n}","preventionTips":["Compile debuggee classes with -g to produce real local variable tables","Match assigned value types exactly for slot-based variables","Keep the IDE updated for JDI-internal compatibility fixes"],"tags":["debugger","jdi","decompiled-variables","reflection"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}