• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when class gets unloaded?

 
hari harann
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
hari harann
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks steve..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic