This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 246528 - Lambda functions can't see outer variables
Summary: Lambda functions can't see outer variables
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Martin Entlicher
Depends on:
Reported: 2014-08-18 20:42 UTC by _ gtzabari
Modified: 2015-08-10 11:35 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

Testcase (2.45 KB, application/octet-stream)
2014-08-18 20:43 UTC, _ gtzabari

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2014-08-18 20:42:48 UTC
Product Version: NetBeans IDE Dev (Build 201408170001)
Java: 1.8.0_11; Java HotSpot(TM) 64-Bit Server VM 25.11-b03
Runtime: Java(TM) SE Runtime Environment 1.8.0_11-b12
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

1. Open the testcase project.
2. Set a breakpoint in lines 6 and 7
3. Start a debugging session.
4. Bug #1: "variable" is defined on line 6 but not on line 7.
5. Bug #2: When line 7 is hit, the Debugging tab contains an erroneous line between Main.lambda$run$0:7 and Main.translateRequest:13 (in my case, it's called 155584260.process)
Comment 1 _ gtzabari 2014-08-18 20:43:58 UTC
Created attachment 148748 [details]
Comment 2 _ gtzabari 2014-08-18 20:45:15 UTC
I consider this a very serious regression, so please test it against the 8.0.1 branch (which I don't have access to).

If the bug is present there, I would urge you to delay the release until it is fixed.
Comment 3 Martin Entlicher 2014-08-19 07:17:44 UTC
I do not think this is a regression, since the same behavior is in 8.0.
Bug #2 - this is not an errorneous line, but it should be "Main$$Lambda$1.242481580.process" It's a stack frame, therefore it should be there. It looks like only this frame contains the value of "variable" under this.arg$1
Comment 4 _ gtzabari 2014-08-19 11:46:09 UTC
Interesting, I thought I saw this working before but I guess not.

Okay, so next question: will a fix make it into 8.0.1? I'm guessing not.
Comment 5 Martin Entlicher 2014-08-19 12:12:30 UTC
Unfortunately not. The 8.0.1 release will be soon and we even do not know how to best fix this.
I've verified that this does not work even with jdb:
main[1] print variable Name unknown: variable
Comment 6 _ gtzabari 2014-08-19 12:29:16 UTC
So it's possible this is actually a JDK bug?
Comment 7 Martin Entlicher 2014-08-19 12:38:47 UTC
We need to analyze it more to see how outer variables are handled in lambdas.
Comment 8 Martin Entlicher 2014-09-11 12:38:30 UTC
Comment 9 Martin Entlicher 2015-04-14 08:32:11 UTC
The JDK bug 8058227 was fixed in JDK 9.
Thus it will be fixed in the next NetBeans version, which will be adapted for JDK 9.
Comment 10 _ gtzabari 2015-04-14 11:23:52 UTC
This was also backported to JDK8 update 60. As such, please consider a fix for an earlier release than JDK9.
Comment 11 _ gtzabari 2015-07-01 17:49:25 UTC
Reopening because this was fixed in JDK8 update 60, yet I still can't debug the variables in that version (using Netbeans dev build 201506240001). I suspect that Netbeans needs to be fixed as well.
Comment 12 _ gtzabari 2015-07-01 17:49:55 UTC
To clarify, I am running JDK8 update 60 build 21 which I downloaded from
Comment 13 Martin Entlicher 2015-07-02 10:00:00 UTC
You need to recompile the code. :-(
Comment 14 Egor Ushakov 2015-08-10 11:34:52 UTC
Have just tried it with:
Product Version: NetBeans IDE Dev (Build 201508100002)
Java: 1.8.0_60-ea; Java HotSpot(TM) 64-Bit Server VM 25.60-b23
Runtime: Java(TM) SE Runtime Environment 1.8.0_60-ea-b25

with jdk 8u60b25 from,
rebuilt everything.
Still no luck, variable is available only on line 6, not 7.
Was the fix really pushed into 8u60?