Bug 546107 - Evaluate boolean in lambda expression doesn't work properly
Summary: Evaluate boolean in lambda expression doesn't work properly
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.9   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-04 05:31 EDT by samuele baldan CLA
Modified: 2023-04-01 12:19 EDT (History)
2 users (show)

See Also:


Attachments
Video that describe the situation (953.55 KB, video/mp4)
2019-04-04 05:31 EDT, samuele baldan CLA
no flags Details
here are my settings (244.33 KB, image/jpeg)
2019-04-05 07:47 EDT, samuele baldan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description samuele baldan CLA 2019-04-04 05:31:08 EDT
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]
Comment 1 Sarika Sinha CLA 2019-04-04 06:26:11 EDT
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.
Comment 2 samuele baldan CLA 2019-04-04 07:43:31 EDT
The problem exists only in the lambda blocks, however look the video for a better explanation
Comment 3 Sarika Sinha CLA 2019-04-04 22:52:46 EDT
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);
}
Comment 4 samuele baldan CLA 2019-04-05 03:05:55 EDT
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.
Comment 5 Andrey Loskutov CLA 2019-04-05 03:24:07 EDT
(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.
Comment 6 samuele baldan CLA 2019-04-05 07:35:18 EDT
> 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.
Comment 7 samuele baldan CLA 2019-04-05 07:47:31 EDT
Created attachment 278153 [details]
here are my settings
Comment 8 Eclipse Genie CLA 2021-03-26 11:38:47 EDT
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.
Comment 9 Sarika Sinha CLA 2021-03-26 16:14:35 EDT
Are you still seeing this issue?
Comment 10 Eclipse Genie CLA 2023-04-01 12:19:07 EDT
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.