Monday, June 11, 2012

What is a class loader and what are its responsibilities?

The Class loader is a subsystem of a JVM which is responsible, predominantly for loading classes and interfaces in the system. Apart from this, a class loader is responsiblefor the following activities:-Verification of imported types(classes and interfaces)-Allocating memory for class variables and initializing them to default values. Staticfields for a class are created and these are set to standard default values but they are notexplicitly initialized. The method tables are constructed for the class.-Resolving symbolic references from type to direct references The class loaders can be of two types: a bootstrap or primordial class loader and user defined class loaderEach JVMhas a bootstrap class loader which loads trusted classes , including classes from JavaAPI.JVM specs do not tell how to locate these classes and is left to implementationdesigners.A Java application with user defined class loader objects can customize class loading.These load untrustworthy classes and not an intrinsic part of JVM.They are written inJava, converted to class files and loaded into the JVM and installed like any other objects.

No comments:

Post a Comment