Tuesday 5 May 2015

Class loader in Java

ClassLoaders(CL) in Java

Class Loader:

1. Responsible for loading classes
2. is Abstract class
3. given binary name -> CL should attempt to locate or generate data that    constitues a definition for the class
4. Every Class object contains reference to ClassLoader that defined it.
5. Class objects for array classes are not created by ClassLoader but automaticallt by Java runtime.   If the element type is a primitive type, then array class has no class loader.
6. Class.getClassLoader()
7. typically used by security managers to indicate security domains
8. ClassLoader class uses a delegation model to search classes and resources.   Each instance of ClassLoader has an assocaited parent class loader.
9. When requested to find a class or resource, a ClassLoader instance delegate the search for the class or resource to its parent class loader before attempting to find class itself.
10. Virtual machine build in class loader called "BootStrap class loader" does not ahve parent but may serve as parent of classloader instance.
11. Normally, JVM loades classes from local file system  in paltform dependent manner.
12. Some classes may not originate from a file, they may originate from other sources. The method defineClass converts bytes into an instance of class "Class". Instance of newly defined is class can be created using Class.newInstance.
13. Method and constructor of objects created by class loader may reference to other class.    JVM uses loadClass method of the classs loader that originally created the class.      

No comments:

Post a Comment