aspose file tools*
The moose likes Beginning Java and the fly likes when class gets unloaded? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "when class gets unloaded?" Watch "when class gets unloaded?" New topic
Author

when class gets unloaded?

hari harann
Ranch Hand

Joined: Aug 07, 2008
Posts: 54
we all know that when a class gets loaded, static block does execute and static variable exists as long as class is loaded.
but my question is when does the class gets unloaded from VM ???
please explain
[ August 16, 2008: Message edited by: Bear Bibeault ]
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3956
    
  17

Originally posted by hari harann:
we all know that when a class gets loaded, static block does execute and static variable exists as long as class is loaded.
but my question is when does the class gets unloaded from VM ???
please explain


According to the JLS, classes can only be unloaded when the ClassLoader that loaded the class is being garbage collected (and thus the classes it loaded are no longer reachable). The link above goes into more detail on the rationale.


Steve
hari harann
Ranch Hand

Joined: Aug 07, 2008
Posts: 54
thanks steve..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: when class gets unloaded?
 
Similar Threads
Loading of a class
Class loading
static block
When to close static PreparedStatements
Singleton Pattern