简体   繁体   English

我可以从Eclipse调试器中的void方法“强制返回”吗?

[英]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). 在Eclipse中进行调试时,通过执行强制返回(我之前使用非void方法完成)来避免void函数的副作用对我有用。

However, the context menu item is always disabled when I try to return from a void method. 但是,当我尝试从void方法返回时,始终禁用上下文菜单项。 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. 显然,void方法不应返回任何内容,因此我可以理解为什么禁用此菜单项。

Does anyone know of a way to do this, or does some feature of Java prohibit me from doing it? 有没有人知道这样做的方法,还是Java的某些功能禁止我这样做?

是的,您可以这样做,不要使用变量显示中的上下文菜单,而是右键单击代码,您将在上下文菜单中看到“强制返回”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM