Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse breakpoint in single / one line lambda?

How can I set a breakpoint in a single line lambda?

e.g. I'd like the (eclipse) debugger to halt, when outer.doSth(event) is called:

observable.addCallback(event-> outer.doSth(event));
like image 891
Stefan K. Avatar asked Jan 19 '16 11:01

Stefan K.


People also ask

What is single method lambda expression?

A lambda expression is a short block of code which takes in parameters and returns a value. Lambda expressions are similar to methods, but they do not need a name and they can be implemented right in the body of a method.

How many methods can be implemented by a single lambda expression?

Lambda expressions can only implement functional interfaces, interface that has only one abstract method. Similarly, lambda expression essentially provides the body for the abstract method within the functional interface.

Can we debug lambda expression?

We can use different IDE's like Netbeans, IntelliJ, and Eclipse to debug the lambda expressions in Java. It is always possible to create multi-line lambda expressions and use print statements to display the values of a variable. The debugger can also provide additional information about the state of a java program.

How do you go to the next line in debug mode?

A solution to this is to place the cursor into the next line and hit Ctrl+R ( Run to Line ) but this is not quite as comfortable as simply hitting a button (like hitting F6 for stepping over the line).


1 Answers

You can't.

If you refactor it like this:

observable.addCallback(event-> {
    return outer.doSth(event);
});

you can.

like image 87
Adam Arold Avatar answered Sep 19 '22 06:09

Adam Arold