# HG changeset patch # User Jaroslav Tulach # Date 1358543764 -3600 # Node ID 947269b26dc0404c971f1b98cda041ae54daa758 # Parent d962d1330e54f588701763bd614931ce2486b3d8 Array.get can convert basic types diff -r d962d1330e54 -r 947269b26dc0 emul/src/main/java/java/lang/reflect/Array.java --- a/emul/src/main/java/java/lang/reflect/Array.java Fri Jan 18 21:51:06 2013 +0100 +++ b/emul/src/main/java/java/lang/reflect/Array.java Fri Jan 18 22:16:04 2013 +0100 @@ -188,8 +188,9 @@ */ public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { - if (array.getClass().getComponentType().isPrimitive()) { - throw new IllegalArgumentException(); + final Class t = array.getClass().getComponentType(); + if (t.isPrimitive()) { + return Array.fromPrimitive(t, array, index); } else { return ((Object[])array)[index]; } @@ -649,4 +650,10 @@ } return arr; } + private static Object fromPrimitive(Class t, Object array, int index) { + return Method.fromPrimitive(t, atArray(array, index)); + } + + @JavaScriptBody(args = { "array", "index" }, body = "return array[index]") + private static native Object atArray(Object array, int index); } diff -r d962d1330e54 -r 947269b26dc0 emul/src/main/java/java/lang/reflect/Method.java --- a/emul/src/main/java/java/lang/reflect/Method.java Fri Jan 18 21:51:06 2013 +0100 +++ b/emul/src/main/java/java/lang/reflect/Method.java Fri Jan 18 22:16:04 2013 +0100 @@ -537,7 +537,7 @@ ) private static native Object invoke0(boolean isStatic, Method m, Object self, Object[] args); - private static Object fromPrimitive(Class type, Object o) { + static Object fromPrimitive(Class type, Object o) { if (type == Integer.TYPE) { return fromRaw(Integer.class, "valueOf__Ljava_lang_Integer_2I", o); }