@@ -390,25 +390,48 @@ public interface Map<K, V> {
390390 * implemented. The Entry may be independent of any map, or it may represent
391391 * an entry of the entry-set view of a map.
392392 * <p>
393- * Instances of the {@code Map.Entry} interface may be obtained by iterating
394- * the entry-set view of a map. These instances maintain a connection to the
395- * original, backing map. This connection to the backing map is valid
396- * <i>only</i> for the duration of iteration over the entry-set view.
397- * During iteration of the entry-set view, if supported by the backing map,
398- * a change to a {@code Map.Entry}'s value via the
399- * {@link Map.Entry#setValue setValue} method will be visible in the backing map.
400- * The behavior of such a {@code Map.Entry} instance is undefined outside of
401- * iteration of the map's entry-set view. It is also undefined if the backing
402- * map has been modified after the {@code Map.Entry} was returned by the
403- * iterator, except through the {@code Map.Entry.setValue} method. In particular,
393+ * An Entry maintains a connection to its underlying map if the Entry was obtained by
394+ * iterating the {@link Map#entrySet} view of a map, either explicitly by using an
395+ * {@link Iterator} or implicitly via the enhanced {@code for} statement. This connection
396+ * to the backing map is valid <i>only</i> during iteration of the entry-set view. During
397+ * the iteration, if supported by the backing map, a change to an Entry's value via
398+ * the {@link Map.Entry#setValue setValue} method will be visible in the backing map.
399+ * The behavior of such an Entry is undefined outside of iteration of the map's entry-set
400+ * view. It is also undefined if the backing map has been modified after the Entry was
401+ * returned by the iterator, except through the {@code setValue} method. In addition,
404402 * a change to the value of a mapping in the backing map might or might not be
405- * visible in the corresponding {@code Map.Entry} element of the entry-set view.
403+ * visible in the corresponding Entry of the entry-set view.
404+ * <p>
405+ * An Entry may also be obtained from a map's entry-set view by other means, for
406+ * example, using the
407+ * {@link Set#parallelStream parallelStream},
408+ * {@link Set#stream stream},
409+ * {@link Set#spliterator spliterator} methods,
410+ * any of the
411+ * {@link Set#toArray toArray} overloads,
412+ * or by copying the entry-set view into another collection. It is unspecified whether
413+ * the obtained Entry instances are connected to the underlying map, whether changes
414+ * to such an Entry will affect the underlying the map and vice-versa, and whether
415+ * such an Entry supports the optional {@link Map.Entry#setValue setValue} method.
416+ * <p>
417+ * In addition, an Entry may be obtained directly from a map, for example via calls
418+ * to methods directly on the {@link NavigableMap} interface. An entry thus obtained
419+ * is generally not connected to the map and is an unmodifiable snapshot of the mapping
420+ * as of the time of the call. Such an Entry also does not generally support the
421+ * {@code setValue} method.
422+ * <p>
423+ * An Entry obtained by direct construction of the {@link AbstractMap.SimpleEntry}
424+ * or {@link AbstractMap.SimpleImmutableEntry} classes or from a call to the
425+ * {@link Map#entry Map.entry} or {@link Map.Entry#copyOf Map.Entry.copyOf} methods
426+ * is not connected to any map.
406427 *
407428 * @apiNote
408- * It is possible to create a {@code Map.Entry} instance that is disconnected
409- * from a backing map by using the {@link Map.Entry#copyOf copyOf} method. For example,
410- * the following creates a snapshot of a map's entries that is guaranteed not to
411- * change even if the original map is modified:
429+ * The exact behavior of Entry instances obtained from a map's entry-set view other than
430+ * via iteration varies across different map implementations; some are connected to the
431+ * backing map, and some are not. To guarantee that an Entry is disconnected from its
432+ * backing map, use the {@link Map.Entry#copyOf copyOf} method. For example, the following
433+ * creates a snapshot of a map's entries that is guaranteed not to change even if the
434+ * original map is modified:
412435 * <pre> {@code
413436 * var entries = map.entrySet().stream().map(Map.Entry::copyOf).toList()
414437 * }</pre>
@@ -581,7 +604,7 @@ public static <K, V> Comparator<Map.Entry<K, V>> comparingByValue(Comparator<? s
581604 *
582605 * @apiNote
583606 * An instance obtained from a map's entry-set view has a connection to that map.
584- * The {@code copyOf} method may be used to create a {@code Map.Entry} instance,
607+ * The {@code copyOf} method may be used to create a {@code Map.Entry} instance,
585608 * containing the same key and value, that is independent of any map.
586609 *
587610 * @implNote
0 commit comments