class loader

Delegation Principal

Class loaders request their parent to load the class first before attempting to load it themselves. classloader1           classloader2

Visibility Principal

Classes loaded by the parent class loaders have visibility into classes loaded by its children down the hierarchy, but the reverse is not true classloader3

Uniqueness Principal

When a class loader loads a class, the child class loaders in the hierarchy will never reload the class again. Hence uniqueness is maintained.  

Although this, you are easy to violate this by manually loading the class. Thus, in a classloader hierarchy, there exists two Class with the same qualified name but loaded by different classloaders.

Then if you cast them, a ClassCastException will be thrown.


class loading ways

  • explicitly invoke new XXX()
  • load its subclass, then the parent class will be also loaded
  • dynamically load class: Class.forName(“”)