You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by Neeme Praks <ne...@apache.org> on 2002/12/06 00:05:07 UTC

[donation] dynamicProxy implementation, based on BCEL

After some digging and wrestling, I finally managed to complete first 
shot at implementing dynamic proxies with BCEL.

Attached are the sources and some patches to the existing files that I 
found useful:
* classfile/ConstantUtf8.java should not allow null reference to bytes
* classfile/Field.java sent already earlier
* classfile/Method.java sent already earlier
* generic/PUTSTATIC.java mistake in javadocs
* util/Repository.java sent already earlier

Issues:
* invocation handler is set via a public 
setInvocationHandler(InvocationHandler ih) method on a proxy. If someone 
figures out, how to pass InvocationHandler to a constructor then that 
would be even better... but AFAIK, this is not possible?
* in order to use the generator, there is currently some classloader 
magic involved... should look for ways to make this easier (if possible?)

TODO:
* implement the other three standard static methods for Proxy class:
     * getInvocationHandler(Object proxy)
     * getProxyClass(ClassLoader loader, Class[] interfaces)
     * isProxyClass(Class cl)
* javadocs everywhere
* unit tests
* probably should move some stuff from ProxyClassLoader to util/ClassLoader
* package name... right now I put it in proxy subpackage, but this is 
just a matter of preference

If someone feels like helping me out with any of the issues, feel free 
to contribute.

In order to see the generator in action, extract the archive and apply 
the patches.
Then run:
java -cp bin/classes org.apache.bcel.proxy.sample.SampleLoader

And you should see the result on your console.

While generating the proxy in debug mode, generator prints out a bunch 
of debugging information that should give some idea, what is happening 
behind the scenes.

Ok, will get some sleep now, probably will try to check up on the TODO 
list next week (short of time this week...)

Rgds,
Neeme