ClassLoader

来源:互联网 发布:淘宝客怎么赚钱? 编辑:程序博客网 时间:2024/05/19 22:28

JVM can be divided into two parts: classloader and execute engine. Classloader takes charge of loading varies class files into JVM, execute engine executes them, and will invoke native method in your system.


ClassLoader Types:

There are two kinds of ClassLoader here: Bootstrap ClassLoader(a part of JVM, written by C++), and CustDef ClassLoader.

Bootstrap ClassLoader loads Java API class files like java.lang.String, CustDef ClassLoader loads class written by programmers. 


Namespace:

If Class A dependends on Class B, then JVM will load Class B using the same ClassLoader that loads Class A.

Different ClassLoader have different namespace, which means the classes loaded by the same class loader are able to each other, otherwise, are not able to. Things like this under default condition. And this is for security consideration.


Parents Delegation Model

A class loader(not Bootstrap ClassLoader) will always make a request to another class loader to load class file, this is Parents Delegation Model. So every class loader has a parent classLoader except Bootstrap ClassLoader.

If all its parent class loaders can't load this class file, then the base class loader itself will load it.


resources: http://www.blogjava.net/zhuxing/archive/2008/08/08/220841.html

     http://www.iteye.com/topic/83978

  http://blog.csdn.net/xw13106209/article/details/7041807