1 Reply Latest reply on Feb 3, 2004 7:39 AM by chiba

    change class based on implementing an interface

    jcl

       

      "jcl" wrote:
      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?

      Pseudo code:
      MyLoader extends reflect.Loader

      protected Class loadClass(...)
      {
      clazz = super.loadClass(..).
      if ( clazz has interface xyz )
      {
      makeReflective(...)
      return reflective modified class.
      }
      else
      {
      return clazz
      }
      }

      Thanks for any suggestions.