Oop JVM in Context. oop What’s a JVM uPlatform-independent execution environment lA different JVM is required for each operating system lAny JVM can run.

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
JAVA Processors and JIT Scheduling. Overview & Literature n Formulation of the problem n JAVA introduction n Description of Caffeine * Literature: “Java.
The Java Language. Topics of this Course  Introduction to Java  The Java Language  Object Oriented Programming in Java  Exceptions Handling  Threads.
JVM-1 Java Virtual Machine Reading Assignment: Chapter 1: All Chapter 3: Sections.
JVM-1 Java Virtual Machine Reading Assignment: Chapter 1: All Chapter 3: Sections.
3/17/2008Prof. Hilfinger CS 164 Lecture 231 Run-time organization Lecture 23.
JVM-1 Java Virtual Machine Reading Assignment: Chapter 1: All Chapter 3: Sections.
Java Virtual Machine (JVM). Lecture Objectives Learn about the Java Virtual Machine (JVM) Understand the functionalities of the class loader subsystem.
Java for High Performance Computing Jordi Garcia Almiñana 14 de Octubre de 1998 de la era post-internet.
JETT 2003 Java.compareTo(C++). JAVA Java Platform consists of 4 parts: –Java Language –Java API –Java class format –Java Virtual Machine.
Run-Time Storage Organization
Run time vs. Compile time
JVM-1 Introduction to Java Virtual Machine. JVM-2 Outline Java Language, Java Virtual Machine and Java Platform Organization of Java Virtual Machine Garbage.
Oop The JVM. oop What’s a JVM uA computing machine (just like 8086, but not produced by Intel) lAbstract: machine is specified in a book. lConcrete: anyone.
Oop The JVM. oop What’s a JVM uA computing machine (just like 8086, but not produced by Intel) lAbstract: machine is specified in a book. lConcrete: anyone.
1 Memory Model of A Program, Methods Overview l Closer Look at Methods l Memory Model of JVM »Method Area »Heap »Stack l Preview: Parameter Passing.
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 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Unit 061 Java Virtual Machine (JVM) What is Java Virtual Machine? The Class Loader Subsystem Linking oVerification oPreparation oResolution Class Initialization.
Oop The JVM. oop What’s a JVM uA computing machine (just like 8086, but not produced by Intel) lAbstract: machine is specified in a book. lConcrete: anyone.
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.
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.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
JVM And CLR Dan Agar April 16, Outline Java and.NET Design Philosophies Overview of Virtual Machines Technical Look at JVM and CLR Comparison of.
1 The Java Virtual Machine Yearly Programming Project.
 Java Programming Environment  Creating Simple Java Application  Lexical Issues  Java Class Library.
Java Virtual Machine Java Virtual Machine A Java Virtual Machine (JVM) is a set of computer software programs and data structures that use.
Implement High-level Program Language on JVM CSCE 531 ZHONGHAO LIU ZHONGHAO LIU XIAO LIN.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
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.
By Noorez Kassam Welcome to JNI. Why use JNI ? 1. You already have significantly large and tricky code written in another language and you would rather.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
1 Introduction to JVM Based on material produced by Bill Venners.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
Java 2 security model Valentina Casola. Components of Java the development environment –development lifecycle –Java language features –class files and.
Java Security Model For Mobile Code Abdo Achkar. Mobile Code A mobile object is a “self contained piece” of executable code. Definition:  Code that can.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Copyright © Mohamed Nuzrath Java Programming :: Syllabus & Chapters :: Prepared & Presented By :: Mohamed Nuzrath [ Major In Programming ] NCC Programme.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
Programming Languages and Paradigms Activation Records in Java.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Hello world !!! ASCII representation of hello.c.
Introduction to Programming 1 1 2Introduction to Java.
RealTimeSystems Lab Jong-Koo, Lim
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Computer System Structures
Lecture 3 Translation.
Applications Active Web Documents Active Web Documents.
Java™ 2 Platform Getting Started.
Java Interview Questions
Java security (in a nutshell)
Introduction Enosis Learning.
Java Virtual Machine Complete subject details are available at:
2.1. Compilers and Interpreters
Mobile Handset Virtual Machine
Introduction Enosis Learning.
Computer Organization and Design Assembly & Compilation
M S COLLEGE ART’S, COMM., SCI. & BMS
Presentation transcript:

oop JVM in Context

oop What’s a JVM uPlatform-independent execution environment lA different JVM is required for each operating system lAny JVM can run the same version of a Java program uConverts Java bytecode into machine language and executes it.

oop Platform independence uPrograms can run without change on any networked computer lSimple administration uPrograms can run on embedded devices lPrinters, scanners… uNetworks as homogeneous execution environments lEnables building distributed systems uReduce time and cost of development uMore potential customers

oop JVM in Java Architecture uJava’s architecture main technologies: lThe Java programming language Source files lThe Java class file format Compiled files lThe Java API Provide access to system resources lThe Java virtual machine Runs the class files

oop The Java Programming Environment Compile time environmentrun time environment A.Java B.Java C.Java Java Compiler A.class B.class C.class A.class B.class C.class Java Virtual Machine Object class String class

oop Same Program, Different Platforms Java Program Java Platform for Linux Java Platform for Linux Linux Box Java Program Java Platform for Win32 Java Platform for Win32 PC running Windows XP Java Program Java Platform for your Television Java Platform for your Television Your Television Java Program Java Platform for your Toaster Java Platform for your Toaster Your Toaster

oop The JVM Roles uLoad class files lBoth program and API files lOnly files from API that are actually needed by the program are loaded uExecute bytecode lInterpretation – one method bytecode at a time lJust in time compiler – compiles bytecodes of a method to native machine code the first time the method is invoked, cache the native code. lAdaptive optimizer – identifies the most heavily used areas, compile them to native code.

oop Basic JVM Components The Java Virtual Machine Class loader Execution engine Host operating system Program Class files The Java API’s class files Native methods invocation

oop The Java Class File uThe binary form for Java programs uRepresents a complete description of one Java class or interface uPlatform independent – bytecodes are the machine language of the JVM uNot necessarily linked to the java language: Compiler Program in Java Lang. Program in Java Lang. Program in other Lang. Program in other Lang. Program in Java Lang. Program in Java Lang. Java class files Java class files Other Binary format Other Binary format

oop The Java API uSet of runtime libraries uProvide access to system resources of the host computer uA required component of any implementation of the Java platform Java Program Java Methods (Java API) Native methods (dynamic libraries) Host operating system

oop JVM Major Subsystems and Memory Areas.

oop The Class Loader Subsystem uThe class loader performs three main functions of JVM, namely: loading, linking and initialization. uThe linking process consists of three sub-tasks, namely, verification, preparation, and resolution, as shown by the following figure. uThese activities are performed in a strict order as shown by the figure.

oop Class Loading uLoading means reading the class file for a type, parsing it to get its information, and storing the information in the method area. uFor each type, the JVM stores reflection information and bytecodes in the method area.

oop Linking : Verification uEnsuring that binary representation of a class is structurally correct. uChecks that each instruction will find a correctly formed stack and local variable array lchecks that the items on top of the stack, and in the local variables, are of the correct type for the instruction uNone of the following are allowed: lType errors lOperand stack overflow or underflow lAccess control violations (e.g., private fields and methods) lReading of uninitialized variables lUse of uninitialized objects lWild jumps

oop Preparation uAllocating memory for the class (i.e static) variables and sets them to default initial values. uClass variables are not initialized to their proper initial values until the initialization phase - no java code is executed until initialization. uThe default values for the various types are shown below:

oop Resolution uReplacing symbolic names for types, fields and methods used by a loaded type with their actual references. uSymbolic references are resolved into direct references by searching through the method area to locate the referenced entity.

oop Class Initialization uSetting class variables to their proper initial values - initial values desired by the programmer. uInitialization of a class consists of two steps: lInitializing its direct superclass (if any and if not already initialized) lExecuting its own initialization statements uThe above imply that, the first class that gets initialized is Object.

oop JVM Memory Areas uEach instance of the JVM has one method area, one heap, and one or more stacks - one for each thread. uWhen JVM loads a class file, it puts its information in the method area. uAs the program runs, all objects instantiated are stored in the heap. uThe stack area is used to store activation records as a program runs.

oop The Method Area uInformation about types lName, super class, modifiers… uConstant pool lConstants used by the type uFields and methods information uClass (static) variables uSize is not fixed uCan be garbage collected lUnreferenced classes can be unloaded

oop JVM Stack vs. Heap uJava stack lUsed for method activation frames lOne for each thread lNo restrictions in its layout lChecked for overflow uJava native stacks lNative methods are used like other JVM methods, except they are implemented in some other language (e.g. C) lCan be used for things that cannot be handled well in Java, e.g., integrating legacy code written in other languages lNative stacks are used to keep track of state of native methods lBehave like the stack in C uJava heap lUsed for allocating objects lManaged by a garbage collector lEach object is associated with a class stored in the method area

oop Activation Frames uOne is pushed on the Java stack for each method invocation uThe frame is popped when the invocation finishes uA frame contains lLocal variables array Organized as an array Contains method’s parameters and local variables Size is determined at compile-time lAn operand stack Used for passing method arguments and results Only the top (few) words are accessed by any instruction Size is determined at compile-time

oop Architectural Tradeoffs uProgram execution performance lInterpreted languages are slower than running compiled native code lJIT improves performance uMemory management control lGarbage collection improve robustness but adds a level of uncertainty to performance uPlatform independence lSupports only the “lowest common denominator” capabilities