Accepted answer

this feature was added to eclipse version 4.7 m2 under eclipse bug 40912.

to use it:

  • step over the return statement (using "step over" or "step return")
  • now the first line in the variable view will show the result of the return statement, as "[statement xxx] returned: "

see eclipse project oxygen (4.7) m2 - new and noteworthy for details.


tough one. my experience, outside of eclipse, is that if you might need to see the return value, it is best to assign it to a local variable in the function so that the return statement is a simple return varname; and not return(some * expression || other);. however, that's not dreadfully helpful to you since you say you can't (or don't want to) modify or even recompile the code. so, i don't have a good answer for you - perhaps you need to reconsider your requirement.


depending on the return statement, you can highlight the expression that is being returned and from the right-click menu, there should be something like "evaluate expression" (i don't have eclipse in front of me now, but it's something like that). it will show you what is going to be returned.


this is a bit far-fetched, but as there doesn't seem to be a simple way:

you could use aspectj to instrument the jar with aspects that get hold of the return value of the methods you're interested in. according to eclipse's documentation, aspectj programs can be debugged like other programs.

there are two options to weave your classes without recompiling the library :

  • post-compile weaving if processing the binary jar is acceptable;

  • load-time weaving, which requires activating a weaving agent in the vm.

see the eclipse documentation (link above) and also the aspectj development environment guide.


"now when you return from a method, in the upper method, in the variable view it shows the return value of the previously finished call" [1]



i am curious about to learn the answer to this question also.

in the past, when dealing with 3rd party library like that, what i did is to create a wrapper class or child class that delegate to the parent class and do my debugging in the wrapper/child class. it takes extra work though.


this is actually a long standing bug in eclipse, dating back from the very first days of the ide:


that's why i always stick with the following pattern for methods:

myreturnedtype foo() {
     myreturnedtype   result = null;

     // do your stuff, modify the result or not

     return result;

my rules:

  1. only one return statement, only at the end of the method (finally allowed after it)
  2. always have a local called result which holds the returned value, starting from a default.

naturally, the most trivial getters are exempt.


found a really good shortcut for this. select the expression which returns the value and press

ctrl + shift + d

this will display the value of the return statement. this is really helpful in cases where you can't or don't want to change just for debugging purpose.

hope this helps.

note: have not tested this with third party libraries, but it is working fine for my code. tested this on eclipse java ee ide for web developers. version: juno service release 1

Related Query

More Query from same tag