diff -r 6ab756741111 -r 3471d74a6b99 rt/emul/mini/src/main/java/java/lang/reflect/Method.java --- a/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Mon Feb 17 16:55:44 2014 +0100 +++ b/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Wed May 07 08:49:54 2014 +0200 @@ -552,28 +552,28 @@ } static Object fromPrimitive(Class type, Object o) { - if (type == Integer.TYPE) { + if (samePrimitive(type, Integer.TYPE)) { return fromRaw(Integer.class, "valueOf__Ljava_lang_Integer_2I", o); } - if (type == Long.TYPE) { + if (samePrimitive(type, Long.TYPE)) { return fromRaw(Long.class, "valueOf__Ljava_lang_Long_2J", o); } - if (type == Double.TYPE) { + if (samePrimitive(type, Double.TYPE)) { return fromRaw(Double.class, "valueOf__Ljava_lang_Double_2D", o); } - if (type == Float.TYPE) { + if (samePrimitive(type, Float.TYPE)) { return fromRaw(Float.class, "valueOf__Ljava_lang_Float_2F", o); } - if (type == Byte.TYPE) { + if (samePrimitive(type, Byte.TYPE)) { return fromRaw(Byte.class, "valueOf__Ljava_lang_Byte_2B", o); } - if (type == Boolean.TYPE) { + if (samePrimitive(type, Boolean.TYPE)) { return fromRaw(Boolean.class, "valueOf__Ljava_lang_Boolean_2Z", o); } - if (type == Short.TYPE) { + if (samePrimitive(type, Short.TYPE)) { return fromRaw(Short.class, "valueOf__Ljava_lang_Short_2S", o); } - if (type == Character.TYPE) { + if (samePrimitive(type, Character.TYPE)) { return fromRaw(Character.class, "valueOf__Ljava_lang_Character_2C", o); } if (type.getName().equals("void")) { @@ -581,6 +581,46 @@ } throw new IllegalStateException("Can't convert " + o); } + static boolean samePrimitive(Class c1, Class c2) { + if (c1 == c2) { + return true; + } + if (c1.isPrimitive()) { + return c1.getName().equals(c2.getName()); + } + return false; + } + + static String findArraySignature(Class type) { + if (!type.isPrimitive()) { + return "[L" + type.getName().replace('.', '/') + ";"; + } + if (samePrimitive(type, Integer.TYPE)) { + return "[I"; + } + if (samePrimitive(type, Long.TYPE)) { + return "[J"; + } + if (samePrimitive(type, Double.TYPE)) { + return "[D"; + } + if (samePrimitive(type, Float.TYPE)) { + return "[F"; + } + if (samePrimitive(type, Byte.TYPE)) { + return "[B"; + } + if (samePrimitive(type, Boolean.TYPE)) { + return "[Z"; + } + if (samePrimitive(type, Short.TYPE)) { + return "[S"; + } + if (samePrimitive(type, Character.TYPE)) { + return "[C"; + } + throw new IllegalStateException("Can't create array for " + type); + } @JavaScriptBody(args = { "cls", "m", "o" }, body = "return cls.cnstr(false)[m](o);"