1.1 --- a/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Thu Feb 28 10:39:40 2013 +0100
1.2 +++ b/rt/emul/mini/src/main/java/java/lang/reflect/Method.java Thu Feb 28 13:00:24 2013 +0100
1.3 @@ -512,8 +512,8 @@
1.4 args = args.clone();
1.5 for (int i = 0; i < types.length; i++) {
1.6 Class c = types[i];
1.7 - if (c.isPrimitive()) {
1.8 - args[i] = toPrimitive(c, args[i]);
1.9 + if (c.isPrimitive() && args[i] != null) {
1.10 + args[i] = toPrimitive(args[i]);
1.11 }
1.12 }
1.13 }
1.14 @@ -573,41 +573,8 @@
1.15 )
1.16 private static native Integer fromRaw(Class<?> cls, String m, Object o);
1.17
1.18 - private static Object toPrimitive(Class<?> type, Object o) {
1.19 - if (type == Integer.TYPE) {
1.20 - return toRaw("intValue__I", o);
1.21 - }
1.22 - if (type == Long.TYPE) {
1.23 - return toRaw("longValue__J", o);
1.24 - }
1.25 - if (type == Double.TYPE) {
1.26 - return toRaw("doubleValue__D", o);
1.27 - }
1.28 - if (type == Float.TYPE) {
1.29 - return toRaw("floatValue__F", o);
1.30 - }
1.31 - if (type == Byte.TYPE) {
1.32 - return toRaw("byteValue__B", o);
1.33 - }
1.34 - if (type == Boolean.TYPE) {
1.35 - return toRaw("booleanValue__Z", o);
1.36 - }
1.37 - if (type == Short.TYPE) {
1.38 - return toRaw("shortValue__S", o);
1.39 - }
1.40 - if (type == Character.TYPE) {
1.41 - return toRaw("charValue__C", o);
1.42 - }
1.43 - if (type.getName().equals("void")) {
1.44 - return o;
1.45 - }
1.46 - throw new IllegalStateException("Can't convert " + o);
1.47 - }
1.48 -
1.49 - @JavaScriptBody(args = { "m", "o" },
1.50 - body = "return o[m](o);"
1.51 - )
1.52 - private static native Object toRaw(String m, Object o);
1.53 + @JavaScriptBody(args = { "o" }, body = "return o.valueOf();")
1.54 + private static native Object toPrimitive(Object o);
1.55
1.56 /**
1.57 * Returns {@code true} if this method is a bridge