<br><br><div><span class="gmail_quote">On 12/12/2007, <b class="gmail_sendername">David Wagner</b> &lt;<a href="mailto:daw@cs.berkeley.edu">daw@cs.berkeley.edu</a>&gt; 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 &lt;<a href="mailto:mikesamuel@gmail.com">mikesamuel@gmail.com</a>&gt; writes:<br>&gt;Does Joe-E provide a tamed equivalent to<br>&gt;java.lang.reflect.Proxy.newProxyInstance?<br><br>Yes: org.joe_e.reflect.Proxies.proxy
().<br><br>&gt;If it does, then having access to an interface&#39;s class object allows you to<br>&gt;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&#39;s assumptions if you make private inner classes ambiently available.
<br><br>&nbsp; <br>&nbsp;</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.&nbsp;&nbsp;For instance, you can always write
<br>&nbsp;&nbsp;Class c = Foo.class;<br>to get a Class object for class Foo.<br><br>By the way, you don&#39;t need reflection to proxy an interface.&nbsp;&nbsp;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&#39;s your uncle.</blockquote><div><br>Not true.&nbsp; Proxying allows you to do things with private inner classes and package private classes that you can&#39;t do statically.&nbsp; See the below program.
<br><br>import java.lang.reflect.*;<br><br>public class Foo {<br>&nbsp; public static void main(String[] args) {<br>&nbsp;&nbsp;&nbsp; Object baz = Proxy.newProxyInstance(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Foo.class.getClassLoader(),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new Class[] { Bar.c
 },<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; new InvocationHandler() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Object invoke(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object proxy, Method method, Object[] args) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.err.println(&quot;Invoked &quot; + method);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br>&nbsp;&nbsp;&nbsp; Bar.exec(baz);<br>&nbsp; }<br>}<br><br>class Bar {<br>&nbsp; // Class is private<br>&nbsp; private interface Baz {<br>&nbsp;&nbsp;&nbsp; void foo();<br>&nbsp; }<br><br>&nbsp; // but class object is exposed, either as a class, or because
<br>&nbsp; // Bar passes out an instance whose class is available via<br>&nbsp; // getClass()<br>&nbsp; static Class c = Baz.class;<br><br>&nbsp; // The enclosing class unwraps an instance and assumes only<br>&nbsp; // it could have created it.<br>
&nbsp; static void exec(Object o) {<br>&nbsp;&nbsp;&nbsp; ((Baz) o).foo();<br>&nbsp; }<br>}<br><br><br><br>&nbsp;</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>