Visibility Principle in JVM Class Loader

Viewed 387

What is the significance of Visibility principle in class loader of JVM? I understand the uniqueness principle that is handled by delegation model but could not decode the benefit of the Visibility principle or why would this principle was introduced in first place?

1 Answers

The child class loaders NEED to be aware of the parent class loaders. The parent class loaders DON'T NEED to be aware of the child class loaders.

Why? Because of the class dependencies(inheritance, composition, etc).

Classes from the Application Classloader - those defined by the user - could use classes from the Extension or Bootstrap Classloader. But not the other way around. Similarly, classes from the Extension Classloader use classes from the Bootstrap Classloader. Classes from Bootstrap can't use classes from the extension - if they did, they would be included in the Bootstrap. Classes from the Application Classloader didn't even exist at the time the classes in the Bootstrap were written.

Correctness benefit: Trying to load an Application Classloader class from the Bootstrap classloader would result in a circular dependency.

Optimization benefit(minor): I would imagine this delegation model to lend itself to a linked list. A double-linked list is more expensive.

Related