emul/src/main/java/java/lang/reflect/Array.java
branchArrayReflect
changeset 485 d962d1330e54
parent 484 7ca6bd52b668
child 486 947269b26dc0
     1.1 --- a/emul/src/main/java/java/lang/reflect/Array.java	Fri Jan 18 21:21:35 2013 +0100
     1.2 +++ b/emul/src/main/java/java/lang/reflect/Array.java	Fri Jan 18 21:51:06 2013 +0100
     1.3 @@ -186,8 +186,14 @@
     1.4       * argument is negative, or if it is greater than or equal to the
     1.5       * length of the specified array
     1.6       */
     1.7 -    public static native Object get(Object array, int index)
     1.8 -        throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
     1.9 +    public static Object get(Object array, int index)
    1.10 +    throws IllegalArgumentException, ArrayIndexOutOfBoundsException {
    1.11 +        if (array.getClass().getComponentType().isPrimitive()) {
    1.12 +            throw new IllegalArgumentException();
    1.13 +        } else {
    1.14 +            return ((Object[])array)[index];
    1.15 +        }
    1.16 +    }
    1.17  
    1.18      /**
    1.19       * Returns the value of the indexed component in the specified
    1.20 @@ -399,8 +405,15 @@
    1.21       * argument is negative, or if it is greater than or equal to
    1.22       * the length of the specified array
    1.23       */
    1.24 -    public static native void set(Object array, int index, Object value)
    1.25 -        throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
    1.26 +    public static void set(Object array, int index, Object value)
    1.27 +    throws IllegalArgumentException, ArrayIndexOutOfBoundsException {
    1.28 +        if (array.getClass().getComponentType().isPrimitive()) {
    1.29 +            throw new IllegalArgumentException();
    1.30 +        } else {
    1.31 +            Object[] arr = (Object[])array;
    1.32 +            arr[index] = value;
    1.33 +        }
    1.34 +    }
    1.35  
    1.36      /**
    1.37       * Sets the value of the indexed component of the specified array