SlideShare ist ein Scribd-Unternehmen logo
1 von 27
GROUP MEMBERS :-
07. ANKITA
14. ASHUTOSH
18. SHAMIKSHA
19. LAXMAN
JAVA BYTECODE
 Byte codes are the machine language of the Java virtual
machine.
 When a JVM loads a class file, it gets one stream of
byte codes for each method in the class.
 The byte codes streams are stored in the method area
of the JVM.
 Byte code, also known as p-code (portable code), is a
form of instruction set designed for efficient execution by
a software interpreter.
 A method's byte code stream is a sequence of instructions
for the Java virtual machine.
 Each instruction consists of a one-byte op code followed
by zero or more operands.
 The op code indicates the action to take. If more
information is required before the JVM can take the
action, that information is encoded into one or more
operands that immediately follow the opcode.
 Each type of opcode has a mnemonic. In the typical assembly
language style, streams of Java bytecodes can be represented by
their mnemonics followed by any operand values. For
example, the following stream of bytecodes can be disassembled
into mnemonics:
 // Bytecode stream: 03 3b 84 00 01 1a 05 68 3b a7 ff f9
Disassembly:
 iconst_0 // 03
 istore_0 // 3b
 iinc 0, 1 // 84 00 01
 iload_0 // 1a
 iconst_2 // 05
 imul // 68
 istore_0 // 3b
 goto -7 // a7 ff f9
 The seven primitive types are listed in the following
table:
TYPE DFEFINITION
byte one-byte signed two's
complement integer.
short two-byte signed two's
complement integer.
int 4-byte signed two's
complement integer.
long 8-byte signed two's
complement integer.
float 4-byte IEEE 754 single-
precision float.
double 8-byte IEEE 754 double-
precision float.
EXAMPLES ActionScript executes in the ActionScript Virtual
Machine (AVM), which is part of Flash Player and AIR.
 Adobe Flash objects.
 Byte Code Engineering Library.
 C to Java Virtual Machine compilers.
 Icon and Unicon programming languages
 Infocom used the Z-machine to make its software
applications more portable.
What is in a .class file?
 Java class file is a file (with the .class extension)
containing a Java byte code which can be executed on
the Java Virtual Machine (JVM). Java class file is
produced by Java compiler from Java programming
language source files (.java files) containing
Java classes. If a source file has more than one class,
each class is compiled into a separate class file
 In Short,
 Create source file
 Compile source file into .class file
 Run the .class file
8
The Interpreter's are sometimes referred to as the Java Virtual
Machines
The output of the
compiler is .class file
 Stack-based virtual machine
 Small instruction set: 202 instructions (all are 1 byte opcode
+ operands)
 Intel x86: ~280 instructions (1 to 17 bytes long!)
 Every Java class file begins with magic number 3405691582 =
0xCAFEBABE
 JVM executes the step-by-step instructions given to it from
the bytecode
 JVM is specific to each computer architecture (Linux
JVM, Windows JVM, Mac JVM).
Java Byte code
Example :
 1 + 2
 1 2 +
PUSH 1
PUSH 2
ADD
3
+
1 2
 1 + 2
 1 2 +
ICONST_1
ICONST_2
IADD
3
+
1 2
JAVA JAVAP TOOL
 The javap tool disassembles compiled Java™ files and
prints out a representation of the Java program. This
may be helpful when the original source code is no
longer available on a system.
 Link to refer about javap !!!
http://docs.oracle.com/javase/7/docs/technotes/to
ols/windows/javap.html
Execution Environment
 Oracle's Java execution environment is termed the Java
Runtime Environment, or JRE.
 The execution environment section is used to maintain
the operations of the stack itself. It is pointed to by
the frame register.
 The JVM runtime
executes .class or .jar files, emulating the
JVM instruction set by interpreting it or using a just-in-
time compiler (JIT) such as Oracle's HotSpot.
Runtime Data Areas
 PC register:
PC register has the address of a JVM instruction being
executed now.
 JVM stack:
One JVM stack exists for one thread, and is created
when the thread starts. It is a stack that saves the
struct (Stack Frame).
 Native method stack:
A stack for native code written in a language other than Java.
 Method area:
It stores runtime constant pool, field and method
information, static variable, and method byte code for each of
the classes and interfaces read by the JVM.
 Runtime constant pool:
This area is included in the method area; however, it plays the
most core role in JVM operation. Therefore, the JVM
specification separately describes its importance. As well as the
constant of each class and interface, it contains all references for
methods and fields.
 Heap:
A space that stores instances or objects, and is a target of
garbage collection.
Runtime data areas shared among
all threads.
Runtime data areas exclusive to
each thread.
Execution Engine
 The bytecode that is assigned to the runtime data
areas in the JVM via class loader is executed by the
execution engine.
 The execution engine reads the Java Bytecode in the
unit of instruction.
 The execution engine gets one OpCode and execute
task with the Operand, and then executes the next
OpCode.
Features of JVM
 Stack-based virtual machine:
The most popular computer architectures such as Intel x86
Architecture and ARM Architecture run based on a register.
 Symbolic reference:
All types (class and interface) except for primitive data types
are referred to through symbolic reference, instead of through
explicit memory address-based reference.
 Garbage collection:
A class instance is explicitly created by the user code
 Guarantees platform independence by clearly
defining the primitive data type:
A traditional language such as C/C++ has different int
type size according to platform.
 Network byte order:
The Java class file uses the network byte order.
What is VM ?
 The purpose of VM is to
abstract the details of the
hardware or the operating
system and to let a program
execute as same way on any
operating system.
 Can think VM as type of
computer. It is not new idea
 The JVM is most widely used
machine
Source code
VM compiler
VM code
VM interpreter
Executable code
Java code(.java)
Javac compiler
Byte code (.class)
Windows
JVM
Linux
JVM
Mac
JVM
Windows Linu
x
Mac
What is VM as it applies to JAVA?
 A very large installed base,
this computer is efficient,
dynamic and net aware.
 A JVM facilitates Write-
Once, Run-Run Anywhere
(WORA)
 It is not new idea
 The JVM is most widely used
machine
JVM Architecture
JVM has various sub components internally.
1. Class loader sub system: JVM's class loader sub system performs 3 tasks
a. It loads .class file into memory.
b. It verifies byte code instructions.
c. It allots memory required for the program.
2. Run time data area: This is the memory resource used by JVM and it is divided into 5
part
a. Method area: Method area stores class code and method code.
b. Heap: Objects are created on heap.
c. Java stacks: Java stacks are the places where the Java methods are executed. A Java
stack contains frames. On each frame, a separate method is executed.
d. Program counter registers: The program counter registers store memory
address of the instruction to be executed by the micro processor.
e. Native method stacks: The native method stacks are places where native
methods (for example, C language programs) are executed. Native method is a function,
which is written in another language other than Java.
3. Native method interface: Native method
interface is a program that connects native
methods libraries (C header files) with JVM for
executing native methods.
4. Native method library: holds the native
libraries information.
5. Execution engine: Execution engine
contains interpreter and JIT compiler, which
covert byte code into machine code. JVM uses
optimization technique to decide which part to
be interpreted and which part to be used with
JIT compiler.
Java byte code & virtual machine

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Java string handling
Java string handlingJava string handling
Java string handling
 
Java threads
Java threadsJava threads
Java threads
 
Core Java
Core JavaCore Java
Core Java
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
core java
core javacore java
core java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Jdk,jre,jvm
Jdk,jre,jvmJdk,jre,jvm
Jdk,jre,jvm
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
garbage collector
garbage collectorgarbage collector
garbage collector
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
 
OOP java
OOP javaOOP java
OOP java
 
Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java
 
Byte code jvm
Byte code jvmByte code jvm
Byte code jvm
 

Ähnlich wie Java byte code & virtual machine

Java Virtual Machine - Internal Architecture
Java Virtual Machine - Internal ArchitectureJava Virtual Machine - Internal Architecture
Java Virtual Machine - Internal Architecturesubnesh
 
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
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderijaprr_editor
 
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 StartedRakesh Madugula
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeOmar Bashir
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to JavaAnkita Totala
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8kumar467
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core javaWE-IT TUTORIALS
 
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 JVMBRNSSPublicationHubI
 
Advanced java training in bangalore
Advanced java training in bangaloreAdvanced java training in bangalore
Advanced java training in bangaloresiyaram ray
 
Advanced java-training-in-bangalore
Advanced java-training-in-bangaloreAdvanced java-training-in-bangalore
Advanced java-training-in-bangaloresiyaram ray
 

Ähnlich wie Java byte code & virtual machine (20)

Basic Java I
Basic Java IBasic Java I
Basic Java I
 
Java Virtual Machine - Internal Architecture
Java Virtual Machine - Internal ArchitectureJava Virtual Machine - Internal Architecture
Java Virtual Machine - Internal Architecture
 
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...
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
Java JDK.docx
Java JDK.docxJava JDK.docx
Java JDK.docx
 
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
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
 
Java notes
Java notesJava notes
Java notes
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
 
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
 
About java
About javaAbout java
About java
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Advanced java training in bangalore
Advanced java training in bangaloreAdvanced java training in bangalore
Advanced java training in bangalore
 
Advanced java-training-in-bangalore
Advanced java-training-in-bangaloreAdvanced java-training-in-bangalore
Advanced java-training-in-bangalore
 
Java basic
Java basicJava basic
Java basic
 

Mehr von Laxman Puri

Remote access from a smartphone ppt
Remote access from a smartphone pptRemote access from a smartphone ppt
Remote access from a smartphone pptLaxman Puri
 
Co relation between dfd & event table
Co relation between dfd & event tableCo relation between dfd & event table
Co relation between dfd & event tableLaxman Puri
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming LanguageLaxman Puri
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++Laxman Puri
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer GraphicsLaxman Puri
 

Mehr von Laxman Puri (7)

Remote access from a smartphone ppt
Remote access from a smartphone pptRemote access from a smartphone ppt
Remote access from a smartphone ppt
 
Processors
ProcessorsProcessors
Processors
 
Dbms rlde.ppt
Dbms rlde.pptDbms rlde.ppt
Dbms rlde.ppt
 
Co relation between dfd & event table
Co relation between dfd & event tableCo relation between dfd & event table
Co relation between dfd & event table
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 

Kürzlich hochgeladen

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 

Kürzlich hochgeladen (20)

Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 

Java byte code & virtual machine

  • 1. GROUP MEMBERS :- 07. ANKITA 14. ASHUTOSH 18. SHAMIKSHA 19. LAXMAN
  • 2. JAVA BYTECODE  Byte codes are the machine language of the Java virtual machine.  When a JVM loads a class file, it gets one stream of byte codes for each method in the class.  The byte codes streams are stored in the method area of the JVM.
  • 3.  Byte code, also known as p-code (portable code), is a form of instruction set designed for efficient execution by a software interpreter.  A method's byte code stream is a sequence of instructions for the Java virtual machine.  Each instruction consists of a one-byte op code followed by zero or more operands.  The op code indicates the action to take. If more information is required before the JVM can take the action, that information is encoded into one or more operands that immediately follow the opcode.
  • 4.  Each type of opcode has a mnemonic. In the typical assembly language style, streams of Java bytecodes can be represented by their mnemonics followed by any operand values. For example, the following stream of bytecodes can be disassembled into mnemonics:  // Bytecode stream: 03 3b 84 00 01 1a 05 68 3b a7 ff f9 Disassembly:  iconst_0 // 03  istore_0 // 3b  iinc 0, 1 // 84 00 01  iload_0 // 1a  iconst_2 // 05  imul // 68  istore_0 // 3b  goto -7 // a7 ff f9
  • 5.  The seven primitive types are listed in the following table: TYPE DFEFINITION byte one-byte signed two's complement integer. short two-byte signed two's complement integer. int 4-byte signed two's complement integer. long 8-byte signed two's complement integer. float 4-byte IEEE 754 single- precision float. double 8-byte IEEE 754 double- precision float.
  • 6. EXAMPLES ActionScript executes in the ActionScript Virtual Machine (AVM), which is part of Flash Player and AIR.  Adobe Flash objects.  Byte Code Engineering Library.  C to Java Virtual Machine compilers.  Icon and Unicon programming languages  Infocom used the Z-machine to make its software applications more portable.
  • 7. What is in a .class file?  Java class file is a file (with the .class extension) containing a Java byte code which can be executed on the Java Virtual Machine (JVM). Java class file is produced by Java compiler from Java programming language source files (.java files) containing Java classes. If a source file has more than one class, each class is compiled into a separate class file  In Short,  Create source file  Compile source file into .class file  Run the .class file
  • 8. 8 The Interpreter's are sometimes referred to as the Java Virtual Machines The output of the compiler is .class file
  • 9.  Stack-based virtual machine  Small instruction set: 202 instructions (all are 1 byte opcode + operands)  Intel x86: ~280 instructions (1 to 17 bytes long!)  Every Java class file begins with magic number 3405691582 = 0xCAFEBABE  JVM executes the step-by-step instructions given to it from the bytecode  JVM is specific to each computer architecture (Linux JVM, Windows JVM, Mac JVM). Java Byte code
  • 10. Example :  1 + 2  1 2 + PUSH 1 PUSH 2 ADD 3 + 1 2
  • 11.  1 + 2  1 2 + ICONST_1 ICONST_2 IADD 3 + 1 2
  • 12. JAVA JAVAP TOOL  The javap tool disassembles compiled Java™ files and prints out a representation of the Java program. This may be helpful when the original source code is no longer available on a system.  Link to refer about javap !!! http://docs.oracle.com/javase/7/docs/technotes/to ols/windows/javap.html
  • 13. Execution Environment  Oracle's Java execution environment is termed the Java Runtime Environment, or JRE.  The execution environment section is used to maintain the operations of the stack itself. It is pointed to by the frame register.  The JVM runtime executes .class or .jar files, emulating the JVM instruction set by interpreting it or using a just-in- time compiler (JIT) such as Oracle's HotSpot.
  • 15.  PC register: PC register has the address of a JVM instruction being executed now.  JVM stack: One JVM stack exists for one thread, and is created when the thread starts. It is a stack that saves the struct (Stack Frame).
  • 16.  Native method stack: A stack for native code written in a language other than Java.  Method area: It stores runtime constant pool, field and method information, static variable, and method byte code for each of the classes and interfaces read by the JVM.  Runtime constant pool: This area is included in the method area; however, it plays the most core role in JVM operation. Therefore, the JVM specification separately describes its importance. As well as the constant of each class and interface, it contains all references for methods and fields.  Heap: A space that stores instances or objects, and is a target of garbage collection.
  • 17. Runtime data areas shared among all threads.
  • 18. Runtime data areas exclusive to each thread.
  • 19. Execution Engine  The bytecode that is assigned to the runtime data areas in the JVM via class loader is executed by the execution engine.  The execution engine reads the Java Bytecode in the unit of instruction.  The execution engine gets one OpCode and execute task with the Operand, and then executes the next OpCode.
  • 20. Features of JVM  Stack-based virtual machine: The most popular computer architectures such as Intel x86 Architecture and ARM Architecture run based on a register.  Symbolic reference: All types (class and interface) except for primitive data types are referred to through symbolic reference, instead of through explicit memory address-based reference.  Garbage collection: A class instance is explicitly created by the user code
  • 21.  Guarantees platform independence by clearly defining the primitive data type: A traditional language such as C/C++ has different int type size according to platform.  Network byte order: The Java class file uses the network byte order.
  • 22. What is VM ?  The purpose of VM is to abstract the details of the hardware or the operating system and to let a program execute as same way on any operating system.  Can think VM as type of computer. It is not new idea  The JVM is most widely used machine Source code VM compiler VM code VM interpreter Executable code
  • 23. Java code(.java) Javac compiler Byte code (.class) Windows JVM Linux JVM Mac JVM Windows Linu x Mac What is VM as it applies to JAVA?  A very large installed base, this computer is efficient, dynamic and net aware.  A JVM facilitates Write- Once, Run-Run Anywhere (WORA)  It is not new idea  The JVM is most widely used machine
  • 25. JVM has various sub components internally. 1. Class loader sub system: JVM's class loader sub system performs 3 tasks a. It loads .class file into memory. b. It verifies byte code instructions. c. It allots memory required for the program. 2. Run time data area: This is the memory resource used by JVM and it is divided into 5 part a. Method area: Method area stores class code and method code. b. Heap: Objects are created on heap. c. Java stacks: Java stacks are the places where the Java methods are executed. A Java stack contains frames. On each frame, a separate method is executed. d. Program counter registers: The program counter registers store memory address of the instruction to be executed by the micro processor. e. Native method stacks: The native method stacks are places where native methods (for example, C language programs) are executed. Native method is a function, which is written in another language other than Java.
  • 26. 3. Native method interface: Native method interface is a program that connects native methods libraries (C header files) with JVM for executing native methods. 4. Native method library: holds the native libraries information. 5. Execution engine: Execution engine contains interpreter and JIT compiler, which covert byte code into machine code. JVM uses optimization technique to decide which part to be interpreted and which part to be used with JIT compiler.