Copies the number of length elements of the Array src starting at the offset srcPos into the Array dest at the position destPos. @param src the source array to copy the content. @param srcPos the starting index of the content in {@code s
(Object src, int srcPos, Object dest, int destPos,
int length)
| 37 | * to be copied. |
| 38 | */ |
| 39 | public static void arraycopy(Object src, int srcPos, Object dest, int destPos, |
| 40 | int length) { |
| 41 | // sending getClass() to both arguments will check for null |
| 42 | Class<?> type1 = src.getClass(); |
| 43 | Class<?> type2 = dest.getClass(); |
| 44 | if (!type1.isArray() || !type2.isArray()) { |
| 45 | throw new ArrayStoreException(); |
| 46 | } |
| 47 | Class<?> componentType1 = type1.getComponentType(); |
| 48 | Class<?> componentType2 = type2.getComponentType(); |
| 49 | if (!componentType1.isPrimitive()) { |
| 50 | if (componentType2.isPrimitive()) { |
| 51 | throw new ArrayStoreException(); |
| 52 | } |
| 53 | } else { |
| 54 | if (componentType2 != componentType1) { |
| 55 | throw new ArrayStoreException(); |
| 56 | } |
| 57 | } |
| 58 | arraycopyImpl(src, srcPos, dest, destPos, length); |
| 59 | } |
| 60 | |
| 61 | public static native void arraycopyImpl(Object src, int srcPos, Object dest, int destPos, |
| 62 | int length); |
no test coverage detected