Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-3580

Expression Lambdas cannot be debugged

    XMLWordPrintableJSON

Details

    Description

      Consider this source code:

      package org.netbeans.modules.learning.lambda.code.completion;

      import java.util.Arrays;

      public class NewClass {

          public static void main(String... args) {
              Arrays.stream(new String[] {"a", "", "b"})
                    .filter(s -> !s.isEmpty()) //breakpoint here
                    .forEach(System.err::println);
      {

      {    }

      }}
      }

       

      Add a breakpoint at the marked line, and run the code under the debugger. The debugger will stop on the breakpoint for the "filter" method invocation (OK), but it will not stop there for the lambda invocation (bad). So with a code like this, one does not see the lambda parameters, cannot step inside, etc. Workaround is to place the expression on a new line:

      {{ .filter(s -> }}
      {{ !s.isEmpty()) //breakpoint here}}

      But that requires a change to the code just for debugging - and that defies the purpose of debugging (which is to inspect the code without changes).

      The IDE is a fully updated Apache NetBeans 11.2, with nb-javac installed running on JDK 13:
      Product Version: Apache NetBeans IDE 11.2
      Java: 13.0.1; OpenJDK 64-Bit Server VM 13.0.1+9
      Runtime: OpenJDK Runtime Environment 13.0.1+9
      System: Linux version 4.15.0-72-generic running on amd64; UTF-8; en_US (nb)
      User directory: /tmp/nbuser.lambda.test
      Cache directory: /tmp/nbuser.lambda.test/var/cache

      Attachments

        Issue Links

          Activity

            People

              singh-akhilesh Akhilesh Singh
              jlahoda Jan Lahoda
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h