Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Java Development User Guide
Previous Page Home Next Page

Force Return

Select the Force Return command to return from the current method with the speified value.

You can force an early return from a method (only available when debugging on a Java SE 6 virtual machine). This returns a value from the current stack frame without executing any more instructions in the method and releases any locks obtained by synchronized blocks. A return value is created by selecting an expression and Force Return (Alt+Shift+F). This action is available from the Java editor's context menu, top level Run menu, in the Display View, and in the detail pane of the Variables View.

Forcing an early return from a non-void method requires an expression to be evaluated. For example, if a method was going to return false you could return a value of true by selecting an expression in the Display View and invoking Force Return. In the following example, elementCount is not equal to zero, and would return false (see debug hover showing the value of elementCount).

Force Return Example

From the Display View, we could enter the value we want returned, select it and use the Force Return command to force the method isEmpty() to return with that value (in the following example we will force isEmpty() to return with the value true).

Force Return Action in the Display View

This command applies to:

Related Tasks

Evaluating Expressions

 


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire