From c6f9c23111bd235063680b77f73ed5ceb2dac17c Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Thu, 4 Jun 2026 08:50:52 +0000 Subject: [PATCH] 8385054: Spec: Clarify ofLazy List/Set/Map equals/hashCode/toString Javadoc Reviewed-by: vklang --- src/java.base/share/classes/java/util/List.java | 6 +++++- src/java.base/share/classes/java/util/Map.java | 8 ++++++-- src/java.base/share/classes/java/util/Set.java | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/java.base/share/classes/java/util/List.java b/src/java.base/share/classes/java/util/List.java index a906215f16b..d9befd9c454 100644 --- a/src/java.base/share/classes/java/util/List.java +++ b/src/java.base/share/classes/java/util/List.java @@ -1242,7 +1242,11 @@ public interface List extends SequencedCollection { * {@linkplain Object#hashCode() hashCode()}, and * {@linkplain Object#toString() toString()} methods may trigger initialization of * one or more lazy elements. If initialization fails for at least one element, - * the {@linkplain Object Object methods} may throw {@linkplain NoSuchElementException}. + * the {@linkplain Object#hashCode() hashCode()} and + * {@linkplain Object#toString() toString()} methods throw + * {@linkplain NoSuchElementException}, and the {@linkplain Object#equals(Object)} + * throw {@linkplain NoSuchElementException} if attempting to compare an element that + * could not be computed. *

* The returned lazy list strongly references its computing * function used to compute elements at least as long as there are uninitialized diff --git a/src/java.base/share/classes/java/util/Map.java b/src/java.base/share/classes/java/util/Map.java index f5fb190f7d8..11a64295d2b 100644 --- a/src/java.base/share/classes/java/util/Map.java +++ b/src/java.base/share/classes/java/util/Map.java @@ -1793,8 +1793,12 @@ public interface Map { * {@linkplain Object#equals(Object) equals()}, * {@linkplain Object#hashCode() hashCode()}, and * {@linkplain Object#toString() toString()} methods may trigger initialization of - * one or more lazy values. If initialization fails for at least one value, - * the {@linkplain Object Object methods} may throw {@linkplain NoSuchElementException}. + * one or more lazy values. If initialization fails for at least one value, + * the {@linkplain Object#hashCode() hashCode()} and + * {@linkplain Object#toString() toString()} methods throw + * {@linkplain NoSuchElementException}, and the {@linkplain Object#equals(Object)} + * throw {@linkplain NoSuchElementException} if attempting to compare a value that + * could not be computed. *

* The returned lazy map strongly references its underlying * computing function used to compute values at least as long as there are diff --git a/src/java.base/share/classes/java/util/Set.java b/src/java.base/share/classes/java/util/Set.java index 0c66d4ef53c..3c76c88b12c 100644 --- a/src/java.base/share/classes/java/util/Set.java +++ b/src/java.base/share/classes/java/util/Set.java @@ -788,7 +788,11 @@ public interface Set extends Collection { * {@linkplain Object#hashCode() hashCode()}, and * {@linkplain Object#toString() toString()} methods may trigger initialization of * one or more lazy elements. If initialization fails for at least one element, - * the {@linkplain Object Object methods} may throw {@linkplain NoSuchElementException}. + * the {@linkplain Object#hashCode() hashCode()} and + * {@linkplain Object#toString() toString()} methods throw + * {@linkplain NoSuchElementException}, and the {@linkplain Object#equals(Object)} + * throw {@linkplain NoSuchElementException} if attempting to compare an element that + * could not be computed. *

* The returned lazy set strongly references its underlying * computing function used to compute membership status at least as long as there are