I have been playing with Javassist in order to modified a class at load
time if it implements a specific interface.
I figured creating my own class loader and catching it in the loadClass
method would work.
I was using the makeReflective(..) call since this is what I need
to do is trap all method calls to this object.
But my problem is that since I called super.loadClass(..)
and then try to a makeRefective(...)
I get a class frozen exception.
Does anyone have any suggestions on how to do this with
Javassist. Maybe there is a hook somewhere else?
MyLoader extends reflect.Loader
protected Class loadClass(...)
clazz = super.loadClass(..).
if ( clazz has interface xyz )
return reflective modified class.
Thanks for any suggestions.
You should define a subclass of javassist.reflect.Reflection,
override onWrite() in that subclass, and modify
javassist.reflect.Loader so that it uses your new class instead
onWrite() can choose which class must be reflective.