Delegation Principal
Visibility Principal
Uniqueness Principal
- According to this principle, if a particular class is not loaded already, the classloaders delegate the requests to load that class to their parent classloaders.
Suppose your class MyApp is being loaded:public class MyApp{
Since the System-Classpath classloader loaded the MyApp class, it first asks its parent, the extension classloader to load the class. The extension classloader asks the Bootstrap classloader to load java.util.Vector. Since java.util.Vector is a J2SE class, the bootstrap classloader loads it and returns.
Vector vec = new Vector
}
Visibility Principal
- According to this principle, Classes loaded by parent classloaders are visible to child classloaders but not vice versa
- For classes loaded by ClassLoader X, classes A, B and X are visible, but not class Y. Sibling classloaders cannot see each other’s classes.
Uniqueness Principal
- According to this principle, when a classloader loads a class, the child classloaders in the hierarchy will never reload the class. This follows from the delegation principle since a classloader always delegates class loading to its parents. The child classloader will load it (or try to load it) only if the parent hierarchy fails to load the class. Thus the uniqueness of the class is maintained. An interesting scenario emerges when both parent and child classloaders load the same
No comments:
Post a Comment