SlideShare una empresa de Scribd logo
1 de 21
By,
PRITY KUMARI
205111037
NIT-Trichy(MCA)
 JVM is an interpreter for bytecode.
 JVM needs to be implemented on each
platform.
 Enhance portability.
 Assure security.
 Encourage Fast execution of the program.
 Def : JVM is a component of the Java system
that interprets and executes the instructions in
our class files.
 Compiled code to be executed by the Java
Virtual Machine is represented using a
hardware- and operating system-independent
binary format, typically (but not necessarily)
stored in a file, known as the class file format.
 The class file format precisely defines the
representation of a class or interface, including
details such as byte ordering that might be
taken for granted in a platform-specific object
file format.
 Like the Java programming language, the Java
Virtual Machine operates on two kinds of types:
primitive types and reference types.
 There are, correspondingly, two kinds of values
that can be stored in variables, passed as
arguments, returned by methods, and operated
upon: primitive values and reference values.
 The instruction set of the Java Virtual Machine
distinguishes its operand types using instructions
intended to operate on values of specific types.
 For instance, iadd, ladd, fadd, and dadd
 numeric types,
 the boolean type
 returnAddress type
1)Numeric types
The integral types are:
 Byte(8-bit signed two's-complement integers)
 Short (16-bit signed two's-complement integers)
 Int(32-bit signed two's-complement integers)
 Long(64-bit signed two's-complement integers)
 Char(16-bit unsigned )and default value is the null
code point ('u0000')
2) Floating-point:
 float, whose values are elements of the float value set
and whose default value is positive zero
 double, whose values are elements of the double value
and whose default value is positive zero
3)Boolean-type:
 encode the truth values true and false, and the default
value is false.
4)returnAddress Type:
 The values of the returnAddress type are pointers to
the opcodes of Java Virtual Machine instructions.
 Of the primitive types, only the returnAddress type is
not directly associated with a Java programming
language type.
 There are three kinds of reference types:
class types
array types
interface types.
 Their values are references to dynamically created
class instances, arrays, or class instances or arrays
that implement interfaces, respectively.
 A reference value may also be the special null
reference, a reference to no object, which will be
denoted here by null
 The Java Virtual Machine specification does not
mandate a concrete value encoding null.
FIG: Memory Configuration of JVM
The JVM defines various run-time data areas that
are used during execution of a program. Some
of these data areas are created on JVM start-up
and are destroyed only when the Java Virtual
Machine exits.
Other data areas are per thread. Per-thread data
areas are created when a thread is created and
destroyed when the thread exits.
1)The pc Register:
 The JVM can support many threads of execution at once
 Each Java Virtual Machine thread has its own pc (program
counter) register.
2) JVM Stacks:
 Each JVM thread has a private JVM stack, created at the same
time as the thread.
 It holds local variables and partial results, and plays a part in
method invocation and return.
 Because the JVM stack is never manipulated directly except to
push and pop frames, frames may be heap allocated.
 The memory for a JVM stack does not need to be contiguous.
 Throws two exceptions
- OutOfMemoryError.
- StackOverflowError.
3) Heap
 The JVM has a heap that is shared among all Java Virtual
Machine threads.
 The heap is the run-time data area from which memory for
all class instances and arrays is allocated.
 The heap is created on virtual machine start-up.
 Throws one exception
- OutOfMemoryError
4) Method Area
 The method area is analogous to the storage area for
compiled code of a conventional language or analogous to
the "text" segment in an operating system process.
 It stores per-class structures such as the run-time constant
pool, field and method data, and the code for methods and
constructors, including the special methods used in class
and instance initialization and interface initialization.
 Throws one exception
- OutOfMemoryError
5) Run-Time Constant Pool
It contains several kinds of constants, ranging from numeric
literals known at compile-time to method and field references
that must be resolved at run-time.
 The run-time constant pool serves a function similar to that of a
symbol.
6) Native Method Stacks
 An implementation of the Java Virtual Machine may use
conventional stacks, called "C stacks," to support native
methods
 Java Virtual Machine implementations that cannot load native
methods and that do not themselves rely on conventional
stacks need not supply native method stacks.
 If supplied, native method stacks are typically allocated per
thread when each thread is created.
Figure 2: Content of Memory Blocks at runtime.
 Loading means reading the class file for a type, parsing it to get its
information, and storing the information in the method area.
 For each type it loads, the JVM must store the following information in the
method area:
 The fully qualified name of the type
 Whether the type is a class or an interface
 The type's modifiers ( public, abstract, final, etc)
 Method info: name, return type, number & types of parameters, modifiers,
bytecodes, size of stack frame and exception table.
The end of the loading process is the creation of an instance of
java.lang.Class for the loaded type.
The purpose is to give access to some of the information
captured in the method area for the type, to the programmer.
Some of the methods of the class java.lang.Class are:
Note that for any loaded type T, only one instance of java.lang.Class is
created even if T is used several times in an application.
public String getName()
public Class getSupClass()
public boolean isInterface()
public Class[] getInterfaces()
public Method[] getMethods()
public Fields[] getFields()
public Constructor[] getConstructors()
 The next process handled by the class loader is Linking. This
involves three sub-processes: Verification, Preparation and
Resolution
 Example of some of the things that are checked at verification are:
 Every method is provided with a structurally correct signature
 Every instruction obeys the type discipline of the Java language
 Every branch instruction branches to the start not middle of
another instruction
 In this phase, the JVM allocates memory for the class (i.e static)
variables and sets them to default initial values.
 Note that class variables are not initialized to their proper
initial values until the initialization phase - no java code is
executed until initialization.
 The default values for the various types are shown below:
 Resolution is the process of replacing symbolic names
for types, fields and methods used by a loaded type
with their actual references.
 Symbolic references are resolved into a direct references
by searching through the method area to locate the
referenced entity.
 For the class below, at the loading phase, the class
loader would have loaded the classes: TestClassClass,
String, System and Object.
 The names of these classes would have been stored in
public class TestClassClass{
public static void main(String[] args){
String name = new String(“Ahmed”);
Class nameClassInfo = name.getClass();
System.out.println("Parent is: “ + nameClassInfo.getSuperclass());
}
}
 After a class is loaded, linked, and initialized, it is
ready for use. Its static fields and static methods can be
used and it can be instantiated.
 When a new class instance is created, memory is
allocated for all its instance variables in the heap.
 Memory is also allocated recursively for all the instance
variables declared in its super class and all classes up is
inheritance hierarchy.
 All instance variables in the new object and those of its
superclasses are then initialized to their default values.
 Finally, the reference to the newly created object is
returned as the result.
Rules for processing a constructor:
 Assign the arguments for the constructor to its parameter
variables.
 If this constructor begins with an explicit invocation of another
constructor in the same class (using this), then evaluate the
arguments and process that constructor invocation recursively.
 If this constructor is for a class other than Object, then it will begin
with an explicit or implicit invocation of a superclass constructor
(using super). Evaluate the arguments and process that
superclass constructor invocation recursively.
 Initialize the instance variables for this class with their proper
values.
 Execute the rest of the body of this constructor.
JVM

Más contenido relacionado

La actualidad más candente (20)

Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
 
Introduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their featuresIntroduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their features
 
Java History
Java HistoryJava History
Java History
 
java token
java tokenjava token
java token
 
Jdk,jre,jvm
Jdk,jre,jvmJdk,jre,jvm
Jdk,jre,jvm
 
QSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and JitQSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and Jit
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
JVM
JVMJVM
JVM
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 
Main method in java
Main method in javaMain method in java
Main method in java
 
core java
core javacore java
core java
 
Important features of java
Important features of javaImportant features of java
Important features of java
 
History of java'
History of java'History of java'
History of java'
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Introduction To Java.
Introduction To Java.Introduction To Java.
Introduction To Java.
 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVM
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Java platform
Java platformJava platform
Java platform
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 

Destacado (20)

JVM- Java Virtual Machine
JVM- Java Virtual MachineJVM- Java Virtual Machine
JVM- Java Virtual Machine
 
Architecture diagram of jvm
Architecture diagram of jvmArchitecture diagram of jvm
Architecture diagram of jvm
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Understanding JVM
Understanding JVMUnderstanding JVM
Understanding JVM
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
QSpiders - Memory (JVM architecture)
QSpiders - Memory (JVM architecture)QSpiders - Memory (JVM architecture)
QSpiders - Memory (JVM architecture)
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Inside the jvm
Inside the jvmInside the jvm
Inside the jvm
 
Basics of JVM Tuning
Basics of JVM TuningBasics of JVM Tuning
Basics of JVM Tuning
 
What's Inside a JVM?
What's Inside a JVM?What's Inside a JVM?
What's Inside a JVM?
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
 
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
Security Architecture of the Java Platform (http://www.javaday.bg event - 14....
 
Java bytecode and classes
Java bytecode and classesJava bytecode and classes
Java bytecode and classes
 
Java Multi Thead Programming
Java Multi Thead ProgrammingJava Multi Thead Programming
Java Multi Thead Programming
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 
QSpiders - Variable Length-Subnet-Masks
QSpiders - Variable Length-Subnet-MasksQSpiders - Variable Length-Subnet-Masks
QSpiders - Variable Length-Subnet-Masks
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
802.11 wireless lan
802.11 wireless lan802.11 wireless lan
802.11 wireless lan
 

Similar a JVM

Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slidesunny khan
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAVINASH KUMAR
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)Khaled Anaqwa
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in JavaGurpreet singh
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java ProgrammingMath-Circle
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satyaSatya Johnny
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction AKR Education
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performanceRoger Xia
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting StartedRakesh Madugula
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Unit8 security (2) java
Unit8 security (2) javaUnit8 security (2) java
Unit8 security (2) javaSharafat Husen
 

Similar a JVM (20)

Java14
Java14Java14
Java14
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Java OOP Concepts 1st Slide
Java OOP Concepts 1st SlideJava OOP Concepts 1st Slide
Java OOP Concepts 1st Slide
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in Java
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
 
Adv kvr -satya
Adv  kvr -satyaAdv  kvr -satya
Adv kvr -satya
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performance
 
testing ppt
testing ppttesting ppt
testing ppt
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Unit8 security (2) java
Unit8 security (2) javaUnit8 security (2) java
Unit8 security (2) java
 
Class loaders
Class loadersClass loaders
Class loaders
 

Último

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 

Último (20)

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 

JVM

  • 2.  JVM is an interpreter for bytecode.  JVM needs to be implemented on each platform.  Enhance portability.  Assure security.  Encourage Fast execution of the program.  Def : JVM is a component of the Java system that interprets and executes the instructions in our class files.
  • 3.  Compiled code to be executed by the Java Virtual Machine is represented using a hardware- and operating system-independent binary format, typically (but not necessarily) stored in a file, known as the class file format.  The class file format precisely defines the representation of a class or interface, including details such as byte ordering that might be taken for granted in a platform-specific object file format.
  • 4.  Like the Java programming language, the Java Virtual Machine operates on two kinds of types: primitive types and reference types.  There are, correspondingly, two kinds of values that can be stored in variables, passed as arguments, returned by methods, and operated upon: primitive values and reference values.  The instruction set of the Java Virtual Machine distinguishes its operand types using instructions intended to operate on values of specific types.  For instance, iadd, ladd, fadd, and dadd
  • 5.  numeric types,  the boolean type  returnAddress type 1)Numeric types The integral types are:  Byte(8-bit signed two's-complement integers)  Short (16-bit signed two's-complement integers)  Int(32-bit signed two's-complement integers)  Long(64-bit signed two's-complement integers)  Char(16-bit unsigned )and default value is the null code point ('u0000')
  • 6. 2) Floating-point:  float, whose values are elements of the float value set and whose default value is positive zero  double, whose values are elements of the double value and whose default value is positive zero 3)Boolean-type:  encode the truth values true and false, and the default value is false. 4)returnAddress Type:  The values of the returnAddress type are pointers to the opcodes of Java Virtual Machine instructions.  Of the primitive types, only the returnAddress type is not directly associated with a Java programming language type.
  • 7.  There are three kinds of reference types: class types array types interface types.  Their values are references to dynamically created class instances, arrays, or class instances or arrays that implement interfaces, respectively.  A reference value may also be the special null reference, a reference to no object, which will be denoted here by null  The Java Virtual Machine specification does not mandate a concrete value encoding null.
  • 9. The JVM defines various run-time data areas that are used during execution of a program. Some of these data areas are created on JVM start-up and are destroyed only when the Java Virtual Machine exits. Other data areas are per thread. Per-thread data areas are created when a thread is created and destroyed when the thread exits.
  • 10. 1)The pc Register:  The JVM can support many threads of execution at once  Each Java Virtual Machine thread has its own pc (program counter) register. 2) JVM Stacks:  Each JVM thread has a private JVM stack, created at the same time as the thread.  It holds local variables and partial results, and plays a part in method invocation and return.  Because the JVM stack is never manipulated directly except to push and pop frames, frames may be heap allocated.  The memory for a JVM stack does not need to be contiguous.  Throws two exceptions - OutOfMemoryError. - StackOverflowError.
  • 11. 3) Heap  The JVM has a heap that is shared among all Java Virtual Machine threads.  The heap is the run-time data area from which memory for all class instances and arrays is allocated.  The heap is created on virtual machine start-up.  Throws one exception - OutOfMemoryError 4) Method Area  The method area is analogous to the storage area for compiled code of a conventional language or analogous to the "text" segment in an operating system process.  It stores per-class structures such as the run-time constant pool, field and method data, and the code for methods and constructors, including the special methods used in class and instance initialization and interface initialization.  Throws one exception - OutOfMemoryError
  • 12. 5) Run-Time Constant Pool It contains several kinds of constants, ranging from numeric literals known at compile-time to method and field references that must be resolved at run-time.  The run-time constant pool serves a function similar to that of a symbol. 6) Native Method Stacks  An implementation of the Java Virtual Machine may use conventional stacks, called "C stacks," to support native methods  Java Virtual Machine implementations that cannot load native methods and that do not themselves rely on conventional stacks need not supply native method stacks.  If supplied, native method stacks are typically allocated per thread when each thread is created.
  • 13. Figure 2: Content of Memory Blocks at runtime.
  • 14.  Loading means reading the class file for a type, parsing it to get its information, and storing the information in the method area.  For each type it loads, the JVM must store the following information in the method area:  The fully qualified name of the type  Whether the type is a class or an interface  The type's modifiers ( public, abstract, final, etc)  Method info: name, return type, number & types of parameters, modifiers, bytecodes, size of stack frame and exception table.
  • 15. The end of the loading process is the creation of an instance of java.lang.Class for the loaded type. The purpose is to give access to some of the information captured in the method area for the type, to the programmer. Some of the methods of the class java.lang.Class are: Note that for any loaded type T, only one instance of java.lang.Class is created even if T is used several times in an application. public String getName() public Class getSupClass() public boolean isInterface() public Class[] getInterfaces() public Method[] getMethods() public Fields[] getFields() public Constructor[] getConstructors()
  • 16.  The next process handled by the class loader is Linking. This involves three sub-processes: Verification, Preparation and Resolution  Example of some of the things that are checked at verification are:  Every method is provided with a structurally correct signature  Every instruction obeys the type discipline of the Java language  Every branch instruction branches to the start not middle of another instruction
  • 17.  In this phase, the JVM allocates memory for the class (i.e static) variables and sets them to default initial values.  Note that class variables are not initialized to their proper initial values until the initialization phase - no java code is executed until initialization.  The default values for the various types are shown below:
  • 18.  Resolution is the process of replacing symbolic names for types, fields and methods used by a loaded type with their actual references.  Symbolic references are resolved into a direct references by searching through the method area to locate the referenced entity.  For the class below, at the loading phase, the class loader would have loaded the classes: TestClassClass, String, System and Object.  The names of these classes would have been stored in public class TestClassClass{ public static void main(String[] args){ String name = new String(“Ahmed”); Class nameClassInfo = name.getClass(); System.out.println("Parent is: “ + nameClassInfo.getSuperclass()); } }
  • 19.  After a class is loaded, linked, and initialized, it is ready for use. Its static fields and static methods can be used and it can be instantiated.  When a new class instance is created, memory is allocated for all its instance variables in the heap.  Memory is also allocated recursively for all the instance variables declared in its super class and all classes up is inheritance hierarchy.  All instance variables in the new object and those of its superclasses are then initialized to their default values.  Finally, the reference to the newly created object is returned as the result.
  • 20. Rules for processing a constructor:  Assign the arguments for the constructor to its parameter variables.  If this constructor begins with an explicit invocation of another constructor in the same class (using this), then evaluate the arguments and process that constructor invocation recursively.  If this constructor is for a class other than Object, then it will begin with an explicit or implicit invocation of a superclass constructor (using super). Evaluate the arguments and process that superclass constructor invocation recursively.  Initialize the instance variables for this class with their proper values.  Execute the rest of the body of this constructor.

Notas del editor

  1. For instance, iadd , ladd , fadd , and dadd are all Java Virtual Machine instructions that add two numeric values and produce numeric results, but each is specialized for its operand type: int, long, float, and double, respectively.
  2. An array type consists of a component type with a single dimension (whose length is not given by the type). The component type of an array type may itself be an array type. . The null reference initially has no run-time type, but may be cast to any type. The default value of a reference type is null.
  3. A JVM stack stores frames . JVM stack is analogous to the stack of a conventional language such as C:
  4. The Java Virtual Machine has a method area that is shared among all Java Virtual Machine threads.
  5. The run-time constant pool serves a function similar to that of a symbol table for a conventional programming language, although it contains a wider range of data than a typical symbol table.
  6. Verification is the process of ensuring that binary representation of a class is structurally correct The JVM has to make sure that a file it is asked to load was generated by a valid compiler and it is well formed Class B may be a valid sub-class of A at the time A and B were compiled, but class A may have been changed and re-compiled
  7. In this phase, the names are replaced with their actual references.