Improve isNonCapturingLambda checkers

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: 26
    • Component/s: core-libs
    • None

      Originally reported here:
      https://github.com/openjdk/jdk/pull/25673#issuecomment-2951174116

      Various vector code has this checker:
          public static boolean isNonCapturingLambda(Object o) {
              return o.getClass().getDeclaredFields().length == 0;
          }

      This might not be precise, as LMF generates static fields in lambda-s in some cases:
       https://github.com/openjdk/jdk/blob/d7352559195b9e052c3eb24d773c0d6c10dc23ad/src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java#L365-L372

      Looks like it only affects the assertions.

            Assignee:
            Xueming Shen
            Reporter:
            Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: