I just started playing with Java 8 Lambdas and I noticed that I can't debug them in the NetBeans IDE. If I try to attach a breakpoint to the following code I get a variable breakpoint which is definately not what I wanted:
private EventListener myListener (Event event) ->
{
command1;
command2; // Set Breakpoint here
command3;
};
NetBeans attaches the debugger at the "myListener" variable but I can't step into the EventListener itself so I can't see what is happening inside it.
Is there debugging information missing, is this a missing feature in NetBeans or is it not at all possible to debug Lambdas in Java?
It works for me in Eclipse. For example:
I can add breakpoints to individual lines within both
r1
andr2
, and they get hit appropriately, with stepping etc.If I put a breakpoint on just the
run()
calls, I can step into the relevant lambda expression too.So it sounds like all the debug information at least can be available.
EDIT: Apparently the above works in Netbeans too - I suggest you try it to check that you can get that working.
In IntelliJ it also works for me:
I can debug into the return
random.nextInt()
but only when I provide a terminal operation likecount()
.With the following sample code in Netbeans 8 Release:
I can set a breakpoint on
System.out.println("Integer: " + i + " / List: " + l);
and inspect the values (i
,l
) perfectly fine.So I'm inclined to say that it is working.