Bug 541799 - While in lambda expression, "this" in variable's view cannot be expanded.
Summary: While in lambda expression, "this" in variable's view cannot be expanded.
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.10   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-03 00:37 EST by Vikas Chandra CLA
Modified: 2022-12-23 10:26 EST (History)
2 users (show)

See Also:


Attachments
problem (417.50 KB, image/jpeg)
2018-12-03 00:37 EST, Vikas Chandra CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vikas Chandra CLA 2018-12-03 00:37:52 EST
Created attachment 276789 [details]
problem

Please see the self-explanatory image attached
Comment 1 Andrey Loskutov CLA 2018-12-03 01:13:06 EST
On which line is the debugger stopped?
Comment 2 Vikas Chandra CLA 2018-12-03 01:56:49 EST
		});
		CompletableFuture.runAsync(() -> {
			try {
				Parser.getDefault().parse(fDocument);
			} catch (XMLStreamException e) {
				Annotation error = prepareAnnotation(e);
				Position position = preparePosition(e);
				model.addAnnotation(error, position);


On line -> Parser.getDefault().parse(fDocument);

Rest of the information may be available from the image.
Comment 3 Sarika Sinha CLA 2018-12-03 03:42:56 EST
It's not happening in the normal case, I tried lambda within lambda also and this expands well. So something specific to that class. 
package xyz;

import java.util.function.Function;

public class Main {

	private int instanceField = 952;

	static public void main(String[] args) throws Exception {
		new Main().callLambda("hello");
	}

	void callLambda(String outerArg) throws Exception {
		double outerLocal = Math.random(); // Effectively final

		Function<String, Integer> lambda = lambdaArg -> {
			int lambdaLocal = 6;
			System.out.println(instanceField); // bp1
			System.out.println(outerArg);
			System.out.println(outerLocal);
			System.out.println(lambdaArg);
			System.out.println(lambdaLocal);
			Function<String, Integer> lambda1 = lambdaArg1 -> {
				System.out.println(instanceField); // bp1
				System.out.println(outerArg);
				System.out.println(outerLocal);
				System.out.println(lambdaArg);
				System.out.println(lambdaLocal);

				return lambdaArg1.length();
			};
			System.out.println(lambda1);
			lambda1.apply("6");
			return lambdaArg.length();
		};
		int result = lambda.apply("degenerate case");
		System.out.println(result);
	}
}

Vikas, 
what are the steps to reproduce it ?
Comment 4 Vikas Chandra CLA 2018-12-03 12:20:39 EST
>>what are the steps to reproduce it ?

You can try debugging the class shown in image attached. Put breakpoint in line mentioned in comment#2.
Comment 5 Sarika Sinha CLA 2018-12-03 22:02:37 EST
(In reply to Vikas Chandra from comment #4)
> >>what are the steps to reproduce it ?
> 
> You can try debugging the class shown in image attached. Put breakpoint in
> line mentioned in comment#2.

Just by launching I will hit this breakpoint ?
Comment 6 Vikas Chandra CLA 2018-12-04 00:19:49 EST
>>Just by launching I will hit this breakpoint ?

Create a target editor file.
Comment 7 Sarika Sinha CLA 2018-12-04 03:07:34 EST
I was bale to reproduce on the SyntaxValidatorListener file. 

I tried reproducing by having my example code inside thread, but this still works.

Still looks to me that it is due to some thread forking and un availability of class details to the debugger.
Comment 8 Andrey Loskutov CLA 2018-12-04 03:16:39 EST
I can't reproduce on I20181128-1800 / 1.8.0_181 / RHEL 7.5. Which exact Eclipse build on which JVM is used?
Comment 9 Sarika Sinha CLA 2018-12-04 03:23:11 EST
I tried on Build id: I20181203-1800, Windows 7, with Java 8 as well as Java 11.

Will try on Linux/Mac - Possibly a Windows issue !!
Comment 10 Sarika Sinha CLA 2018-12-05 01:15:55 EST
Tried in Mac, Was able to reproduce.
The stack frame in Debug view -> the stack before lambda for run method states local variable not available.
Comment 11 Eclipse Genie CLA 2020-11-25 11:49:56 EST Comment hidden (obsolete)
Comment 12 Vikas Chandra CLA 2020-11-26 02:33:13 EST
recreates on Version: 2020-12 (4.18)
Build id: I20201123-1800
Comment 13 Eclipse Genie CLA 2022-12-23 10:26:59 EST
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.