1.1 --- a/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Mon Feb 17 16:55:44 2014 +0100
1.2 +++ b/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Wed May 07 08:49:54 2014 +0200
1.3 @@ -552,28 +552,28 @@
1.4 }
1.5
1.6 static Object fromPrimitive(Class<?> type, Object o) {
1.7 - if (type == Integer.TYPE) {
1.8 + if (samePrimitive(type, Integer.TYPE)) {
1.9 return fromRaw(Integer.class, "valueOf__Ljava_lang_Integer_2I", o);
1.10 }
1.11 - if (type == Long.TYPE) {
1.12 + if (samePrimitive(type, Long.TYPE)) {
1.13 return fromRaw(Long.class, "valueOf__Ljava_lang_Long_2J", o);
1.14 }
1.15 - if (type == Double.TYPE) {
1.16 + if (samePrimitive(type, Double.TYPE)) {
1.17 return fromRaw(Double.class, "valueOf__Ljava_lang_Double_2D", o);
1.18 }
1.19 - if (type == Float.TYPE) {
1.20 + if (samePrimitive(type, Float.TYPE)) {
1.21 return fromRaw(Float.class, "valueOf__Ljava_lang_Float_2F", o);
1.22 }
1.23 - if (type == Byte.TYPE) {
1.24 + if (samePrimitive(type, Byte.TYPE)) {
1.25 return fromRaw(Byte.class, "valueOf__Ljava_lang_Byte_2B", o);
1.26 }
1.27 - if (type == Boolean.TYPE) {
1.28 + if (samePrimitive(type, Boolean.TYPE)) {
1.29 return fromRaw(Boolean.class, "valueOf__Ljava_lang_Boolean_2Z", o);
1.30 }
1.31 - if (type == Short.TYPE) {
1.32 + if (samePrimitive(type, Short.TYPE)) {
1.33 return fromRaw(Short.class, "valueOf__Ljava_lang_Short_2S", o);
1.34 }
1.35 - if (type == Character.TYPE) {
1.36 + if (samePrimitive(type, Character.TYPE)) {
1.37 return fromRaw(Character.class, "valueOf__Ljava_lang_Character_2C", o);
1.38 }
1.39 if (type.getName().equals("void")) {
1.40 @@ -581,6 +581,46 @@
1.41 }
1.42 throw new IllegalStateException("Can't convert " + o);
1.43 }
1.44 + static boolean samePrimitive(Class<?> c1, Class<?> c2) {
1.45 + if (c1 == c2) {
1.46 + return true;
1.47 + }
1.48 + if (c1.isPrimitive()) {
1.49 + return c1.getName().equals(c2.getName());
1.50 + }
1.51 + return false;
1.52 + }
1.53 +
1.54 + static String findArraySignature(Class<?> type) {
1.55 + if (!type.isPrimitive()) {
1.56 + return "[L" + type.getName().replace('.', '/') + ";";
1.57 + }
1.58 + if (samePrimitive(type, Integer.TYPE)) {
1.59 + return "[I";
1.60 + }
1.61 + if (samePrimitive(type, Long.TYPE)) {
1.62 + return "[J";
1.63 + }
1.64 + if (samePrimitive(type, Double.TYPE)) {
1.65 + return "[D";
1.66 + }
1.67 + if (samePrimitive(type, Float.TYPE)) {
1.68 + return "[F";
1.69 + }
1.70 + if (samePrimitive(type, Byte.TYPE)) {
1.71 + return "[B";
1.72 + }
1.73 + if (samePrimitive(type, Boolean.TYPE)) {
1.74 + return "[Z";
1.75 + }
1.76 + if (samePrimitive(type, Short.TYPE)) {
1.77 + return "[S";
1.78 + }
1.79 + if (samePrimitive(type, Character.TYPE)) {
1.80 + return "[C";
1.81 + }
1.82 + throw new IllegalStateException("Can't create array for " + type);
1.83 + }
1.84
1.85 @JavaScriptBody(args = { "cls", "m", "o" },
1.86 body = "return cls.cnstr(false)[m](o);"