4 Replies Latest reply on Nov 4, 2004 11:31 AM by Shigeru Chiba

    Copying / Moving fabricated CtClass from one ClassPool to an

    Howard Lewis Ship Newbie

      Here's my situation:

      I have two ClassPool instances, let's call them A and B.

      I create a new CtClass in ClassPool A. It has an arbitrary name, generated at runtime. I succesfully create my CtClass, and with the help of a custom class loader, instantiate an instance of the actual Class. Let's call that C1.

      Later, I want to create a different Class, Class C2, using ClassPool B.

      C2 has methods and fields of type C1.

      I get Javassist errors at this point:

      Caused by: org.apache.hivemind.ApplicationRuntimeException: Unable to add constructor to class $ServicePropertyProxy_feb5c6c94d_43: [source error] javassist.NotFoundException: $SingletonProxy_feb5c6c871_37

      That's because C1 ($SingletonProxy...) is unknown to the ClassPool B, which is trying to create Class C2 ($ServicePropertyProxy...).

      What I'm struggling with is a way to "tell" ClassPool B about a class fabrictaed using ClassPool A.

      I'd love some feedback; in the meantime I'm pursuing my own approach, where I have a subclass of ClassPool that I can "inject" with my CtClass instances from foriegn ClassPools.