microsoft / microsoft/vscode-java-debug
static variable are not updated in the variable view.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 591
- Forks
- 429
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 19
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the Dog and App examples, then inspect how the Java debugger populates the Variables View's Local section and handles edits made through it. Compare that display with the watch value after changing d2; done means all instances show the current shared static name automatically or after an available refresh action.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, typescript
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100