classloader

classloader is class which is defined to load classes in the Java VM.

A JVM has a primordial class loader which loads the classes required for the virtual machine and all the classes which are defined in the classpath. Besides this classloader there are different other class loaders.

1. Applet class loader

this class loader first allows the primodial class loader to load the class. if the primordial class loader cannot find the class then it fetches the byte code using HTTP and loads the class itself.

2.RMI and Secure class loader

introduced in java 1.2 and java 2.0 respectively these class loader use different methods to fetch the byte code for the java classes. Note that each time the primordial class loader is allowed to load classes first.

Characteristics of classloader:

since the primordial class loader is allowed to load the class first this prevents overwrriting of existing classes. this prevents non secure code from pretending to be system classes.

each class loader has a namespace of its own. thus the classes loaded by one class loader cannot access the classes loaded by another class loader. this prevents ambiguity in case of different classes defined under same package name by different applets loaded at the same time.

e.g: applet 1 loads com.AppletForm.class from www.google.com

e.g: applet 2 loads com.AppletForm.class from www.yahoo.com

since the two applets are loaded by different applet class loaders the JVM has no ambiguity even thought both use two different classes of same name and package.

Source:

http://www.securingjava.com/chapter-two/chapter-two-7.html