In Eclipse each plug-in has its own class loader and has its own class look-up path that is derived from the imported plug-ins. A separate class loader gives each plug-in a separate name space for its classes. The class loader also is responsible for triggering the activation of a plug-in. When a plug-in class loader loads the first class from a plug-in, then the plug-in is activated and the plug-in's startup() method is called.
The classes are looked-up in the following order:
-
The plug-in class loader's parents— The immediate parent of a plug-in class loader is the Eclipse boot class loader. It provides access to the Eclipse boot classes (boot.jar). The parent of the boot class loader is the standard Java system class loader, which terminates the parent chain. Notice that the application class loader, which loads classes from the system's CLASSPATH variable is not part of this chain. This means classes on the system class path are never found by Eclipse. Plug-ins are the only way to surface additional classes. The following spider diagram illustrates the parent chain:
-
The plug-in's class loader itself— It finds the classes contributed by the plug-in as specified in the run-time section of the plugin.xml manifest.
-
The plug-in class loaders of the imported/prerequisite plug-ins— A delegating URL class loader is used internally to forward the class lookup to the imported plug-ins.