Skip to content

Commit 63d28c7

Browse files
committed
Fix ArrayDeque.clone on andriod-8
`Arrays.copyOf` was introduced in API 9, so the `minSdkVersion` of 8 is not enough. Substituting for `System.arraycopy` makes a bit more sense at this point in time. See koush#2 (comment) for discussion.
1 parent 37fa29a commit 63d28c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

AndroidAsync/src/com/koushikdutta/async/ArrayDeque.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ public ArrayDeque<E> clone() {
798798
try {
799799
@SuppressWarnings("unchecked")
800800
ArrayDeque<E> result = (ArrayDeque<E>) super.clone();
801-
result.elements = Arrays.copyOf(elements, elements.length);
801+
System.arraycopy(elements, 0, result.elements, 0, elements.length);
802802
return result;
803803

804804
} catch (CloneNotSupportedException e) {

0 commit comments

Comments
 (0)