GROUP MEMBERS :-
Byte codes are the machine language of the Java virtual
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
// Bytecode stream: 03 3b 84 00 01 1a 05 68 3b a7 ff f9
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
byte one-byte signed two's
short two-byte signed two's
int 4-byte signed two's
long 8-byte signed two's
float 4-byte IEEE 754 single-
double 8-byte IEEE 754 double-
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
Create source file
Compile source file into .class file
Run the .class file
The Interpreter's are sometimes referred to as the Java Virtual
The output of the
compiler is .class file
Stack-based virtual machine
Small instruction set: 202 instructions (all are 1 byte opcode
Intel x86: ~280 instructions (1 to 17 bytes long!)
Every Java class file begins with magic number 3405691582 =
JVM executes the step-by-step instructions given to it from
JVM is specific to each computer architecture (Linux
JVM, Windows JVM, Mac JVM).
Java Byte code
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 !!!
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.
PC register has the address of a JVM instruction being
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.
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.
A space that stores instances or objects, and is a target of
The bytecode that is assigned to the runtime data
areas in the JVM via class loader is executed by the
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
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.
All types (class and interface) except for primitive data types
are referred to through symbolic reference, instead of through
explicit memory address-based reference.
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
Can think VM as type of
computer. It is not new idea
The JVM is most widely used
Byte code (.class)
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
It is not new idea
The JVM is most widely used
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
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
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