I want to lay the groundwork on which we can start a discussion about dynamic and modular software systems. Class loaders may seem to be a dry topic, but I think it is one of the topics that separate the junior from the senior software engineer, so bear
Tutorial Details:
\"Why should I deal with multiple class loaders and their limitations and problems?\" a simple servlet or JSP program and deploy within a servlet container, your code is loaded by your very own class loader, preventing you from accessing other web applications\' classes. In addition, many \"container-type\" applications such as J2EE servers, web containers, NetBeans, and others are using custom class loaders in order to limit the impact of classes provided by a component, and thus will have an impact on the developer of such components.one class loaded in a particular JVM. Additional class loaders enable a developer to partition the JVM
First we need to explain some definitions:
CL: Class loader.
Initial CL: The CL that initiated the loading of the class.
Effective CL: The CL that actually loaded the class.
Class type: The fully qualified class name (package plus class name).
Class: A combination of the class type and effective class loader.
java.lang.Class: A class in the JDK that represents a class (name, fields, methods, etc.).
Symbolic Link: A class type used within the source code, such as superclasses, extended interfaces, variables, parameters, return values, instanceofs, and upcasts.
Class loaders and their usage follow a few simple rules:
* Class loaders are hierarchically organized, where each one has a parent class loader, except the bootstrap class loader (the root).
* Class loaders should (practically: must) delegate the loading of a class to the parent, but a custom class loader can define for itself when it should do so.
* A class is defined by its class type and the effective class loader.
* A class is only loaded once and then cached in the class loader to ensure that the byte code cannot change.
* Any symbolic links are loaded by the effective class loader (or one of its ancestors), if this is not already done. The JVM can defer this resolution until the class is actually used.
* An upcast of an instance to another class fails when the class of the instance and the class of the symbolic link do not match (meaning their class loaders do not match).
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: Inside Class Loaders
View Tutorial: Inside Class Loaders
Related
Tutorials:
Revolutionary RMI: Dynamic
class loading
and behavior
objects - JavaWorld - December 1998
Revolutionary RMI: Dynamic
class loading
and behavior
objects - JavaWorld - December 1998 |
Java Tip 39: The trick
to using a basic
Java 1.1 network
and file class
loader - JavaWorld -
Java Tip 39: The trick
to using a basic
Java 1.1 network
and file class
loader - JavaWorld - October
1997 |
Java Tip 70: Create objects from jar
files! - JavaWorld - March
1999
Java Tip 70: Create objects from jar
files! - JavaWorld - March
1999 |
What's new in Java Servlet API 2.2? -
JavaWorld
October 1999
What's new in Java Servlet API 2.2? -
JavaWorld
October 1999 |
Static class declarations
Static class declarations |
A ZipClassLoader for automated application distribution - JavaWorld April 2000
A ZipClassLoader for automated application distribution - JavaWorld April 2000 |
Object mobility
in the Jini environment - JavaWorld January 2001
Object mobility
in the Jini environment - JavaWorld January 2001 |
When is a Singleton not a
Singleton? - JavaWorld January 2001
When is a Singleton not a
Singleton? - JavaWorld January 2001 |
The basics of Java class loaders
The basics of Java class loaders |
Cracking Java byte-code encryption
Cracking Java byte-code encryption |
classworlds
classworlds
classworlds is a framework for container developers who require complex manipulation of Java\'s ClassLoaders. Java\'s native ClassLoader mechanims and classes can cause much headache and confusion for certain types of application developers. |
Good article
Good article |
Java Development on Eclipse, Part 1
Java Development on Eclipse, Part 1
Author\'s note: In part one of a two-part series of excerpts from Eclipse\'s Chapter 2, we\'ll get down to the business of developing Java using Eclipse. We\'re going to take a look at using Eclipse for Java developm |
Inside Class Loaders: Debugging
Inside Class Loaders: Debugging
This article will show how to solve class-loading problems and to overcome some debugging limitations of the JDK class loaders.
|
Attribute-Oriented Programming with Java 1.5, Part 1
In this article, I will consider the case of a status-bar component embedded in a GUI application. I will explore a number of different ways to implement this status reporter, starting with the traditional hard-coded idiom. Along the way, I will introduce |
Attribute-Oriented Programming with Java 1.5, Part 2
Peeking Inside the Box: Attribute-Oriented Programming with Java 1.5,Part
In the previous article in this series, "Peeking Inside the Box, Part 1," I introduced the concepts of Attribute-Oriented Programming, Java 1.5 annotations, and bytecode instrume |
Understanding Network Class Loaders Class loaders
One of the cornerstones of Java dynamics, determine when and how classes can be added to a running Java environment. |
Game Canvas Basics
Introduces the MIDP 2.0 GameCanvas class and the game loop concept. Required reading for all aspiring "first person shooter" developers. |
Adding search to your applications
The Lucene search engine is an open source, Jakarta project used to build and search indexes. Lucene can index any text-based information you like and then find it later based on various search criteria. |
Internals of Java Class Loading
When are two classes not the same? When they're loaded by different class loaders. This is just one of many curious side effects of Java's class-loading system. Binildas Christudas shows how different class loaders relate to one another and how (and why) |
|
|
|