During an Eclipse debugger session in the eclipse debugging view, it is possible to change arbitrary primitive variables and even Strings.
I wonder why it does not seem possible to change variable references to objects as well.
E.g. if there is something like
ClassLoader cl = ClassLoader.getCallerClassLoader()
in the code I’d like to be able to bind the variable (“change its value” in a relaxed sense) to
cl = Thread.currentThread().contextClassLoader
during debugging.
Am I wrong (it is possible to do this) and if not, are there any conceptional reasons (so other reasons than “nobody simply has done this yet”)?
It transpires that you can actually do this in a round about way. Code:-
Breakpoint on the syserr line.
Select ‘this’ in the variables view then type into the details area at the bottom the following code:-
foo = new java.util.ArrayList()
Now select the above expression and hit shift+ctrl+i (inspect) and it will execute the code. Lo and behold foo now contains an array list!