Java virtual machine

Post on 17-Feb-2017

52 views 0 download

Transcript of Java virtual machine

By: Nikhil Sharma.

JAVA VIRTUAL MACHINE(JVM)

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

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

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

BIG PICTURE OF JAVA

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”

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

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

WHAT JVM DOES

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

INTERNAL ARCHITECTURE OF JVM

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.

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.

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.

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.

DATA TYPES OF JVM

STORAGE & COMPUTATION TYPE INSIDE THE JVM

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.

EXAMPLE OF GARBAGE COLLECTOR

OUTPUT OF ABOVE CODING

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

WHAT IS JRE

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

WHAT IS JDK

RELATION AMONG JVM, JDK & JRE.

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