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

JShell : Unnamed variable issue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 23
    • 21, 22
    • tools
    • 21
    • b05
    • generic
    • generic

    Backports

      Description

        JShell stops interpreting the snippet after the function declaration which uses an unnamed variable. This happens on both 21 (preview) & 22.

        ```
        var values = List.of(1, 2, 3);
        Function<Integer, Integer> zero = _ -> 0;
        // The rest is ignored
        var res = values.stream().map(zero).toList();
        ```

        Note that this snippet works properly if we feed JShell with the snippet line by line. This behaviour, i.e. works line by line, but doesn't with multiple lines, looks similar to https://bugs.openjdk.org/browse/JDK-8319532

        Attachments

          Issue Links

            Activity

              People

                jlahoda Jan Lahoda
                ddelabassee David Delabassee
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: