On Fri, 24 Mar 2023 22:01:11 GMT, Tagir F. Valeev <tval...@openjdk.org> wrote:
>> Stuart Marks has updated the pull request incrementally with four additional >> commits since the last revision: >> >> - Add missing @throws and @since tags. >> - Convert code samples to snippets. >> - Various editorial changes. >> - Fix up toArray(T[]) on reverse-ordered views. > > src/java.base/share/classes/java/util/ReverseOrderDequeView.java line 167: > >> 165: public <T> T[] toArray(T[] a) { >> 166: // TODO can probably optimize this >> 167: return toArray(i -> (T[]) >> java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), i)); > > Hm... Does it follow the spec when the size of `a` is greater than the size > of this collection? In this case, we should return the supplied array filling > it partially and setting the next element to null. Here, we will always > create a new array, which seems to violate the spec. I've rewritten the `toArray(T[] a)` implementation here and in other places. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/7387#discussion_r1172067817