SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

QSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and JitQSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and Jit
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
Java package
Java packageJava package
Java package
 
JVM
JVMJVM
JVM
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Java program structure
Java program structureJava program structure
Java program structure
 
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
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Types of Drivers in JDBC
Types of Drivers in JDBCTypes of Drivers in JDBC
Types of Drivers in JDBC
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Static keyword ppt
Static keyword pptStatic keyword ppt
Static keyword ppt
 
Java and its features
Java and its featuresJava and its features
Java and its features
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 

Similar a 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
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machineNikhil Sharma
 
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
 

Similar a 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
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Java notes
Java notesJava notes
Java notes
 
Javanotes ww8
Javanotes ww8Javanotes ww8
Javanotes ww8
 
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
 

Más de 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
 

Más de 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
 

Último

Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 

Último (20)

Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 

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.