RFR 8206123 : ArrayDeque created with default constructor can only hold 15 elements
joe darcy
joe.darcy at oracle.com
Thu Jul 5 23:40:00 UTC 2018
Hello,
Note that another approach would be to change the spec to match the
long-standing implementation. That is the the default resolution patch
in situations like this, but in this case I don't think it matters very
much how the matter is resolved.
Cheers,
-Joe
On 6/29/2018 7:21 PM, Ivan Gerasimov wrote:
> Hello!
>
> The spec states that an ArrayDeque created with the default
> constructor should be able to hold 16 elements.
>
> https://docs.oracle.com/javase/10/docs/api/java/util/ArrayDeque.html#%3Cinit%3E()
>
> """
> Constructs an empty array deque with an initial capacity sufficient to
> hold 16 elements.
> """
>
> In the constructor an array of size 16 is created:
> elements = new Object[16];
>
> However, one element must always be null:
> /**
> * The array in which the elements of the deque are stored.
> * All array cells not holding deque elements are always null.
> * The array always has at least one null slot (at tail).
> */
> transient Object[] elements;
>
> which leaves us space for only 15 elements, contrarily to what the
> spec promises.
>
>
> Would you please help review a trivial fix?
>
> BUGURL: https://bugs.openjdk.java.net/browse/JDK-8206123
> WEBREV: http://cr.openjdk.java.net/~igerasim/8206123/00/webrev/
>
> Thanks in advance!
>
More information about the core-libs-dev
mailing list