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

Debugger doesn't show variables *outside* lambda

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8u11
    • tools
    • b59
    • x86_64
    • linux_ubuntu
    • Verified

        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.

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

                Created:
                Updated:
                Resolved: