Open nathan-gt opened 1 year ago
How is declared your array ?
is it double myArray[][]
, or double[][] myArray
?
From my tests, the debugger works better with double myArray[][]
, but give error Cannot evaluate because of compilation error(s): The type of the expression must be an array type but it resolved to double.
with the other.
Could anyone provide some snippet to reproduce the problem?
Surprisingly, it was little hard to produce a minimal exemple: Using instance variable for array_ok
and array_nok
seems to be mandatory.
public class Test {
private double[][] array_nok;
private double array_ok[][];
public Test(){
array_nok = new double[][]{{0.,0.},{0.,0.}};
array_ok = new double[][]{{0.,0.},{0.,0.}};
}
public void run() {
System.out.printf("array_nok[0][0]: %f\n", array_nok[0][0]);
System.out.printf("array_ok[0][0]: %f\n", array_ok[0][0]);
System.out.println("breakpoint here");
}
public static void main (String[] args) {
Test test = new Test();
test.run();
}
}
So, after setting a breakpoint on the line System.out.println("breakpoint here");
, and using the debug console:
> array_nok[0].length
Cannot evaluate because of compilation error(s): length cannot be resolved or is not a field.
> array_nok[0][0]
Cannot evaluate because of compilation error(s): The type of the expression must be an array type but it resolved to double.
It works as expected with array_ok
.
Test environment:
java --version
openjdk 17.0.10 2024-01-16
OpenJDK Runtime Environment Temurin-17.0.10+7 (build 17.0.10+7)
OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (build 17.0.10+7, mixed mode, sharing)
and
Debugger for Java v0.55.0 & pre-release v0.55.2023121302
@oarcher thanks for the sample code. I can reproduce it as well. Defining the 2d array as a local variable works, but does not work when accessing it as a field member.
If you try to watch the value of a 2 dimensional array it will give you "the type of the expression must be an array type but it resolved to int"
Environment
Steps To Reproduce
Current Result
Unable to access via watch the value of a 2d array when debugging.
Expected Result
Being able to do that