vscode-java-debug
vscode-java-debug copied to clipboard
static variable are not updated in the variable view.
The static variables of an instance of a class are not updated in the variable view if another instance is changed.
Environment
- Operating System: Windows 10
- JDK version: JDK 1.8.311
- Visual Studio Code version: 1.78.2
- Java extension version: Language Support for Java(TM) by Red Hat v1.18.0
- Java Debugger extension version: 0.50.0
Steps To Reproduce
- Create a simple class with a static variable as:
public class Dog {
private static String name;
private int age;
public Dog(String name, int age) {
Dog.name = name;
this.age = age;
}
public static String getName() {
return name;
}
public int getAge() {
return age;
}
}
- In the main create 3 instance of class Dog :
public class App {
public static void main(String[] args) throws Exception {
Dog d1 = new Dog("Medor", 3);
Dog d2 = new Dog("Rex", 5);
Dog d3 = new Dog("Fifi", 1);
System.out.println("Dog 1 name : " + d1.getName());
}
}
- Put a break point on the System.out.println
- Run in debug mode and check in the Variables View - Local if all dog have the same name.
- Edit the name of d2
Current Result
Only the name of d2 is changed and no possibility to update the name of the other dog. We can see if we add a watch that the name of the other dog changes correctly but not in the Variable view.
Expected Result
In the Variable view the name of all instance of dog should be updated, automatically or with a refresh button
Additional Informations
Very important for teachers to explains what happen with static variables.