By "released" I mean there are no references to the classloader remaining.
We're running into a problem where a frequently-redeployed Java EE application eats up permgen space. Analysis shows that a singleton in the Java EE app has passed references to application-classloader objects outside of the application (in violation of Java EE rules) and isn't clearing them when the app is undeployed.
Assuming there are no other references remaining to the singleton or the class object, will the singleton's finalize() be called when its class's classloader is released? I'd like to clear the rogue in-bound references there. Or am I in a catch-22 where finalize won't get called until the classloader itself can be garbage-collected - and thus will never be called because of the rogue external references?
The main question here is perhaps:
Will a class object be garbage-collected in this case where its classloader can't be yet? This may be dependent on the specification of classloader behavior, or may be implementation-dependent.
References (the other kind! ;-)) would be appreciated, but aren't necessary.