After compilation of java program by the compiler, the code turns into a respective .class file that contains Java bytecode. The file and the resources are then loaded onto JRE using Classloader.
In the classloader Subsystem there consists of three stages:-
1) Loading
2) Linking
3) Initialization
There are three kinds of loaders. Any program requires these three loaders to execute.
Bootstrap Classloader: It loads classes or packages that are essential for a program that resides in rt.jar file such as Java.lang.object, Java.lang.Thread etc.
Extension Classloader: It loads classes from installed optional packages and jar files that are required by JVM for the further processing program which resides within $JRE_HOME/lib/ext directory.
Application Classloader: It loads classes from the application path and this path can be set by using -cp. It is also known as system class loader.
It is responsible for verifying and preparing class or interface, however, the resolution is an optional process in linking. Class get loaded before linking and after that verified and prepared before initialization.
It has three steps:
1)Verification:- It checks whether a class or interface up to the JVM’S structural constraints or not. if not then it would throw VerifyError exception.
2) Preparation:- It initializes the instance variables of the class to its default value.
3) Resolution: It determines the actual value from symbolic references ( references of variables and methods are stored in class’s constant pool) in runtime constant pool, dynamically.
It invokes the class’s static initialization methods to initialize the static variable. It also initializes the class reference if it’s not initialized yet.
It comprised of all the memories which are going to be used by JVM in order to execute a program. Out of these memories, some of them are created when JVM starts up and diminished when it ends up its execution.
It is responsible for executing the bytecode. It has three subparts, these are:
Interpreter: It interprets bytecodes line by line and converts the bytecode to the machine understandable language.
Jit-compiler: Just-in-compiler comes into play when a single code inn program appears and executes multiple times. What it does is, it precompiles that particular piece of code and improves the performance by reducing the execution time.
Garbage collector: It cleans up the objects created by using new keyword which are not being used in heap memory area.
There may be situation where a programmer cannot writes his application entirely on Java language. In this situation, Java native Interface can be used as it provides a way where native applications can communicate with JAVA application
This post was last modified on June 5, 2021