Copies from the source array to the destination. @param __src The source array. @param __srcoff The source offset. @param __dest The destination array. @param __destoff The destination offset. @param __copylen The number of elements to copy. @throws ArrayStoreException If the destination array cann
(Object __src, int __srcoff, Object __dest, int __destoff, int __copylen)
| 64 | * @since 2018/09/27 |
| 65 | */ |
| 66 | public static void arraycopy(Object __src, int __srcoff, |
| 67 | Object __dest, int __destoff, int __copylen) |
| 68 | throws ArrayStoreException, IndexOutOfBoundsException, |
| 69 | NullPointerException |
| 70 | { |
| 71 | if (__src == null || __dest == null) |
| 72 | throw new NullPointerException("NARG"); |
| 73 | |
| 74 | // {@squirreljme.error ZZ18 Negative offsets and/or length cannot be |
| 75 | // specified. (The source offset; The destination offset; The copy |
| 76 | // length)} |
| 77 | if (__srcoff < 0 || __destoff < 0 || __copylen < 0) |
| 78 | throw new IndexOutOfBoundsException(String.format("ZZ18 %d %d %d", |
| 79 | __srcoff, __destoff, __copylen)); |
| 80 | |
| 81 | // {@squirreljme.error ZZ19 Copy operation would exceed the bounds of |
| 82 | // the array. (Source offset; Source length; Destination offset; |
| 83 | // Destination length; The copy length)} |
| 84 | int srclen = ObjectAccess.arrayLength(__src), |
| 85 | destlen = ObjectAccess.arrayLength(__dest); |
| 86 | if (__srcoff + __copylen > srclen || |
| 87 | __destoff + __copylen > srclen) |
| 88 | throw new IndexOutOfBoundsException(String.format( |
| 89 | "ZZ19 %d %d %d %d %d", __srcoff, srclen, __destoff, destlen, |
| 90 | __copylen)); |
| 91 | |
| 92 | // {@squirreljme.error ZZ1a The source array type is not compatible |
| 93 | // with destination array. (The source array; The destination array)} |
| 94 | if (!__dest.getClass().isAssignableFrom(__src.getClass())) |
| 95 | throw new ArrayStoreException(String.format( |
| 96 | "ZZ1a %s %s", __src, __dest)); |
| 97 | |
| 98 | // These offsets for the loops are the same |
| 99 | int i = __srcoff, |
| 100 | o = __destoff, |
| 101 | end = __srcoff + __copylen; |
| 102 | |
| 103 | // Copy depending on the type |
| 104 | if (__src instanceof boolean[]) |
| 105 | for (boolean[] s = (boolean[])__src, d = (boolean[])__dest; |
| 106 | i < end; i++, o++) |
| 107 | d[o] = s[i]; |
| 108 | else if (__src instanceof byte[]) |
| 109 | for (byte[] s = (byte[])__src, d = (byte[])__dest; |
| 110 | i < end; i++, o++) |
| 111 | d[o] = s[i]; |
| 112 | else if (__src instanceof short[]) |
| 113 | for (short[] s = (short[])__src, d = (short[])__dest; |
| 114 | i < end; i++, o++) |
| 115 | d[o] = s[i]; |
| 116 | else if (__src instanceof char[]) |
| 117 | for (char[] s = (char[])__src, d = (char[])__dest; |
| 118 | i < end; i++, o++) |
| 119 | d[o] = s[i]; |
| 120 | else if (__src instanceof int[]) |
| 121 | for (int[] s = (int[])__src, d = (int[])__dest; |
| 122 | i < end; i++, o++) |
| 123 | d[o] = s[i]; |
no test coverage detected