{"record":{"id":"24a2e1f462337761","repo":"JetBrains/intellij-community","slug":"invalid-local-variable-name-0-24a2e1","errorCode":null,"errorMessage":"Invalid local variable name ''{0}''","messagePattern":"Invalid local variable name ''(.+?)''","errorType":"exception","errorClass":"EvaluateException","httpStatus":null,"severity":"warning","filePath":"java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/LocalVariableDescriptorImpl.java","lineNumber":108,"sourceCode":"\n  @Override\n  public String getName() {\n    return myLocalVariable.name();\n  }\n\n  @Override\n  public @Nullable String getDeclaredType() {\n    return myTypeName;\n  }\n\n  @Override\n  public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {\n    PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(myProject);\n    try {\n      return elementFactory.createExpressionFromText(getName(), PositionUtil.getContextElement(context));\n    }\n    catch (IncorrectOperationException e) {\n      throw new EvaluateException(JavaDebuggerBundle.message(\"error.invalid.local.variable.name\", getName()), e);\n    }\n  }\n\n  @Override\n  public XValueModifier getModifier(JavaValue value) {\n    return new JavaValueModifier(value) {\n      @Override\n      protected void setValueImpl(@NotNull XExpression expression, @NotNull XModificationCallback callback) {\n        final LocalVariableProxyImpl local = LocalVariableDescriptorImpl.this.getLocalVariable();\n        if (local != null) {\n          final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();\n          set(expression, callback, debuggerContext, new SetValueRunnable() {\n            @Override\n            public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException,\n                                                                                                 InvalidTypeException,\n                                                                                                 EvaluateException {\n              debuggerContext.getFrameProxy().setValue(local, preprocessValue(evaluationContext, newValue, getLType()));\n              update(debuggerContext);","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/LocalVariableDescriptorImpl.java#L90-L126","documentation":"Thrown by LocalVariableDescriptorImpl.getDescriptorEvaluation when the debugger tries to build a PSI expression from a local variable's name via JavaPsiFacade.getElementFactory().createExpressionFromText(getName(), ...). If the variable's name (as reported by the target VM's variable table) is empty or not a valid Java identifier, the PSI factory throws IncorrectOperationException, which is wrapped into an EvaluateException with this message.","triggerScenarios":"Evaluating the 'this' expression or inspecting/evaluating a local variable in the Variables view whose name is blank, a keyword, or contains characters illegal in a Java identifier; typically happens when the class was compiled without local variable tables, with obfuscated/renamed variables, or by non-standard compilers (Kotlin with odd name mangling, bytecode manipulators).","commonSituations":"Debugging obfuscated code (ProGuard/R8), classes compiled with -g:none so variable names come back empty, or synthetic variables produced by Kotlin/Scala/Groovy compilers. Also seen when the debug info is stale after hot-swap/redefine and names no longer match.","solutions":["Rebuild the target module with full debug info (-g or -g:vars) and restart the debug session","If the code is obfuscated, exclude it from renaming or attach original sources/variable names before debugging","Check that class files on the classpath match the sources you are editing (stale build); rebuild project","As a workaround, evaluate the value by its computed expression or use Watches with an explicit valid expression instead of the broken variable entry"],"exampleFix":"// before: relying on variable-table names from a -g:none build\njavac -g:none Main.java\n// after: compile with local variable tables so the debugger gets valid names\njavac -g Main.java","handlingStrategy":"try-catch","validationCode":"// before asking the debugger to evaluate a variable, check the name is a legal identifier\nboolean valid = name != null && !name.isEmpty() && NameUtil.isValidIdentifier(name);","typeGuard":null,"tryCatchPattern":"try {\n  PsiExpression expr = descriptor.getDescriptorEvaluation(context);\n} catch (EvaluateException e) {\n  // name not representable as Java expression; fall back to raw JDI value display\n  showRawValue(descriptor);\n}","preventionTips":["Compile debugged code with -g (full debug info) so variable names are present and valid","Avoid debugging obfuscated builds; keep a debug-build variant with original names","After HotSwap/redefine, restart the session rather than trusting stale variable tables"],"tags":["intellij-debugger","evaluation","psi","javac","debug-info"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}