Community
Participate
Working Groups
Debug into the filter step in the following stream expression long count = Arrays.asList(1, 2, 33).stream() .filter(i -> i > y ? true : false).count(); The i variable can be seen in the variables view, but cannot be inspected or used in a expression under the DebugShell.
This works fine if the filter step was written as a lambda block.
It works if we write the statement like this long count = Arrays.asList(1, 2, 33).stream() .filter(i -> { return i > y ? true : false; }).count(); But not like this long count = Arrays.asList(1, 2, 33).stream() .filter(i -> { return i > y ? true : false;}).count();
Seems like this bug is there are bug561542
Seems like this bug is caused by bug561542. Will do some more testing
Seems the problem is the variable y which is define before the lambda. This is the code i'm using in the unit test to reproduce this bug. import java.util.Arrays; import java.util.function.Predicate; public class Bug561715 { public static void main(String[] args) { String y = "111"; Arrays.asList("111", "222", "aaa").stream().filter(a -> a.equals(y)).count(); } } adding break point at stream expression line and debug into filter lambda will show that you cannot evaluate\inspect the variable a
further looking at the code it seems that the y variable is appearing as a arg$1, it is not properly resolved to variable y or atleast val$y as we normally expect.
I have a fix, i will provide a gerrit.
New Gerrit change created: https://git.eclipse.org/r/160402
I am not able to reproduce this problem. I am able to use y in debug Shell and Conditional breakpoint also. However the hover shows it as "y" and not "arg$y" and this is not fixed after the patch as well. Gerrit change looks logical improvement from previous version and I am fine with it.
@Sarika Can you the my unit test without the fix in your environment?
(In reply to Gayan Perera from comment #10) > @Sarika > Can you the my unit test without the fix in your environment? Yes, tried from Comment#5 in new workspace with Build id: I20200402-2250
@Sarika strange. Because the actual unit test i wrote failed when i ran it as plugin test until i fixed the code on yday i build
(In reply to Gayan Perera from comment #12) > @Sarika strange. Because the actual unit test i wrote failed when i ran it > as plugin test until i fixed the code on yday i build Yes, as a test when I run it fails without the fix and passes wit hthe fix. But in workspace I am not able to reproduce. As I think the lambda is nested in ta norma statement and Conditional BP is able to evaluate it.
Gerrit change https://git.eclipse.org/r/160402 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=c9eaedc73281724564c0d20525490ea18fb68e29
Thanks Gayan!
Build id: I20200404-1800