1

In Eclipse's Debugger I can change the value of a plain variable, but now I need to modify a List by removing or adding elements. Also, it can't be an empty list, it must contain specific items.

I right-click on the variable and try 'Change Value', but the following don't work:

new ArrayList<String>(Arrays.asList("333"));

==> ERROR: "Arrays cannot be resolved"

and

list.remove("12345");
list.remove("67890");

==> ERROR: Generated value (Boolean) is not compatible with declared type (java.util.List)

Any other ideas?

enter image description here

gene b.
  • 10,512
  • 21
  • 115
  • 227
  • 2
    Actually, the following fully-qualified `Arrays` value worked: `new ArrayList(java.util.Arrays.asList("333","444"))` – gene b. Oct 19 '20 at 20:07

1 Answers1

2

If you need to enter complex expressions, it's probably easier to use the "Debug Shell" view. Using this, you can simple enter an expression or statement, highlight it, and execute it (or display it). You may have to replace references to classes (like "Arrays") with the fully-qualified class name. You can also enter and execute multiple statements, so if "Arrays.asList()" isn't convenient, just call "add()" multiple times.

David M. Karr
  • 14,317
  • 20
  • 94
  • 199
  • 1
    Thanks, actually looks like even the Change Variable with a fully-qualified value will work, too: `new ArrayList(java.util.Arrays.asList("333","444"))` – gene b. Oct 19 '20 at 20:07
  • 1
    The advantage of using the "Debug Shell" view is that the expression you enter there doesn't go away after you execute it. It's not persistent over restarts, but if you have to execute that expression more than once in your session, it's much more convenient from there. – David M. Karr Oct 19 '20 at 20:41