Appendix A. ClassLoaders and JBoss


When a Java application references Java classes, the Java Virtual Machine (JVM) uses a ClassLoader to load them into memory. The Delegation Model was introduced in Java 2 and organizes ClassLoaders into the following tree/hierarchy by using parent/child relationships, as shown in Figure A-1.

Figure A-1. Standard J2SE ClassLoader hierarchy


The J2SE ClassLoaders do the following:

  • The Bootstrap (also called the primordial) ClassLoader has no parent, is the root of the ClassLoader tree, and loads core Java classes (java.*) into the JVM.

  • The Extension ClassLoader loads extension classes:

    • Classes that extend core Java classesjavax.*.

    • Classes from the Java Runtime Environment (JRE) lib/ext directory in the standard J2SE installation.

  • The System (also called the Application) ClassLoader loads classes and JARs from the system CLASSPATHthe CLASSPATH environment variable and the classpath argument on the java command line.

If the current ClassLoader previously loaded a class, then the ClassLoader returns the class to the client. If a class has not been previously loaded, then according to the Java specification, a ClassLoader must defer (or delegate) to its parent before trying to load the class itself. For example, if an application references java.lang.String, the System ClassLoader delegates to the Extension ClassLoader, which in turn defers to the Bootstrap ClassLoader to load the String class. The child ClassLoader gets a chance to load a class only if the parent hasn't already loaded the class or couldn't load the class. A class is loaded only once per ClassLoader.



JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net