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));
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.
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.
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.
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).
You can't.
If you refactor it like this:
observable.addCallback(event-> {
return outer.doSth(event);
});
you can.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With