Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8054220

Debugger doesn't show variables *outside* lambda

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u11
    • Fix Version/s: 9
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b59
    • CPU:
      x86_64
    • OS:
      linux_ubuntu
    • Verification:
      Verified

      Backports

        Description

        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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jlahoda Jan Lahoda
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  11 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: