1.1 --- a/rt/emul/mini/src/main/java/java/lang/reflect/Proxy.java Tue Feb 26 16:54:16 2013 +0100
1.2 +++ b/rt/emul/mini/src/main/java/java/lang/reflect/Proxy.java Mon Oct 21 14:34:12 2013 +0200
1.3 @@ -212,7 +212,16 @@
1.4
1.5 private static final long serialVersionUID = -2222568056686623797L;
1.6
1.7 -
1.8 + private final static Method getProxyClass;
1.9 + static {
1.10 + Class<?> pg;
1.11 + try {
1.12 + pg = Class.forName("org.apidesign.bck2brwsr.emul.reflect.ProxyImpl");
1.13 + getProxyClass = pg.getMethod("getProxyClass", ClassLoader.class, Class[].class);
1.14 + } catch (Exception ex) {
1.15 + throw new IllegalStateException(ex);
1.16 + }
1.17 + }
1.18
1.19 /**
1.20 * the invocation handler for this proxy instance.
1.21 @@ -315,7 +324,14 @@
1.22 Class<?>... interfaces)
1.23 throws IllegalArgumentException
1.24 {
1.25 - throw new IllegalArgumentException();
1.26 + try {
1.27 + try { throw new IllegalArgumentException(); } catch (Throwable t) {}
1.28 + return (Class<?>) getProxyClass.invoke(null, loader, interfaces);
1.29 + } catch (IllegalAccessException ex) {
1.30 + throw new IllegalStateException(ex);
1.31 + } catch (InvocationTargetException ex) {
1.32 + throw (RuntimeException)ex.getTargetException();
1.33 + }
1.34 }
1.35
1.36 /**
1.37 @@ -355,7 +371,27 @@
1.38 if (h == null) {
1.39 throw new NullPointerException();
1.40 }
1.41 - throw new IllegalArgumentException();
1.42 +
1.43 + /*
1.44 + * Look up or generate the designated proxy class.
1.45 + */
1.46 + Class<?> cl = getProxyClass(loader, interfaces);
1.47 +
1.48 + /*
1.49 + * Invoke its constructor with the designated invocation handler.
1.50 + */
1.51 + try {
1.52 + Constructor cons = cl.getConstructor(InvocationHandler.class);
1.53 + return cons.newInstance(new Object[] { h });
1.54 + } catch (NoSuchMethodException e) {
1.55 + throw new IllegalStateException(e.toString());
1.56 + } catch (IllegalAccessException e) {
1.57 + throw new IllegalStateException(e.toString());
1.58 + } catch (InstantiationException e) {
1.59 + throw new IllegalStateException(e.toString());
1.60 + } catch (InvocationTargetException e) {
1.61 + throw new IllegalStateException(e.toString());
1.62 + }
1.63 }
1.64
1.65 /**
1.66 @@ -376,8 +412,7 @@
1.67 if (cl == null) {
1.68 throw new NullPointerException();
1.69 }
1.70 -
1.71 - return false;
1.72 + return Proxy.class.isAssignableFrom(cl);
1.73 }
1.74
1.75 /**
1.76 @@ -401,7 +436,4 @@
1.77 Proxy p = (Proxy) proxy;
1.78 return p.h;
1.79 }
1.80 -
1.81 - private static native Class defineClass0(ClassLoader loader, String name,
1.82 - byte[] b, int off, int len);
1.83 }