While debugging in Eclipse, it would be useful for me to avoid the side effects of a void function by just doing a force return (which I have done before with a non-void method).
However, the context menu item is always disabled when I try to return from a void method. Specifically, I tried going into the Display pane while debugging, enter a value I’d like to return, right-click and select “Force Return”. Obviously, a void method is not supposed to return anything so I can understand why this menu item is disabled.
Does anyone know of a way to do this, or does some feature of Java prohibit me from doing it?
Yes, you can do this, don’t use the context menu in the Variable display, but right-click in your code and you will see “Force Return” in the context menu.