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

FYI: [donation] dynamicProxy implementation, based on BCEL

As there seemed to be a need for this beast, I took some time off and 
implemented it.
Hopefully it will be useful for helping Cocoon to get rid of ECM sooner 
rather that later ;-)

Rgds,
Neeme

-- Original Message --
Teema: [donation] dynamicProxy implementation, based on BCEL
Kuup�ev: Fri, 06 Dec 2002 01:05:07 +0200
Kellelt: Neeme Praks <ne...@apache.org>
Adressaat: bcel-dev <bc...@jakarta.apache.org>


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