1.1 --- a/emul/src/main/java/java/lang/reflect/Method.java Wed Dec 19 16:43:37 2012 +0100
1.2 +++ b/emul/src/main/java/java/lang/reflect/Method.java Thu Dec 20 08:59:47 2012 +0100
1.3 @@ -524,13 +524,34 @@
1.4
1.5 private static Object fromPrimitive(Class<?> type, Object o) {
1.6 if (type == Integer.TYPE) {
1.7 - return fromInteger(o);
1.8 + return fromRaw(Integer.class, "valueOf__Ljava_lang_Integer_2I", o);
1.9 }
1.10 - return o;
1.11 + if (type == Long.TYPE) {
1.12 + return fromRaw(Long.class, "valueOf__Ljava_lang_Long_2J", o);
1.13 + }
1.14 + if (type == Double.TYPE) {
1.15 + return fromRaw(Double.class, "valueOf__Ljava_lang_Double_2D", o);
1.16 + }
1.17 + if (type == Float.TYPE) {
1.18 + return fromRaw(Float.class, "valueOf__Ljava_lang_Float_2F", o);
1.19 + }
1.20 + if (type == Byte.TYPE) {
1.21 + return fromRaw(Byte.class, "valueOf__Ljava_lang_Byte_2B", o);
1.22 + }
1.23 + if (type == Boolean.TYPE) {
1.24 + return fromRaw(Boolean.class, "valueOf__Ljava_lang_Boolean_2Z", o);
1.25 + }
1.26 + if (type == Short.TYPE) {
1.27 + return fromRaw(Short.class, "valueOf__Ljava_lang_Short_2S", o);
1.28 + }
1.29 +// case 'V': return Void.TYPE;
1.30 + throw new IllegalStateException("Can't convert " + o);
1.31 }
1.32
1.33 - @JavaScriptBody(args = "o", body = "return vm.java_lang_Integer(false).valueOf__Ljava_lang_Integer_2I(o);")
1.34 - private static native Integer fromInteger(Object o);
1.35 + @JavaScriptBody(args = { "cls", "m", "o" },
1.36 + body = "return cls.cnstr(false)[m](o);"
1.37 + )
1.38 + private static native Integer fromRaw(Class<?> cls, String m, Object o);
1.39
1.40 /**
1.41 * Returns {@code true} if this method is a bridge