When the JVM needs access to a particular class, it is up to a class loader to provide the class. Internally each class is represented as an instance of class Class. In JDK 1.2 the built-in system class loader is used to load classes from the local _le system in a platform dependent manner. Additionally, Java programmers can de_ne their own class loaders by subclassing the built-in class ClassLoader and implementing the loadClass method. The system class loader is an instance of this class. The programming interface is as follows:
The class loader takes care of loading and linking, although the name ClassLoader might suggest that it is only responsible for loading and not linking. User de_ned class loaders customize the load phase; class loaders do not di_er in the way they link classes. Linking is done by the method resolveClass.
When a class has to be linked, then it must have been loaded before. When loading a class, all its non-loaded super classes (if any) must be loaded as well, from bottom to top in the inheritance hierarchy. During this step these classes are not linked. When a class is going to be linked, then during the link phase all its non linked super classes (if any) are linked from top to bottom in the inheritance tree.
In the JVM dynamic loading and linking is triggered by (constant pool) resolution. When the machine executes an instruction that references a class, _eld or method, it _rst checks whether the referenced class exists in the sense de_ned below. In case it does not, the JVM invokes the loadClass method of the class loader that de_ned the referencing class, to load the referenced class. If loadClass is called for a class that the loader has already loaded, then the method should simply return that class. The system class loader is implemented in that way. A class exists in the name space of a class loader, if the loader is an initiating or de_ning loader for that class.
As a consequence loadClass methods typically perform the following three steps, reecting the programming interface de_ned above.
Alternatively the class loader can delegate the loading to another class loader by invoking the loadClass method of that loader.
JVM Related Interview Questions
|Java Script Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||AJAX Interview Questions|
|Android Interview Questions||Java applet Interview Questions|
|Java 8 Interview Questions||JBOSS Interview Questions|
|Advanced jQuery Interview Questions||Apache Tomcat Interview Questions|
|Application Virtualization Interview Questions||Java 9 Interview Questions|
The Imperative Core Javai Of Java
The Procedural Extension Javac Of Javai
The Object-oriented Extension Javao Of Javac
The Exception-handling Extension Javae Of Javao
The Concurrent Extension Javat Of Javae
Java Is Type Safe
The Jvmi Submachine
The Procedural Extension Jvmc Of Jvmi
The Object-oriented Extension Jvmo Of Jvmc
The Exception-handling Extension Jvme Of Jvmo
Correctness Of The Compiler
The Defensive Virtual Machine
Bytecode Type Assignments
The Diligent Virtual Machine
The Dynamic Virtual Machine
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.