This method does a similar job to JSE 6.0's Arrays.copyOf() method and overloads the method for use with arrays of boolean
@param booleanArray The array to copy
@return A copy of the input, of component type U
358872
public static boolean[] copyOf(boolean[] booleanArray) {

    	boolean[] copy = new boolean[booleanArray.length];
        System.arraycopy(booleanArray, 0, copy, 0, booleanArray.length);
        return copy;
    }
622199
static boolean[] compactArray(boolean[] array, int index, int length)
    {
        if (index == 0 && length == array.length) {
            return array;
        }
        return Arrays.copyOfRange(array, index, index + length);
    }
1272528
public static String encodeByteArray(byte[] byteArray) {
		try {
			return new String(Base64.encodeBase64(byteArray), UTF8_ENCODING);
		} catch(UnsupportedEncodingException e) {
			throw new MappingException("Could not encode byteArray to UTF8 encoding", e);
		}
	}
758544
public static <E extends List<Boolean>> E asList(boolean[] array, Class<E> listType) {
		E result;
		try {
			result = listType.newInstance();

			for (Object item : array) {
				result.add((boolean) item);
			}

			return result;
		} catch (InstantiationException | IllegalAccessException e) {
			e.printStackTrace();
			throw (new KriptonRuntimeException(e.getMessage()));
		}
	}
307293
public Object[] copyOf(Object[] a) {
        Object[] b = new Object[a.length];
        System.arraycopy(a, 0, b, 0, a.length);
        return b;
    }
622329
@Override
    public void set(int index, boolean value) {
        int i = Arrays.binarySearch(trueBits, index);
        // bit at index is set to true and shall be set to false
        if (i >= 0 && !value) {
            int[] tmp = new int[trueBits.length - 1];
            System.arraycopy(trueBits, 0, tmp, 0, i);
            System.arraycopy(trueBits, i + 1, tmp, i, trueBits.length - i - 1);
            trueBits = tmp;
        }
        // bit at index is set to false and shall be set to true
        else if (i < 0 && value) {
            int[] tmp = new int[trueBits.length + 1];
            System.arraycopy(trueBits, 0, tmp, 0, trueBits.length);
            tmp[tmp.length - 1] = index;
            trueBits = tmp;
            Arrays.sort(trueBits);
        }
    }
33307
public static Value boolArray(@Nullable boolean[] v) {
    return boolArray(v, 0, v == null ? 0 : v.length);
  }
367225
public static boolean zArrayGet(boolean[] a, int i) {
        try {
            return a[i];
        } catch (Throwable t) {
            return a[DefaultGroovyMethodsSupport.normaliseIndex(i,a.length)];
        }
    }
126997
public static ByteBuf copiedBuffer(byte[]... arrays) {
        switch (arrays.length) {
        case 0:
            return EMPTY_BUFFER;
        case 1:
            if (arrays[0].length == 0) {
                return EMPTY_BUFFER;
            } else {
                return copiedBuffer(arrays[0]);
            }
        }

        // Merge the specified arrays into one array.
        int length = 0;
        for (byte[] a: arrays) {
            if (Integer.MAX_VALUE - length < a.length) {
                throw new IllegalArgumentException(
                        "The total length of the specified arrays is too big.");
            }
            length += a.length;
        }

        if (length == 0) {
            return EMPTY_BUFFER;
        }

        byte[] mergedArray = PlatformDependent.allocateUninitializedArray(length);
        for (int i = 0, j = 0; i < arrays.length; i ++) {
            byte[] a = arrays[i];
            System.arraycopy(a, 0, mergedArray, j, a.length);
            j += a.length;
        }

        return wrappedBuffer(mergedArray);
    }
531810
public static int[] binaryToRgb(boolean[] binaryArray) {
        int[] rgbArray = new int[binaryArray.length];

        for (int i = 0; i < binaryArray.length; i++) {
            if (binaryArray[i]) {
                rgbArray[i] = 0x00000000;
            } else {
                rgbArray[i] = 0x00FFFFFF;
            }
        }
        return rgbArray;
    }
741411
public static Boolean[] asBooleanArray(List<Boolean> input) {
		Boolean[] result = new Boolean[input.size()];

		for (int i = 0; i < result.length; i++) {
			result[i] = input.get(i);
		}

		return result;
	}
1180086
public static Byte[] toObject(byte[] array) {
        if (array == null) {
            return null;
        } else if (array.length == 0) {
            return EMPTY_BYTE_OBJECT_ARRAY;
        }
        final Byte[] result = new Byte[array.length];
        for (int i = 0; i < array.length; i++) {
            result[i] = array[i];
        }
        return result;
    }
33156
public static Object[] subarray(Object[] array, int startIndexInclusive, int endIndexExclusive) {
        int newSize = endIndexExclusive - startIndexInclusive;
        Class<?> type = array.getClass().getComponentType();
        if (newSize <= 0) {
            return (Object[]) Array.newInstance(type, 0);
        }
        Object[] subarray = (Object[]) Array.newInstance(type, newSize);
        System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
        return subarray;
    }
984202
public static Array array(Object array) {
        if (array instanceof Object[]) {
            return array((Object[]) array);
        }
        switch (tId(array.getClass())) {
            case I_BOOLEAN:     return array((boolean[]) array);
            case I_BYTE:        return array((byte[]) array);
            case I_CHARACTER:   return array((char[]) array);
            case I_DOUBLE:      return array((double[]) array);
            case I_FLOAT:       return array((float[]) array);
            case I_INTEGER:     return array((int[]) array);
            case I_LONG:        return array((long[]) array);
            case I_SHORT:       return array((short[]) array);
        }
        throw new IllegalArgumentException("No array: " + array);
    }
1326498
@Override
    public boolean[] read(ScanBuffer buffer) {
        int length = getLength(buffer);
        if (length<0) return null;
        boolean[] result = new boolean[length];
        int b = 0;
        for (int i = 0; i < length; i++) {
            int offset = i%8;
            if (offset==0) {
                b= 0xFF & buffer.getByte();
            }
            result[i]=BooleanSerializer.decode((byte)((b>>>(7-offset))&1));
        }
        return result;
    }
302442
public static boolean[] unWrap(Boolean... values) {
		if (null == values) {
			return null;
		}
		final int length = values.length;
		if (0 == length) {
			return new boolean[0];
		}

		final boolean[] array = new boolean[length];
		for (int i = 0; i < length; i++) {
			array[i] = values[i].booleanValue();
		}
		return array;
	}
1022196
public static boolean[] asBooleanArray(Collection collection) {
        boolean[] result = new boolean[collection.size()];
        int i = 0;
        for (Object c : collection) {
            result[i++] = asBoolean(c);
        }
        return result;
    }