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

Lambda deduplication fails with non-metafactory BSMs and mismatched local variables names

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 21, 22, 23
    • tools
    • None
    • b23

      The following tests are added in DeduplicationTest demonstrate the problem:

              // generates typeSwitch
              group((Function<Object, Integer>) x -> switch (x) { case String s -> s.length(); default -> -1; },
                    (Function<Object, Integer>) x -> switch (x) { case String s -> s.length(); default -> -1; });

              // local variable names are erroneously significant
              group((Function<Object, Integer>) x -> {
                          int y1 = -1;
                          return y1;
                      },
                    (Function<Object, Integer>) x -> {
                          int y2 = -1;
                          return y2;
                     });

              // consequently, instanceof that generates names with "tmp" + variableIndex++ + "$" demonstrate the problem again
              group((Function<Object, Integer>) x -> x instanceof int i2 ? i2 : -1,
                        (Function<Object, Integer>) x -> x instanceof int i2 ? i2 : -1);

            abimpoudis Angelos Bimpoudis
            abimpoudis Angelos Bimpoudis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: