Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I "Force Return" from a void method in the Eclipse debugger?

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?

like image 666
therin Avatar asked Jul 17 '12 21:07

therin


People also ask

How do I go back in debugger in Eclipse?

Open Debug Configuration -> Debugger -> Enable Reverse Debugging at startup . Than you can press shift+F5 or shift+F6 for step back like F5 or F6 for step forward.

What can the Eclipse debugger do?

Eclipse allows running an application in Debug mode which helps with stepping through each line of code in a program. Eclipse also provides a Debug Perspective which is a set of views grouped together that help inspect code and make the debugging process very effective.

How do you debug a method?

1.4. To debug your application, select a Java file with a main method. Right-click on it and select Debug As Java Application. If you started an application once via the context menu, you can use the created launch configuration again via the Debug button in the Eclipse toolbar.

Can we go back in debugging?

Going to a previously step is not possible in debugging... only option have a new break-point at that point and re-start debugging...


1 Answers

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.

like image 117
Francis Upton IV Avatar answered Oct 14 '22 03:10

Francis Upton IV