eclipse-jdt / eclipse-jdt/eclipse.jdt.debug

Cannot evaluate property of record type

Open
#190 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
23
Forks
68
Avg merge
1d 4h
Merged PRs (30d)
13

Description

When using [java-debug](https://github.com/microsoft/java-debug) to debug the following snippet:

```java
record Foo(String bar) {

public int len() {
return bar.length();
}
}

@Test
public void test_foo() throws Exception {
Foo f1 = new Foo("bar");
f1.len();
}
```

Evaluating `bar` when stopped on a breakpoint inside the `len` function fails with an error - saying it can't evaluate the expression. The value is visible in the variables view.

Looking through the java-debug code it creates an `ICompiledExpression` using the `ASTEvaluationEngine`

The `compiledExpression` looks like this:

```
compiledExpression: InstructionSequence@230
fErrors: ArrayList@237 size=0
fException: null
fInstructions: ArrayList@238 size=4
0: PushThis@248 "push 'this'"
1: PushFieldVariable@249 "push field bar"
2: ReturnInstruction@250 "return"
3: NoOp@251 "no op"
fSnippet: "bar"
```

It then calls `engine.evaluateExpression` which returns an evaluateResult like this:

```
evaluateResult: EvaluationResult@270
fEngine: ASTEvaluationEngine@231
fErrors: ArrayList@278 size=0
fException: DebugException@273 "org.eclipse.debug.core.DebugException: Cannot find the field bar for the object dummy.DummyTest$Foo (id=43)"
backtrace: Object[6]@280
cause: DebugException@273 "org.eclipse.debug.core.DebugException: Cannot find the field bar for the object dummy.DummyTest$Foo (id=43)"
depth: 3
detailMessage: "Cannot find the field bar for the object dummy.DummyTest$Foo (id=43)"
stackTrace: StackTraceElement[0]@282
status: Status@283 "Status ERROR: org.eclipse.jdt.debug code=0 Cannot find the field bar for the object dummy.DummyTest$Foo (id=43)"
suppressedExceptions: Collections$EmptyList@284 size=0
fSnippet: "bar"
fTerminated: false
fThread: JdtEvaluationProvider$1@209
fValue: null
```

In my setup I haven't managed to step into `engine.evaluateExpression` so I don't know where exactly things go wrong, but from what I can tell the code in java-debug appeared alright so I thought this would be the right place to report the issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.