[cap-talk] David Wagner's Google techtalk is now up!

Mike Samuel mikesamuel at gmail.com
Fri Dec 14 19:03:32 EST 2007


On 14/12/2007, Mike Samuel <mikesamuel at gmail.com> wrote:
>
>
>
> On 12/12/2007, David Wagner <daw at cs.berkeley.edu> wrote:
> >
> > Mike Samuel <mikesamuel at gmail.com> writes:
> > >Does Joe-E provide a tamed equivalent to
> > >java.lang.reflect.Proxy.newProxyInstance?
> >
> > Yes: org.joe_e.reflect.Proxies.proxy ().
> >
> > >If it does, then having access to an interface's class object allows
> > you to
> > >proxy that interface.
> >
> > In Joe-E, Class objects are ambiently available and therefore must
>
>
> 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.
>

I was unclear.   In a single classloader environment, classes are obviously
ambient if you allow lookup by name.

But someone who defines a private interface will often assume that an
instance will only behave in ways they define.  The presence of
proxyNewInstance without access checks violates that assumption and so makes
it easier to confuse deputies.



not (and do not) convey authority.  For instance, you can always write
> >   Class c = Foo.class;
> > to get a Class object for class Foo.
> >
> > By the way, you don't need reflection to proxy an interface.  If you
> > know statically what interface you want to proxy and how you want to
> > handle all method calls to that interface, you can just write a class
> > that implements that interface, and Bob's your uncle.
>
>
> 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.
>
> import java.lang.reflect.*;
>
> public class Foo {
>   public static void main(String[] args) {
>     Object baz = Proxy.newProxyInstance(
>         Foo.class.getClassLoader(),
>         new Class[] { Bar.c },
>         new InvocationHandler() {
>           public Object invoke(
>               Object proxy, Method method, Object[] args) {
>             System.err.println("Invoked " + method);
>             return null;
>           }
>         });
>     Bar.exec(baz);
>   }
> }
>
> class Bar {
>   // Class is private
>   private interface Baz {
>     void foo();
>   }
>
>   // but class object is exposed, either as a class, or because
>   // Bar passes out an instance whose class is available via
>   // getClass()
>   static Class c = Baz.class;
>
>   // The enclosing class unwraps an instance and assumes only
>   // it could have created it.
>   static void exec(Object o) {
>     ((Baz) o).foo();
>   }
> }
>
>
>
>
>
> This may be an obscure tangent; if so, my apologies....
> > _______________________________________________
> > cap-talk mailing list
> > cap-talk at mail.eros-os.org
> > http://www.eros-os.org/mailman/listinfo/cap-talk
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eros-os.org/pipermail/cap-talk/attachments/20071214/4290a567/attachment.html 


More information about the cap-talk mailing list