I use Javassist to create a class. And in a test suite, when a second test tries to create the same class, it fails at pool.makeClass( ... )
because the class is fr
You cannot unload a single class from a ClassLoader
. A class may be unloaded if it and its ClassLoader
became unreachable but since every class refers to its loader that implies that all classes loaded by this loader must have become unreachable too.
But you can (re-)create the class using a different ClassLoader
. Well, formally it is a different class with the same name (and maybe the same byte code) then. If the code executed within the test case leaves no references in the heap, the ClassLoader
and its classes might be collected after the test.