SlideShare a Scribd company logo
2
2
| Article by Subnesh Sharma |
In industry, JVM flavors are distributed by many vendors like Oracle, IBM, HP etc. These all flavors are
following the JVM specification published by Sun/Oracle.
2. JVM Subcomponents
After getting the conceptual understanding of JVM, let focus on its internal architecture:
Virtual machine instance is composed of subsystems, memory areas, data types, and instructions. These
components make an abstract inner architecture for the abstract Java virtual machine. The purpose of these
components is to define the behavior of JVM implementation towards the external resources rather than
implementation of internal architecture.
The specification defines the required behavior of any Java virtual machine implementation in terms of these
abstract components and their interactions.
JVM is composed of two major sub components
1. Execution engine
2. Class Loaders
2.1 Execution engine: it’s responsible for executing the instructions contained in the methods of
loaded classes
2.2 Class Loader: a mechanism for loading types (classes and interfaces) given fully qualified names.
Most read
4
4
| Article by Subnesh Sharma |
Java Stacks automatically gets create when a new thread is generated. These stacks are composed of
multiple stack frames which internally keep local variables and partial results, and play a part in method
invocation and return.
The Java virtual machine can support many threads of execution at once. Each Java virtual machine
thread has its own pc (program counter) register. At any point, each Java virtual machine thread is executing
the code of a single method, the current method for that thread. If that method is not native, the pc register
contains the address of the Java virtual machine instruction currently being executed. If the method currently
being executed by the thread is native, the value of the Java virtual machine's pc register is undefined. The
Java virtual machine's pc register is wide enough to hold a returnAddress or a native pointer on the specific
platform.
Native method stacks are in use when java application is going to interact with some native codes.
These stacks can be used by the implementation of an interpreter for the Java virtual machine's instruction
set in a language such as C and that’s why these conventional stacks are colloquially called "C stacks”.
Apart from these components, there are some more components which are playing magic games for
the execution of java application. These components are given below:
Byte Code Verifier:
The JVM verifies all bytecode before it is executed. Verification process includes the verification of
the magic number which is generated by “javac” compiler at the time of compilation. This
verification consists primarily of three types of checks:
 Branches are always to valid locations
 Data is always initialized and references are always type-safe
 Access to "private" or "package private" data and methods is rigidly controlled.
First two activities happen when verification process is going on where as last activity happens
dynamically.
JIT Compiler:
The simplest tool used to increase the performance of an application is the Just-In-Time (JIT)
compiler. A JIT is a code generator that converts Java bytecode into native machine code. Java programs
invoked with a JIT generally run much faster than when the bytecode is executed by the interpreter. The Java
Hotspot VM removes the need for a JIT compiler in most cases however JIT compiler being used in earlier
releases still.
3. Summary
Understanding of internal architecture of JVM will definitely help to better know the behavior of JVM in
different situations. These details must have revealed hidden facts about JVM and how java based programs
run and get executed. Keep learning!
Most read
1
| Article by Subnesh Sharma |
Java Virtual Machine
This article intends to reveal the most hidden, interesting and knowledgeable things about JVM and
its components. Across the globe, there are multiple articles on JAVA, its API and implementation
but very few literatures are written on JVM. Not many JAVA professional make an attempt to
understand the intricacies of internal working of Java Virtual Machine. So let’s get a deep insight of
JVM and Its components. The agenda of this paper would be:
Agenda:
1. What is JVM?
2. JVM subcomponents
2.1 Execution Engine
2.2 Class Loader
2.3 Method Area
3. Summary
1. What is JVM?
A Java Virtual Machine (JVM) is a self contained operating environment that behaves as if it is a separate
computer. Java applets, for example, run in a JVM that has no access to the host operating system.
JVM uses a virtual machine model (VMM) for the execution of other computer programs and scripts and it
enables a set of computer software programs and data structures to make use of VMM. This model accepts a
form of computer intermediate language commonly referred to as Java bytecode.
According to Oracle (Sun Mircosystems), a JVM definition is “A software ‘execution engine’ that safely and
compatibly executes the byte codes in Java class files on a microprocessor (whether in a computer or in
another electronic device)”.
According to Oracle (Sun Mircosystems), a Virtual Machine definition is “An abstract specification for a
computing device that can be implemented in different ways, in software or hardware. You compile to the
instruction set of a virtual machine much like you'd compile to the instruction set of a microprocessor. The
Java virtual machine consists of a bytecode instruction set, a set of registers, a stack, a garbage-collected
heap, and an area for storing methods.” VM model emulates the physical computer so as to execute the
bytecode.
Java works on WORA: “write once, run anywhere” concept. This is implements though JVM which is a
software for non virtual hardware and for standard operating systems.
JVM comes along with a set of libraries which implement JAVA API’s and constitutes JRE (Java Runtime
Environment). This environment can also be used to compile and execute the code of other language like Ada.
2
| Article by Subnesh Sharma |
In industry, JVM flavors are distributed by many vendors like Oracle, IBM, HP etc. These all flavors are
following the JVM specification published by Sun/Oracle.
2. JVM Subcomponents
After getting the conceptual understanding of JVM, let focus on its internal architecture:
Virtual machine instance is composed of subsystems, memory areas, data types, and instructions. These
components make an abstract inner architecture for the abstract Java virtual machine. The purpose of these
components is to define the behavior of JVM implementation towards the external resources rather than
implementation of internal architecture.
The specification defines the required behavior of any Java virtual machine implementation in terms of these
abstract components and their interactions.
JVM is composed of two major sub components
1. Execution engine
2. Class Loaders
2.1 Execution engine: it’s responsible for executing the instructions contained in the methods of
loaded classes
2.2 Class Loader: a mechanism for loading types (classes and interfaces) given fully qualified names.
3
| Article by Subnesh Sharma |
Class loaders are of two types:
2.2.1 System class loader
2.2.2 Custom Class loader
Following diagram shows the level of class loader
Bootstrap Class Loader is responsible to load all the prerequisites classes and interface to
accomplish the loading activity so as to launch application.
Ext class loader is used to load custom class loader which affects the loading process of all
applications for this JVM. The destination of this jar file is under “JRE_HOME/lib/ext” and it introduces global
customization to loading process.
App class loader is used to load custom class loader for this application only.
Custom Class Loaders are derived from java.lang.ClassLoader class. To load a class use loadClass()
method with appropriate parameters.
2.3 Method Area
JVM architecture consists of run time data area which contains components like method area, heap, method
stacks, thread stack frames, java stacks etc.
Method area is a vital part of run time data area. Inside a Java virtual machine instance, information
about loaded types is stored in a logical area of memory called the method area. When the Java virtual
machine loads a type, it uses a class loader to locate the appropriate class file. The class loader reads in the
class file--a linear stream of binary data--and passes it to the virtual machine. The virtual machine extracts
information about the type from the binary data and stores the information in the method area. Memory for
class (static) variables declared in the class is also taken from the method area.
Heap, again a vital and very important component of run time data area, contains all allocated
objects and references of these objects are kept in Method tables in Method area for JVM use and access.
Bootstrap Class Loader
Ext Class Loader
App Class Loader
4
| Article by Subnesh Sharma |
Java Stacks automatically gets create when a new thread is generated. These stacks are composed of
multiple stack frames which internally keep local variables and partial results, and play a part in method
invocation and return.
The Java virtual machine can support many threads of execution at once. Each Java virtual machine
thread has its own pc (program counter) register. At any point, each Java virtual machine thread is executing
the code of a single method, the current method for that thread. If that method is not native, the pc register
contains the address of the Java virtual machine instruction currently being executed. If the method currently
being executed by the thread is native, the value of the Java virtual machine's pc register is undefined. The
Java virtual machine's pc register is wide enough to hold a returnAddress or a native pointer on the specific
platform.
Native method stacks are in use when java application is going to interact with some native codes.
These stacks can be used by the implementation of an interpreter for the Java virtual machine's instruction
set in a language such as C and that’s why these conventional stacks are colloquially called "C stacks”.
Apart from these components, there are some more components which are playing magic games for
the execution of java application. These components are given below:
Byte Code Verifier:
The JVM verifies all bytecode before it is executed. Verification process includes the verification of
the magic number which is generated by “javac” compiler at the time of compilation. This
verification consists primarily of three types of checks:
 Branches are always to valid locations
 Data is always initialized and references are always type-safe
 Access to "private" or "package private" data and methods is rigidly controlled.
First two activities happen when verification process is going on where as last activity happens
dynamically.
JIT Compiler:
The simplest tool used to increase the performance of an application is the Just-In-Time (JIT)
compiler. A JIT is a code generator that converts Java bytecode into native machine code. Java programs
invoked with a JIT generally run much faster than when the bytecode is executed by the interpreter. The Java
Hotspot VM removes the need for a JIT compiler in most cases however JIT compiler being used in earlier
releases still.
3. Summary
Understanding of internal architecture of JVM will definitely help to better know the behavior of JVM in
different situations. These details must have revealed hidden facts about JVM and how java based programs
run and get executed. Keep learning!
5
| Article by Subnesh Sharma |
Bibliography:
http://www.oracle.com/technetwork/java/index.html
www.artima.com

More Related Content

What's hot (20)

constructors in java ppt
constructors in java pptconstructors in java ppt
constructors in java ppt
kunal kishore
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
BG Java EE Course
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
Madishetty Prathibha
 
Control flow statements in java
Control flow statements in javaControl flow statements in java
Control flow statements in java
yugandhar vadlamudi
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Elizabeth alexander
 
JVM
JVMJVM
JVM
baabtra.com - No. 1 supplier of quality freshers
 
14 file handling
14 file handling14 file handling
14 file handling
APU
 
Exception Handling
Exception HandlingException Handling
Exception Handling
Reddhi Basu
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
Jussi Pohjolainen
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
Abir Mohammad
 
JRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVAJRE , JDK and platform independent nature of JAVA
JRE , JDK and platform independent nature of JAVA
Mehak Tawakley
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Java Lover
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Ram132
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
Jin Castor
 
Java constructors
Java constructorsJava constructors
Java constructors
QUONTRASOLUTIONS
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
Abishek Purushothaman
 
Java applets
Java appletsJava applets
Java applets
Pihu Goel
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
Sandeep Rawat
 
Java Basic Oops Concept
Java Basic Oops ConceptJava Basic Oops Concept
Java Basic Oops Concept
atozknowledge .com
 

Viewers also liked (20)

3. jvm
3. jvm3. jvm
3. jvm
Indu Sharma Bhardwaj
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
Luiz Fernando Teston
 
Third Generation Internet Applications
Third Generation Internet ApplicationsThird Generation Internet Applications
Third Generation Internet Applications
Patrick Koning
 
Perfect Patch
Perfect PatchPerfect Patch
Perfect Patch
Regine Deleu
 
Hands on presentatie
Hands on presentatieHands on presentatie
Hands on presentatie
Jan Vansteenkiste
 
Boekpresentatie (HAN)
Boekpresentatie (HAN)Boekpresentatie (HAN)
Boekpresentatie (HAN)
Patrick Koning
 
AVO-Café
AVO-CaféAVO-Café
AVO-Café
Patrick Koning
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011
Doug Hawkins
 
JVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and ScalaJVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and Scala
Takipi
 
Mediawijsheid 2.0
Mediawijsheid 2.0 Mediawijsheid 2.0
Mediawijsheid 2.0
Patrick Koning
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
National Cheng Kung University
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
Surbhi Panhalkar
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Niko Vuokko
 
Introduction to Data Science and Analytics
Introduction to Data Science and AnalyticsIntroduction to Data Science and Analytics
Introduction to Data Science and Analytics
Srinath Perera
 
Java: Exception
Java: ExceptionJava: Exception
Java: Exception
Tareq Hasan
 
Dessler ch 09-performance management and appraisal
Dessler ch 09-performance management and appraisalDessler ch 09-performance management and appraisal
Dessler ch 09-performance management and appraisal
Shamsil Arefin
 
Introduction on Data Science
Introduction on Data ScienceIntroduction on Data Science
Introduction on Data Science
Edureka!
 
Forms of Business Ownership and Organization
Forms of Business Ownership and OrganizationForms of Business Ownership and Organization
Forms of Business Ownership and Organization
Qamar Farooq
 
HRM Dessler CH# 09
HRM Dessler CH# 09HRM Dessler CH# 09
HRM Dessler CH# 09
Usman Rashid
 
HRM-Chapter1-Introduction to HRM
HRM-Chapter1-Introduction to HRMHRM-Chapter1-Introduction to HRM
HRM-Chapter1-Introduction to HRM
subnesh
 
Third Generation Internet Applications
Third Generation Internet ApplicationsThird Generation Internet Applications
Third Generation Internet Applications
Patrick Koning
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011
Doug Hawkins
 
JVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and ScalaJVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and Scala
Takipi
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Niko Vuokko
 
Introduction to Data Science and Analytics
Introduction to Data Science and AnalyticsIntroduction to Data Science and Analytics
Introduction to Data Science and Analytics
Srinath Perera
 
Dessler ch 09-performance management and appraisal
Dessler ch 09-performance management and appraisalDessler ch 09-performance management and appraisal
Dessler ch 09-performance management and appraisal
Shamsil Arefin
 
Introduction on Data Science
Introduction on Data ScienceIntroduction on Data Science
Introduction on Data Science
Edureka!
 
Forms of Business Ownership and Organization
Forms of Business Ownership and OrganizationForms of Business Ownership and Organization
Forms of Business Ownership and Organization
Qamar Farooq
 
HRM Dessler CH# 09
HRM Dessler CH# 09HRM Dessler CH# 09
HRM Dessler CH# 09
Usman Rashid
 
HRM-Chapter1-Introduction to HRM
HRM-Chapter1-Introduction to HRMHRM-Chapter1-Introduction to HRM
HRM-Chapter1-Introduction to HRM
subnesh
 
Ad

Similar to Java Virtual Machine - Internal Architecture (20)

Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
Nikhil Sharma
 
Basic Java I
Basic Java IBasic Java I
Basic Java I
SSN College of Engineering, Kalavakkam
 
Java JDK.docx
Java JDK.docxJava JDK.docx
Java JDK.docx
Bornali Das
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
Laxman Puri
 
A Brief study on JVM A Brief study on JVM
A Brief study on JVM A Brief study on JVMA Brief study on JVM A Brief study on JVM
A Brief study on JVM A Brief study on JVM
BRNSSPublicationHubI
 
Jvm internal detail
Jvm internal detailJvm internal detail
Jvm internal detail
Mohammad Faizan
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
Rakesh Madugula
 
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Rhythm Suiwal
 
JVM Architecture – How It Works.pdf
JVM Architecture – How It Works.pdfJVM Architecture – How It Works.pdf
JVM Architecture – How It Works.pdf
Geekster
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
ijaprr_editor
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
Umesh Kumar
 
Java Virtual Machine (JVM) and just in time compilation
Java Virtual Machine (JVM) and just in time compilationJava Virtual Machine (JVM) and just in time compilation
Java Virtual Machine (JVM) and just in time compilation
ArunKumarPandey43
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
Shipra Swati
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
Nanthini Kempaiyan
 
JAVA ARCHITECTURES PPT | "Mastering Java: A Comprehensive Guide to Core Conc...
JAVA ARCHITECTURES PPT  | "Mastering Java: A Comprehensive Guide to Core Conc...JAVA ARCHITECTURES PPT  | "Mastering Java: A Comprehensive Guide to Core Conc...
JAVA ARCHITECTURES PPT | "Mastering Java: A Comprehensive Guide to Core Conc...
vishnuprasath2603
 
JAVA ARCHITECTURES PPT | "Mastering Java: A Comprehensive Guide to Core Conc...
JAVA ARCHITECTURES PPT  | "Mastering Java: A Comprehensive Guide to Core Conc...JAVA ARCHITECTURES PPT  | "Mastering Java: A Comprehensive Guide to Core Conc...
JAVA ARCHITECTURES PPT | "Mastering Java: A Comprehensive Guide to Core Conc...
vishnuprasath2603
 
JVM.pptx
JVM.pptxJVM.pptx
JVM.pptx
V.V.Vanniaperumal College for Women
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
Satyam Pandey
 
JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program Examples
Prof Chethan Raj C
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
kumar467
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
Nikhil Sharma
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
Laxman Puri
 
A Brief study on JVM A Brief study on JVM
A Brief study on JVM A Brief study on JVMA Brief study on JVM A Brief study on JVM
A Brief study on JVM A Brief study on JVM
BRNSSPublicationHubI
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
Rakesh Madugula
 
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Introduction of jvm|Java Training In Jaipur | Java Training Jaipur | Java Tra...
Rhythm Suiwal
 
JVM Architecture – How It Works.pdf
JVM Architecture – How It Works.pdfJVM Architecture – How It Works.pdf
JVM Architecture – How It Works.pdf
Geekster
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
ijaprr_editor
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
Umesh Kumar
 
Java Virtual Machine (JVM) and just in time compilation
Java Virtual Machine (JVM) and just in time compilationJava Virtual Machine (JVM) and just in time compilation
Java Virtual Machine (JVM) and just in time compilation
ArunKumarPandey43
 
JAVA ARCHITECTURES PPT | "Mastering Java: A Comprehensive Guide to Core Conc...
JAVA ARCHITECTURES PPT  | "Mastering Java: A Comprehensive Guide to Core Conc...JAVA ARCHITECTURES PPT  | "Mastering Java: A Comprehensive Guide to Core Conc...
JAVA ARCHITECTURES PPT | "Mastering Java: A Comprehensive Guide to Core Conc...
vishnuprasath2603
 
JAVA ARCHITECTURES PPT | "Mastering Java: A Comprehensive Guide to Core Conc...
JAVA ARCHITECTURES PPT  | "Mastering Java: A Comprehensive Guide to Core Conc...JAVA ARCHITECTURES PPT  | "Mastering Java: A Comprehensive Guide to Core Conc...
JAVA ARCHITECTURES PPT | "Mastering Java: A Comprehensive Guide to Core Conc...
vishnuprasath2603
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
kumar467
 
Ad

Recently uploaded (20)

Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven InfrastructureNo-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Ben Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding WorldBen Blair - Operating Safely in a Vibe Coding World
Ben Blair - Operating Safely in a Vibe Coding World
AWS Chicago
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Creating an Accessible Future-How AI-powered Accessibility Testing is Shaping...
Impelsys Inc.
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 

Java Virtual Machine - Internal Architecture

  • 1. 1 | Article by Subnesh Sharma | Java Virtual Machine This article intends to reveal the most hidden, interesting and knowledgeable things about JVM and its components. Across the globe, there are multiple articles on JAVA, its API and implementation but very few literatures are written on JVM. Not many JAVA professional make an attempt to understand the intricacies of internal working of Java Virtual Machine. So let’s get a deep insight of JVM and Its components. The agenda of this paper would be: Agenda: 1. What is JVM? 2. JVM subcomponents 2.1 Execution Engine 2.2 Class Loader 2.3 Method Area 3. Summary 1. What is JVM? A Java Virtual Machine (JVM) is a self contained operating environment that behaves as if it is a separate computer. Java applets, for example, run in a JVM that has no access to the host operating system. JVM uses a virtual machine model (VMM) for the execution of other computer programs and scripts and it enables a set of computer software programs and data structures to make use of VMM. This model accepts a form of computer intermediate language commonly referred to as Java bytecode. According to Oracle (Sun Mircosystems), a JVM definition is “A software ‘execution engine’ that safely and compatibly executes the byte codes in Java class files on a microprocessor (whether in a computer or in another electronic device)”. According to Oracle (Sun Mircosystems), a Virtual Machine definition is “An abstract specification for a computing device that can be implemented in different ways, in software or hardware. You compile to the instruction set of a virtual machine much like you'd compile to the instruction set of a microprocessor. The Java virtual machine consists of a bytecode instruction set, a set of registers, a stack, a garbage-collected heap, and an area for storing methods.” VM model emulates the physical computer so as to execute the bytecode. Java works on WORA: “write once, run anywhere” concept. This is implements though JVM which is a software for non virtual hardware and for standard operating systems. JVM comes along with a set of libraries which implement JAVA API’s and constitutes JRE (Java Runtime Environment). This environment can also be used to compile and execute the code of other language like Ada.
  • 2. 2 | Article by Subnesh Sharma | In industry, JVM flavors are distributed by many vendors like Oracle, IBM, HP etc. These all flavors are following the JVM specification published by Sun/Oracle. 2. JVM Subcomponents After getting the conceptual understanding of JVM, let focus on its internal architecture: Virtual machine instance is composed of subsystems, memory areas, data types, and instructions. These components make an abstract inner architecture for the abstract Java virtual machine. The purpose of these components is to define the behavior of JVM implementation towards the external resources rather than implementation of internal architecture. The specification defines the required behavior of any Java virtual machine implementation in terms of these abstract components and their interactions. JVM is composed of two major sub components 1. Execution engine 2. Class Loaders 2.1 Execution engine: it’s responsible for executing the instructions contained in the methods of loaded classes 2.2 Class Loader: a mechanism for loading types (classes and interfaces) given fully qualified names.
  • 3. 3 | Article by Subnesh Sharma | Class loaders are of two types: 2.2.1 System class loader 2.2.2 Custom Class loader Following diagram shows the level of class loader Bootstrap Class Loader is responsible to load all the prerequisites classes and interface to accomplish the loading activity so as to launch application. Ext class loader is used to load custom class loader which affects the loading process of all applications for this JVM. The destination of this jar file is under “JRE_HOME/lib/ext” and it introduces global customization to loading process. App class loader is used to load custom class loader for this application only. Custom Class Loaders are derived from java.lang.ClassLoader class. To load a class use loadClass() method with appropriate parameters. 2.3 Method Area JVM architecture consists of run time data area which contains components like method area, heap, method stacks, thread stack frames, java stacks etc. Method area is a vital part of run time data area. Inside a Java virtual machine instance, information about loaded types is stored in a logical area of memory called the method area. When the Java virtual machine loads a type, it uses a class loader to locate the appropriate class file. The class loader reads in the class file--a linear stream of binary data--and passes it to the virtual machine. The virtual machine extracts information about the type from the binary data and stores the information in the method area. Memory for class (static) variables declared in the class is also taken from the method area. Heap, again a vital and very important component of run time data area, contains all allocated objects and references of these objects are kept in Method tables in Method area for JVM use and access. Bootstrap Class Loader Ext Class Loader App Class Loader
  • 4. 4 | Article by Subnesh Sharma | Java Stacks automatically gets create when a new thread is generated. These stacks are composed of multiple stack frames which internally keep local variables and partial results, and play a part in method invocation and return. The Java virtual machine can support many threads of execution at once. Each Java virtual machine thread has its own pc (program counter) register. At any point, each Java virtual machine thread is executing the code of a single method, the current method for that thread. If that method is not native, the pc register contains the address of the Java virtual machine instruction currently being executed. If the method currently being executed by the thread is native, the value of the Java virtual machine's pc register is undefined. The Java virtual machine's pc register is wide enough to hold a returnAddress or a native pointer on the specific platform. Native method stacks are in use when java application is going to interact with some native codes. These stacks can be used by the implementation of an interpreter for the Java virtual machine's instruction set in a language such as C and that’s why these conventional stacks are colloquially called "C stacks”. Apart from these components, there are some more components which are playing magic games for the execution of java application. These components are given below: Byte Code Verifier: The JVM verifies all bytecode before it is executed. Verification process includes the verification of the magic number which is generated by “javac” compiler at the time of compilation. This verification consists primarily of three types of checks:  Branches are always to valid locations  Data is always initialized and references are always type-safe  Access to "private" or "package private" data and methods is rigidly controlled. First two activities happen when verification process is going on where as last activity happens dynamically. JIT Compiler: The simplest tool used to increase the performance of an application is the Just-In-Time (JIT) compiler. A JIT is a code generator that converts Java bytecode into native machine code. Java programs invoked with a JIT generally run much faster than when the bytecode is executed by the interpreter. The Java Hotspot VM removes the need for a JIT compiler in most cases however JIT compiler being used in earlier releases still. 3. Summary Understanding of internal architecture of JVM will definitely help to better know the behavior of JVM in different situations. These details must have revealed hidden facts about JVM and how java based programs run and get executed. Keep learning!
  • 5. 5 | Article by Subnesh Sharma | Bibliography: http://www.oracle.com/technetwork/java/index.html www.artima.com