-
1. Re: Possible to refer to classes that will be generated late
chiba Sep 8, 2004 8:31 AM (in response to bug-c)Let me know what you mean by "reference to classes
that will be generated later on". Do you want
to define a class whose definition includes
the names of undefined classes?
A tip that might be helpful is that you can create
an empty class without any members but append
members later. -
2. Re: Possible to refer to classes that will be generated late
bug-c Sep 8, 2004 8:47 AM (in response to bug-c)Hi Chiba,
Yes exactly like that. I have a class A that contains a reference to an instance of class B and a class B which has a refence to A. Thanks for your answer, I think it could do it like that.
One final question:
Is is possible to unload created classes later on? I just ask as I also would need that for my application, but I do not find an unloadClass method (or the like) in the ClassPool class.
Thanks,
Stefan -
3. Re: Possible to refer to classes that will be generated late
chiba Sep 9, 2004 10:11 PM (in response to bug-c)As you know, you cannot unload a class from
the JVM.
If you simply want to remove a CtClass instance
from the hashtable in a ClassPool, call
CtClass.detach() on that instance. -
4. Re: Possible to refer to classes that will be generated late
chiba Sep 9, 2004 10:15 PM (in response to bug-c)One more comment.
Be careful when you use detach().
The detached CtClass might be still
referred to by another CtClass instance.
If so, the detached instance is not completely removed.
If you call ClassPool.get() fter calling detach(),
Javassist creates a new instance of CtClass.
Then the old and new CtClass instances representing
the same class might cause some inconsistency
problem. -
5. Re: Possible to refer to classes that will be generated late
bug-c Sep 10, 2004 6:20 AM (in response to bug-c)"chiba" wrote:
As you know, you cannot unload a class from
the JVM.
*hmm* that's bad. I thought that this is perhaps also possible. Thanks a lot for your answers :) -
6. Re: Possible to refer to classes that will be generated late
chiba Sep 10, 2004 10:04 AM (in response to bug-c)It is not a limitation of Javassist but the JVM.
You can reload a class if you use the JPDA
interface but the schema changes between
the old and new classes are quite restricted.