FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Distributor ID: Ubuntu
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename: trusty
A DESCRIPTION OF THE PROBLEM :
Basically if you're debugging inside a lambda, you can't inspect any variables outside of it. This is happening even if said variables are marked final, and regardless of whether they're being accessed inside the lambda.
The error message is : Cannot find local variable '...' if I try to add such variable to a Watch.
An example:
final int outside = 0;
final Map<Integer, Integer> map = new HashMap<>();
map.put(1, 2);
map.entrySet().stream().forEach(entry -> {
System.out.println(outside); // break here, can't inspect the value of "outside"
return entry.getValue();
}).sum();
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
final int outside = 0;
final Map<Integer, Integer> map = new HashMap<>();
map.put(1, 2);
map.entrySet().stream().forEach(entry -> {
System.out.println(outside); // break here, can't inspect the value of "outside"
return entry.getValue();
}).sum();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I should see a variable outside in a debugger on a line starting with System.out
ACTUAL -
Variable is not available.
REPRODUCIBILITY :
This bug can be reproduced always.