RFR 15 8242327: List spec should state that unmodifiable lists implement RandomAccess

Stuart Marks stuart.marks at oracle.com
Wed Apr 8 21:01:31 UTC 2020


Hi all,

Please review this small change to the List interface that specifies that 
unmodifiable lists (returned by List.of et al) implement the RandomAccess marker 
interface. In fact, they already do; the intent of this section was to specify 
the user-visible characteristics of such lists, but this particular 
characteristic was accidentally omitted.

https://bugs.openjdk.java.net/browse/JDK-8242327

Patch below. I'll follow up with a CSR request.

Thanks,

s'marks


# HG changeset patch
# User smarks
# Date 1586379408 25200
#      Wed Apr 08 13:56:48 2020 -0700
# Node ID f0b78a923c2b2eadfc79cfec7f65377588f10574
# Parent  46108b5b69d92dd424b73b828454849c397509cb
8242327: List spec should state that unmodifiable lists implement RandomAccess
Reviewed-by: XXX

diff -r 46108b5b69d9 -r f0b78a923c2b src/java.base/share/classes/java/util/List.java
--- a/src/java.base/share/classes/java/util/List.java	Tue Apr 07 16:31:46 2020 -0700
+++ b/src/java.base/share/classes/java/util/List.java	Wed Apr 08 13:56:48 2020 -0700
@@ -104,6 +104,7 @@
   * <li>They are serializable if all elements are serializable.
   * <li>The order of elements in the list is the same as the order of the
   * provided arguments, or of the elements in the provided array.
+ * <li>The lists and their {@link subList subList} views implement the {@link 
RandomAccess} interface.
   * <li>They are <a href="../lang/doc-files/ValueBased.html">value-based</a>.
   * Callers should make no assumptions about the identity of the returned 
instances.
   * Factories are free to create new instances or reuse existing ones. Therefore,



More information about the core-libs-dev mailing list