I came across this interesting article about loading and unloading of static fields which details a couple of facts I was not aware of
1. Loading – You can get a reference to a class, before it has been initialized (i.e its static fields being initialized or its static initializers being called), only when it is used does it get initialized. The link contains an example code which illustrates this fact.
2. Unloading – Static fields are unloaded when the Class’ classloader is unloaded. This is unloaded when a GC is performed and there are no strong references from the threads’ stacks.
This post adds more detail to the second point. Below are few reasons why classes are unloaded only when the classloader unloads.