Java Virtual Machine http://inbravo.github.io/html/jvm.html Complete subject details are available at: http://inbravo.github.io/html/jvm.html.

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
Java security (in a nutshell)
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
1 1 Lecture 14 Java Virtual Machine Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
JAVA Processors and JIT Scheduling. Overview & Literature n Formulation of the problem n JAVA introduction n Description of Caffeine * Literature: “Java.
Lab#1 (14/3/1431h) Introduction To java programming cs425
JVM-1 Java Virtual Machine Reading Assignment: Chapter 1: All Chapter 3: Sections.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Chapter 16 Java Virtual Machine. To compile a java program in Simple.java, enter javac Simple.java javac outputs Simple.class, a file that contains bytecode.
Unit 061 Java Virtual Machine (JVM) What is Java Virtual Machine? The Class Loader Subsystem Linking oVerification oPreparation oResolution Class Initialization.
1 Further OO Concepts II – Java Program at run-time Overview l Steps in Executing a Java Program. l Loading l Linking l Initialization l Creation of Objects.
1 Memory Model of A Program, Methods Overview l Memory Model of JVM »Method Area »Heap »Stack.
1 Software Testing and Quality Assurance Lecture 31 – SWE 205 Course Objective: Basics of Programming Languages & Software Construction Techniques.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
Java Security Updated May Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security.
Intro to Java The Java Virtual Machine. What is the JVM  a software emulation of a hypothetical computing machine that runs Java bytecodes (Java compiler.
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
1 The Java Virtual Machine Yearly Programming Project.
Implement High-level Program Language on JVM CSCE 531 ZHONGHAO LIU ZHONGHAO LIU XIAO LIN.
Lecture 10 : Introduction to Java Virtual Machine
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
10/12/2015© Hal Perkins & UW CSEV-1 CSE P 501 – Compilers Java Implementation – JVMs, JITs &c Hal Perkins Winter 2008.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
1 Introduction to JVM Based on material produced by Bill Venners.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Java 2 security model Valentina Casola. Components of Java the development environment –development lifecycle –Java language features –class files and.
Java Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007.
12/10/2002© 2002 Hal Perkins & UW CSET-1 CSE 582 – Compilers Java Implementation – JVMs, JITs &c Hal Perkins Autumn 2002.
Copyright © Mohamed Nuzrath Java Programming :: Syllabus & Chapters :: Prepared & Presented By :: Mohamed Nuzrath [ Major In Programming ] NCC Programme.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Object Oriented Software Development 4. C# data types, objects and references.
Programming Languages and Paradigms Activation Records in Java.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
RealTimeSystems Lab Jong-Koo, Lim
Memory Management in Java Mr. Gerb Computer Science 4.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Lecture 3 Translation.
Object Oriented Programming in
Instructions for test_function
JAVA MULTIPLE CHOICE QUESTION.
Intro to ETEC Java.
The Java Virtual Machine (JVM)
Internet and Java Foundations, Programming and Practice
Java security (in a nutshell)
Java package classes Java package classes.
Java Review Hello..This ppt is to give you an introduction about java and why it is soo special The segments all discussed here are the crucial parts of.
Java programming lecture one
Introduction Enosis Learning.
2.1. Compilers and Interpreters
Introduction Enosis Learning.
CSC 253 Lecture 8.
CSC 253 Lecture 8.
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Sridhar Narayan Java Basics Sridhar Narayan
Java for IOI.
Java Implementation – JVMs, JITs &c Hal Perkins Summer 2004
(Computer fundamental Lab)
How Java Program Executes
M S COLLEGE ART’S, COMM., SCI. & BMS
JIT Compiler Design Maxine Virtual Machine Dhwani Pandya
Run-time environments
Presentation transcript:

Java Virtual Machine http://inbravo.github.io/html/jvm.html Complete subject details are available at: http://inbravo.github.io/html/jvm.html

Class file structure

Lets run a java class with –verbose Java –verbose Anagram

Class loader sub system Loading (BEA) Boot strap class Loader – load classes from rt.jar Extension class Loader – load classes from jre\lib\ext folder Application class Loader –load path mentioned environment variable etc. Linking (VPR) Verify – verify generated byte code, if fails generate verification error Prepare – static variables memory will be allocated and assigned with default values Resolve – symbolic references replaced by original references from Method Area. Initialization here all static variables will be assigned and static block will be executed

JVM architecture Interpreter – Interpreter interprets the byte code faster but executes slowly. JIT compiler neutralizes the disadvantage of the interpreter, when it found repeated code it uses JIT compiler JIT compiles the entire bytecode and change it to native code. Garbage collector Java Native Interface

Runtime data areas Method Area Class level data will be stored here. Method Area is one per JVM Heap Objects and its corresponding instance variables and arrays will be stored here. Heap Area is one per JVM Stack Runtime stack for each thread. One stack frame for every method call PC Registers – holds address of current executing instruction  Native stack – holds native method info

Heap

JDK byte code dissembler JDK/bin/javap -c Anagram Javap looks boring  lets use another tool byte code viewer to do make it interesting  For more details on ‘javap’ refer https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javap.html

Jvisualvm Available since JDK 7 Java process id based analysis and thread dump analysis Provided with JDK but can be downloaded from https://visualvm.java.net/download.html Can be integrated with Eclipse IDE

Primitive variable sizing Int: 32-bit long: 64-bit float: 32-bit double: 64-bit boolean, char, byte, short: 32 bit Test class : https://github.com/inbravo/java-src/blob/master/src/com/inbravo/memory/PrimitiveVarsSizeTest.java

Object sizing Size of java.lang.Integer Size of int array Class pointer: A pointer to the class information, which describes the object type. In the case of a java.lang.Integer object, for example, this is a pointer to the java.lang.Integer class Flags : A collection of flags that describe the state of the object, including the hash code for the object if it has one, and the shape of the object (that is, whether or not the object is an array). Lock : The synchronization information for the object Total Object Memory: [OBJECT META INFO] + [OBJECT DATA] [OBJECT META DATA]: [CLASS INFO = 4 bytes] + [FLAGS = 4 bytes] + [LOCK INFO = 4 bytes] Total Object Memory: [12 bytes] + [OBJECT DATA]

JVM Source code http://hg.openjdk.java.net/jdk8/jdk8/hotspot

JVM options Option types: Standard(-), Non-standard(-X), Developer (-XX) Option: -XX:+PrintFlagsFinal lists all flags available Option types: Behavioural options Garbage Collection options Performance tuning options Debugging options

JVM options

JVM options

JVM options

References Topic details : http://inbravo.github.io/html/jvm.html Examples: Anagram.java : https://github.com/inbravo/java-src/blob/master/src/com/inbravo/string/Anagram.java PrimitiveVarsSizeTest.java: https://github.com/inbravo/java-src/blob/master/src/com/inbravo/memory/PrimitiveVarsSizeTest.java Byte code instructions: https://en.wikipedia.org/wiki/Java_bytecode_instruction_listings Byte code viewer tool: http://bytecodeviewer.com Hex editor: https://mh-nexus.de/en/hxd Jvisualvm: https://visualvm.java.net/download.html

Whacky questions  Why should I learn about byte code? Why should I know Jvisualvm? What the hell I am going to do with Hex Editor? What is the benefit of understanding object sizing? Why should I read java source code? Why understanding of JVM is so important? Why should I bother about JVM options? What is next?