Java virtual machine

24
By: Nikhil Sharma. JAVA VIRTUAL MACHINE(JVM)

Transcript of Java virtual machine

Page 1: Java virtual machine

By: Nikhil Sharma.

JAVA VIRTUAL MACHINE(JVM)

Page 2: Java virtual machine

Java Platform.Editions of Java.Big Picture of Java.Java “Fanboi”.What is JVM.What JVM does.Internal Architecture

of JVM.

Data Types of JVM.Garbage Collection.What is JDK & JRE.Relation among JVM,

JDK & JRE.Security Promises of

JVM.

INDEX

Page 3: Java virtual machine

Java Platform is a suite of programs that facilitate developing & running programs written in java programming language.

The platform is not specific to any processor or Operating System.

There are multiple platforms each targeting a different class of devices.

JAVA PLATFORM

Page 4: Java virtual machine

Java SE: It is the Java Standard Edition that contains basic core java classes.

Java EE: It is the Java Enterprise Edition & it contain classes that are beyond Java SE.

Java ME: It stands for Java Micro Edition for developing codes for portable devices.

EDITIONS OF JAVA

Page 5: Java virtual machine

BIG PICTURE OF JAVA

Page 6: Java virtual machine

Speaking of Java as a language as opposed to the JVM platform, James Gosling, the Father of Java, said "Most people talk about Java the language, and this may sound odd coming from me, but I could hardly care less."

He went on to explain, "What I really care about is the Java Virtual Machine as a concept, because that is the thing that ties it all together."

JVM “FANBOI”

Page 7: Java virtual machine

Java Virtual Machine is the heart of entire Java program execution process.

It’s an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.

JVM is platform dependent.It is responsible for taking .class file &

converting each byte code instructions into the machine language instruction that can be executed by the microprocessor.

WHAT IS JVM

Page 8: Java virtual machine

The JVM performs following operation—Loads code.Verifies code.Executes code.Provides Runtime Environment.

WHAT JVM DOES

Page 9: Java virtual machine

First of all, it loads .class file into memory.Then it verifies whether all byte code

instructions are proper or not. If it finds any instruction suspicious, the execution is rejected immediately.

If the byte instructions are proper, then it allocates necessary memory to execute the program.

STEPS UNDERTAKEN

Page 10: Java virtual machine

INTERNAL ARCHITECTURE OF JVM

Page 11: Java virtual machine

Classloader: Classloader is a subsystem of JVM that is used to load class files.

Method Area: Method area is the memory block, which stores the class code, code of the variables, and code of the method in java programs.

Heap: It is the runtime data area in which objects are allocated.

CONTD.

Page 12: Java virtual machine

Java Stacks: Java stacks are memory area where the java methods are executed. While executing methods, a separate frame will be created in the java stack, where the method is executed. JVM uses separate threads(or process) to execute each methods.

PC Registers: These are memory areas which contains memory address of instructions of the methods.

CONTD.

Page 13: Java virtual machine

Native Method Stacks: It contains all the native methods used in the applications. Native methods are executed in these stacks.

Native Method Interface/Libraries : To execute the native methods, generally native method libraries are required. These header files are located & connected to JVM by a program, called Native method interface.

CONTD.

Page 14: Java virtual machine

Execution Engine: Execution engine contains—i. Interpreter.

ii. JIT(Just In Time) complier. these are responsible for converting the byte code instructions into machine code so that the processor will execute them.

CONTD.

Page 15: Java virtual machine

DATA TYPES OF JVM

Page 16: Java virtual machine

STORAGE & COMPUTATION TYPE INSIDE THE JVM

Page 17: Java virtual machine

Each object consumes some memory, of which all there is a limited area. Eventually, the memory allocated to these objects must be reclaimed when they aren’t used. The JVM reclaims these objects automatically through a process called Garbage collection.

An object is ready to be garbage collected when it is no longer alive.

Garbage collector uses many algorithm but the most commonly used algorithm is mark & sweep.

GARBAGE COLLECTION.

Page 18: Java virtual machine

EXAMPLE OF GARBAGE COLLECTOR

Page 19: Java virtual machine

OUTPUT OF ABOVE CODING

Page 20: Java virtual machine

JRE is an acronym for Java Runtime Environment. It is used to provide runtime environment. It is the implementation of JVM.

WHAT IS JRE

Page 21: Java virtual machine

JDK is an acronym for Java Development Kit. It physically exists. It contains JRE + development tools.

WHAT IS JDK

Page 22: Java virtual machine

RELATION AMONG JVM, JDK & JRE.

Page 23: Java virtual machine

Every object is constructed exactly once before it is used.

Every local variable & field is initialized before it is used.

Final methods cannot be overridden, & final classes cannot be sub classed.

Many More..The java platform security architecture depends on all the promises & many more..

SECURITY PROMISES OF JVM

Page 24: Java virtual machine