Community
Participate
Working Groups
Created attachment 278144 [details] Video that describe the situation When i try to evaluate Optional.of(true) in a lambda block, in debug mode, the return is Oprional[false]
I tried in a simple case and it works fine - import java.util.Optional; public class TestOptional { public static void main(String[] args) { Optional<Boolean> s = Optional.of(true); System.out.println(s.get()); } } By the way, System.out.println(s.get()); fetches the value from VM and it is not Java evaluation engine which gets to calculate the value.
The problem exists only in the lambda blocks, however look the video for a better explanation
Inside Lambda also works fine with me - public class TestOptional { public static void main(String[] args) { Optional<Boolean> s = Optional.of(true); System.out.println(s.get()); I lam = (Integer x, Integer z) -> { System.out.println(x); Optional<Boolean> s1 = Optional.of(true); System.out.println(s1.get()); }; lam.apply(20,30); } } interface I { public void apply(Integer k, Integer z); }
I do not know, the strange thing is that when I try with other workspace everything seems to work perfectly fine. The problem exists only in certain cases, I do not understand the discriminant. Even when I call the same methods with the same parameters, sometimes it works fine and sometimes it doesn't. Usually the problem occurs only with lambda.
(In reply to samuele baldan from comment #4) > I do not know, the strange thing is that when I try with other workspace > everything seems to work perfectly fine. Try to compare default JRE / default compiler compliance setting in both workspaces. I guess they are different.
> Try to compare default JRE / default compiler compliance setting in both > workspaces. I guess they are different. The settings seem to be the same for both workspaces, I also tried to check in different PCs and seem to be the same.
Created attachment 278153 [details] here are my settings
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Are you still seeing this issue?