Unclear wording in docs for recursion for List, Map and LazyConstant

XMLWordPrintable

    • Type: CSR
    • Resolution: Unresolved
    • Priority: P3
    • 27
    • Component/s: core-libs
    • None
    • source
    • minimal
    • It is very unlikely that clients would rely on recursive detection on the computing function if invoked directly and not via its lazy construct.
    • Java API
    • SE

      Summary

      While testing, the tester discovered that the documentation around how recursion on the computing function is handled by lazy constructs was ambiguous.

      Problem

      The docs could be construded that detection of recursion were made both by directly calling the computing function and indirectly via its lazy constructs. However, only recursive calls via the lazy constructs are checked for recursive invocation.

      Solution

      This is proposed to be fixed by clarifying the documentation so it coincides with the implementation and the intended way of functioning.

      Specification

      diff --git a/src/java.base/share/classes/java/lang/LazyConstant.java b/src/java.base/share/classes/java/lang/LazyConstant.java
      index 703d67b8abf..b2719ce9421 100644
      --- a/src/java.base/share/classes/java/lang/LazyConstant.java
      +++ b/src/java.base/share/classes/java/lang/LazyConstant.java
      @@ -87,9 +87,8 @@
        * is thrown. Hence, a lazy constant can never hold a {@code null} value. Clients who
        * want to use a nullable constant can wrap the value into an {@linkplain Optional} holder.
        * <p>
      - * If the computing function recursively invokes itself (directly or indirectly via
      - * the lazy constant), an {@linkplain IllegalStateException} is thrown, and the lazy
      - * constant is not initialized.
      + * If the computing function recursively invokes itself via the lazy constant, an
      + * {@linkplain IllegalStateException} is thrown, and the lazy constant is not initialized.
        *
        * <h2 id="composition">Composing lazy constants</h2>
        * A lazy constant can depend on other lazy constants, forming a dependency graph
      diff --git a/src/java.base/share/classes/java/util/List.java b/src/java.base/share/classes/java/util/List.java
      index 43408de292a..7401157a8d3 100644
      --- a/src/java.base/share/classes/java/util/List.java
      +++ b/src/java.base/share/classes/java/util/List.java
      @@ -1224,7 +1224,7 @@ static <E> List<E> copyOf(Collection<? extends E> coll) {
            * The returned list and its {@link List#subList(int, int) subList()} or
            * {@link List#reversed()} views implement the {@link RandomAccess} interface.
            * <p>
      -     * If the provided computing function recursively calls itself or the returned
      +     * If the provided computing function recursively calls itself via the returned
            * lazy list for the same index, an {@linkplain IllegalStateException}
            * will be thrown.
            * <p>
      diff --git a/src/java.base/share/classes/java/util/Map.java b/src/java.base/share/classes/java/util/Map.java
      index 177f0522b1b..a7fdebe6b54 100644
      --- a/src/java.base/share/classes/java/util/Map.java
      +++ b/src/java.base/share/classes/java/util/Map.java
      @@ -1777,7 +1777,7 @@ static <K, V> Map<K, V> copyOf(Map<? extends K, ? extends V> map) {
            * The values of any {@link Map#values()} or {@link Map#entrySet()} views of
            * the returned map are also lazily computed.
            * <p>
      -     * If the provided computing function recursively calls itself or
      +     * If the provided computing function recursively calls itself via
            * the returned lazy map for the same key, an {@linkplain IllegalStateException}
            * will be thrown.
            * <p>
      

            Assignee:
            Per-Ake Minborg
            Reporter:
            Per-Ake Minborg
            Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: