<br><br><div><span class="gmail_quote">On 12/12/2007, <b class="gmail_sendername">David Wagner</b> <<a href="mailto:daw@cs.berkeley.edu">daw@cs.berkeley.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Mike Samuel <<a href="mailto:mikesamuel@gmail.com">mikesamuel@gmail.com</a>> writes:<br>>Does Joe-E provide a tamed equivalent to<br>>java.lang.reflect.Proxy.newProxyInstance?<br><br>Yes: org.joe_e.reflect.Proxies.proxy
().<br><br>>If it does, then having access to an interface's class object allows you to<br>>proxy that interface.<br><br>In Joe-E, Class objects are ambiently available and therefore must</blockquote><div><br>Public classes, and classes within the same package are ambiently available, but you contradict a lot of people's assumptions if you make private inner classes ambiently available.
<br><br> <br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">not (and do not) convey authority. For instance, you can always write
<br> Class c = Foo.class;<br>to get a Class object for class Foo.<br><br>By the way, you don't need reflection to proxy an interface. If you<br>know statically what interface you want to proxy and how you want to<br>
handle all method calls to that interface, you can just write a class<br>that implements that interface, and Bob's your uncle.</blockquote><div><br>Not true. Proxying allows you to do things with private inner classes and package private classes that you can't do statically. See the below program.
<br><br>import java.lang.reflect.*;<br><br>public class Foo {<br> public static void main(String[] args) {<br> Object baz = Proxy.newProxyInstance(<br> Foo.class.getClassLoader(),<br> new Class[] { Bar.c
},<br> new InvocationHandler() {<br> public Object invoke(<br> Object proxy, Method method, Object[] args) {<br> System.err.println("Invoked " + method);<br> return null;
<br> }<br> });<br> Bar.exec(baz);<br> }<br>}<br><br>class Bar {<br> // Class is private<br> private interface Baz {<br> void foo();<br> }<br><br> // but class object is exposed, either as a class, or because
<br> // Bar passes out an instance whose class is available via<br> // getClass()<br> static Class c = Baz.class;<br><br> // The enclosing class unwraps an instance and assumes only<br> // it could have created it.<br>
static void exec(Object o) {<br> ((Baz) o).foo();<br> }<br>}<br><br><br><br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This may be an obscure tangent; if so, my apologies....<br>_______________________________________________<br>cap-talk mailing list<br><a href="mailto:cap-talk@mail.eros-os.org">cap-talk@mail.eros-os.org</a><br><a href="http://www.eros-os.org/mailman/listinfo/cap-talk">
http://www.eros-os.org/mailman/listinfo/cap-talk</a><br></blockquote></div><br>