SlideShare uma empresa Scribd logo
1 de 29
Java Virtual MachineJava Virtual Machine
ArchitectureArchitecture
and APIsand APIs
22 Oct 200722 Oct 2007
National University of SingaporeNational University of Singapore
School of ComputingSchool of Computing
OH KWANG SHINOH KWANG SHIN
The JVM Architecture
and APIs
22 Oct 2007 2
AgendaAgenda
• Big Picture of Java
• The Java Virtual Machine Architecture
– Data Types & Storage
– Java Instruction Set
– Exceptions and Errors
– Binary Classes
– The Java Native Interface
• Completing the Platform: APIs
– Java Platforms
– Java APIs: Serializability
The JVM Architecture
and APIs
22 Oct 2007 3
Big Picture of JavaBig Picture of Java
Java Source
( *.java )
Java Compiler
( javac )
Java Class
( *.class )
Java Platform
Java Virtual
Machine
Java APIs
Object.class
The JVM Architecture
and APIs
22 Oct 2007 4
JVM – Data TypesJVM – Data Types
• Primitive Data Types
– int, char, byte, short, float, double
– Implementation-dependent fashion
• Defined according to the values they can take, not
the number of bits of storage
• Integer in the range -231
to +231
-1
– 32-bit words + two’s complement
– Could use more storage bits
• References
– Can hold reference values
• Reference value points to an object stored in memory
The JVM Architecture
and APIs
22 Oct 2007 5
JVM – Data TypesJVM – Data Types
• Objects and Arrays
– Object
• Composed of primitive data types and
references that may point to other object
– Array
• Has a fixed number of elements
• Elements of an array
– Must all be of the same primitive type
– Must all be references which point to objects of
the same type
The JVM Architecture
and APIs
22 Oct 2007 6
JVM – Data StorageJVM – Data Storage
• Global Storage
– Main memory, where globally declared
variables reside
• Local Storage
– Temporary storage for variables that are local
to a method
• Operand Storage
– Holds variables while they are being operated
on by the functional instructions
The JVM Architecture
and APIs
22 Oct 2007 7
JVM – Data StorageJVM – Data Storage
• The Stack
– Local and operand storage
are allocated on the stack
– Not arrays and objects,
but only references and
individual array elements
on the stack
– As each method is called,
a stack frame is allocated
Locals
Operands
Arguments
Locals
Operands
Arguments
Locals
Operands
Java Stack Structure
The JVM Architecture
and APIs
22 Oct 2007 8
JVM – Data StorageJVM – Data Storage
• Memory Hierarchy
The JVM Architecture
and APIs
22 Oct 2007 9
JVM – Java Instruction SetJVM – Java Instruction Set
• Instruction Formats
(a) opcode
(b) opcode index
(c) opcode index1 index2
(d) opcode data
(e) opcode data1 data2
Typical Bytecode Instruction Formats
The JVM Architecture
and APIs
22 Oct 2007 10
JVM – Java Instruction SetJVM – Java Instruction Set
• Data-Movement Instructions
– Push constant values onto the stack
•iconst1: single-byte instruction that pushes
the integer constant 1 onto the stack
•bipush data, sipush data1 data2,
ldc index, ldc_w index1 index2, etc
– Manipulate the stack entries
•pop: pops the top element from the stack
and discards it
•swap: swaps the positions of the top two
stack elements
The JVM Architecture
and APIs
22 Oct 2007 11
JVM – Java Instruction SetJVM – Java Instruction Set
• Data-Movement Instructions
– Moves values : local storage ↔ operand stack
• iload_1: takes the integer from local storage slot 1
and pushes it onto the stack
• istore_1: moves data from the stack to local
storage in the current stack frame
– Deal with global memory data (objects, arrays)
• new: new instance of the object is created on the
heap and initialized. A reference to the object is
pushed onto the stack
• newarray: creates an array containing elements of a
specified primitive type
• getfield, putfield: accesses data held in objects
The JVM Architecture
and APIs
22 Oct 2007 12
JVM – Java Instruction SetJVM – Java Instruction Set
• Type Conversion
– Convert one type of data item on the
stack to another
•i2f: pops an integer from the stack,
converts it to a float, and pushes the float
back onto the stack
The JVM Architecture
and APIs
22 Oct 2007 13
JVM – Java Instruction SetJVM – Java Instruction Set
• Functional Instructions
– Take input operands, perform operations on
them, and produce a result
– Single byte: operands are always taken from the
stack and results are placed onto the stack
– Example
• iadd: pops two integers from the stack  adds them
 pushes the sum onto the stack
• iand: pops two integers from the stack  performs a
logical AND on them  pushes the result onto the
stack
• ishfl: pops two integers from the stack  shifts the
top element left by an amount specified by the second
element  pushes the result onto the stack
The JVM Architecture
and APIs
22 Oct 2007 14
JVM – Java Instruction SetJVM – Java Instruction Set
• Control Flow Instructions
– ifeq data1 data2
• pops an integer from the stack  compares it with zero
– True: PC relative branch to an offset found by
concatenating the two data bytes
– if_icmpeq data1 data2
• pops two integer values from the stack  compares the
first with the second
– True: PC relative branch to an offset found by
concatenating the two data bytes
– ifnull data1 data2
• pops a reference from the stack  check it for null
– True: PC relative branch to an offset found by
concatenating the two data bytes
The JVM Architecture
and APIs
22 Oct 2007 15
JVM – Java Instruction SetJVM – Java Instruction Set
• Example Program
– javap: The Java Class File Disassembler
class Rectangle {
protected int sides [];
………………
………………
public int perimeter () {
return 2*(sides[0] + sides[1]);
}
public int area () {
return (sides[0] * sides[1]);
}
}
Java Source Rectangle.java
public int perimeter();
Code:
0: iconst_2
1: aload_0
2: getfield #2; //Field sides:[I
5: iconst_0
6: iaload
7: aload_0
8: getfield #2; //Field sides:[I
11: iconst_1
12: iaload
13: iadd
14: imul
15: ireturn
Disassembled Code
The JVM Architecture
and APIs
22 Oct 2007 16
Rectangle Objectsides[0]
JVM – Java Instruction SetJVM – Java Instruction Set
• Example Program Scenario
public int perimeter () {
return 2*(sides[0] + sides[1]);
}
public int perimeter();
Code:
0: iconst_2
1: aload_0
2: getfield #2;
5: iconst_0
6: iaload
7: aload_0
8: getfield #2;
11: iconst_1
12: iaload
13: iadd
14: imul
15: ireturn
Constant 2
Operand Stack
Pushes a constant 2 onto the operand stack
Pushes local variable 0 onto the stack
(argument  reference to the rectangle object)
Pushes the reference to the sides array
sides Array
Pushes index number 0 onto the stack
Index Number 0
Load element 0 from the array sides
Pushes local variable 0 onto the stack
(argument  reference to the rectangle object)
Pushes the reference to the sides array
Pushes index number 1 onto the stack
Load element 1 from the array sides
Rectangle Object
sides Array
Index Number 1
sides[1]
Pushes addition of the top two stack elements
Pushes multiplication of top two stack elements
Returns with the integer result on top of stack
sides[0]+sides[1]
2*(
sides[0]+sides[1])
The JVM Architecture
and APIs
22 Oct 2007 17
JVM – Exceptions & ErrorsJVM – Exceptions & Errors
• All exceptions must be handled
somewhere
– No global way to turn them off
– If there is no handler, then calling method
takes over
– Overall program robustness consideration
• Errors
– Caused by limitation of the VM implementation
or VM bugs
• Exceptions
– Caused by program behavior that occurs
dynamically – as the program executes
The JVM Architecture
and APIs
22 Oct 2007 18
JVM – Exceptions & ErrorsJVM – Exceptions & Errors
• Exception table with each method
– Makes it possible to specify an exception
handler, depending on where an exception
occurs
From To Target Type
8 12 96 Arithmetic Exception
Exception Table
The JVM Architecture
and APIs
22 Oct 2007 19
JVM – Exceptions & ErrorsJVM – Exceptions & Errors
• Example of exception table
class Rectangle {
protected int sides [];
………………
public int perimeter () {
try {
return 2*(sides[0] + sides[1]);
} catch(ArithmeticException e) {
return -1;
}
}
public int area () {
return (sides[0] * sides[1]);
}
}
public int perimeter();
Code:
0: iconst_2
1: aload_0
2: getfield #2; //Field sides:[I
5: iconst_0
6: iaload
7: aload_0
8: getfield #2; //Field sides:[I
11: iconst_1
12: iaload
13: iadd
14: imul
15: ireturn
16: astore_1
17: iconst_m1
18: ireturn
Exception table:
from to target type
0 15 16 Class java/lang/ArithmeticException
The JVM Architecture
and APIs
22 Oct 2007 20
JVM – Binary ClassesJVM – Binary Classes
• Binary class
– Typically included in a class file
– Code + Metadata
• Metadata is a detailed specification of the
data structures and their relationships
– Can be loaded on demand
• At the time they are needed by the program
• Saves bandwidth for loading binary classes
that are never used
• Allows a Java program to start up quickly
The JVM Architecture
and APIs
22 Oct 2007 21
JVM – Binary Class FormatJVM – Binary Class Format
Magic Number
Version Information
Constant Pool Size
Constant Pool
Access Flags
This Class
Super Class
Interface Count
Interfaces
Field Count
Field Information
Method Count
Methods
Attribute Count
Attributes
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
Identifier of java binary class
Minor and major version numbers of this class file
Number of entries in the constant pool + 1
All the constant values and references
Provide access information
Name of this class (Valid index of Constant Pool)
Name of super class (Valid index of Constant Pool or 0)
Number of direct superinterfaces
Number of references to the superinterfaces
(Valid index into the Constant Pool table)
Number of field_info structures in the Field Information
field_info structures giving a complete description of
a field in this class or interface
Number of method_info structures in the Methods
method_info structure giving a complete description of
a method in this class or interface
Number of attributes in the Attributes
Detailed information regarding
the other components listed earlier
The JVM Architecture
and APIs
22 Oct 2007 22
JVM – Java Native InterfaceJVM – Java Native Interface
• JNI (Java Native Interface)
– Allows java code and native compiled
code to interoperate
The JVM Architecture
and APIs
22 Oct 2007 23
Java PlatformJava Platform
• Java Platform = JVM + Java APIs
• Java APIs
– A set of standard libraries
– Provide most of the features that are
visible to users and software developers
• Support for secure network computing,
component-based software, graphical user
interfaces (GUIs), etc.
The JVM Architecture
and APIs
22 Oct 2007 24
Java PlatformJava Platform
• J2EE, J2SE and J2ME
The JVM Architecture
and APIs
22 Oct 2007 25
Java APIs - SerializationJava APIs - Serialization
• Process of converting an object into
an implementation-independent form
Object
Platform A-
Dependent
Representation
Serialization Deserialization
Object
Platform B-
Dependent
Representation
Platform-
Independent
Representation
Persistent Storage
Network
The JVM Architecture
and APIs
22 Oct 2007 26
Java APIs - ThreadJava APIs - Thread
• Multithreading support is provided by Java
libraries that are part of java.lang
• Monitors
– Support the synchronization among threads
– Lock and two Java bytecode instructions
• Lock
– Associated with each object and each class
– Operated as a counter, rather than flag
• Two Java bytecode instructions
– Monitorenter
– monitorexit
The JVM Architecture
and APIs
22 Oct 2007 27
210
Java APIs - ThreadJava APIs - Thread
public int perimeter () {
synchronized (sides) {
synchronized (sides) {
return 2*(sides[0] + sides[1]);
}
}
}
public int perimeter();
Code:
………
6: monitorenter
………
13: monitorenter
14: iconst_2
………
35: aload_2
36: monitorexit
………
41: aload_1
42: monitorexit
………
Lock of sides
Acquires the lock for the object, the lock is incremented
Acquiring thread may already hold the lock
, the lock is incremented
Decrements the lock for the object
Decrements the lock for the object
If the lock becomes zero,
then it is released and can
be acquired by a waiting
thread (if there is one)
The JVM Architecture
and APIs
22 Oct 2007 28
ReferencesReferences
• James E. Smith and Ravi Nair, Virtual Machines: Versatile
Platform for Systems and Processes. Morgan Kaufmann
Publishers, 2005.
• Java Technology – The Source for Java Developers
Available: http://java.sun.com
• Bill Venners, Inside the Java 2 Virtual Machine, McGraw-
Hill, 1999.
• Tim Lindholm and Frank Yellin, The JavaTM
Virtual
Machine Specification – Second Edition, Addison-Wesley
Longman Publishing Co., Inc., Boston, MA, 1999.
CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs

Mais conteúdo relacionado

Mais procurados

Java virtual machine
Java virtual machineJava virtual machine
Java virtual machineNikhil Sharma
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7Deniz Oguz
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz SAurabh PRajapati
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeOmar Bashir
 
Java and Java platforms
Java and Java platformsJava and Java platforms
Java and Java platformsIlio Catallo
 
CS Lesson: Introduction to the Java virtual Machine
CS Lesson: Introduction to the Java virtual MachineCS Lesson: Introduction to the Java virtual Machine
CS Lesson: Introduction to the Java virtual MachineKatrin Becker
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaSanjeev Tripathi
 
Understanding Java Dynamic Proxies
Understanding Java Dynamic ProxiesUnderstanding Java Dynamic Proxies
Understanding Java Dynamic ProxiesRafael Luque Leiva
 
Java byte code presentation
Java byte code presentationJava byte code presentation
Java byte code presentationMahnoor Hashmi
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaAjay Sharma
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructorShivam Singhal
 

Mais procurados (20)

Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz Java history, versions, types of errors and exception, quiz
Java history, versions, types of errors and exception, quiz
 
What is-java
What is-javaWhat is-java
What is-java
 
Java architecture
Java architectureJava architecture
Java architecture
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
 
Java and Java platforms
Java and Java platformsJava and Java platforms
Java and Java platforms
 
Core Java
Core JavaCore Java
Core Java
 
CS Lesson: Introduction to the Java virtual Machine
CS Lesson: Introduction to the Java virtual MachineCS Lesson: Introduction to the Java virtual Machine
CS Lesson: Introduction to the Java virtual Machine
 
Java & advanced java
Java & advanced javaJava & advanced java
Java & advanced java
 
Java basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini indiaJava basic tutorial by sanjeevini india
Java basic tutorial by sanjeevini india
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
Dynamic Proxy by Java
Dynamic Proxy by JavaDynamic Proxy by Java
Dynamic Proxy by Java
 
Understanding Java Dynamic Proxies
Understanding Java Dynamic ProxiesUnderstanding Java Dynamic Proxies
Understanding Java Dynamic Proxies
 
Java introduction
Java introductionJava introduction
Java introduction
 
Core java
Core java Core java
Core java
 
Java features
Java featuresJava features
Java features
 
Java byte code presentation
Java byte code presentationJava byte code presentation
Java byte code presentation
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
java: basics, user input, data type, constructor
java:  basics, user input, data type, constructorjava:  basics, user input, data type, constructor
java: basics, user input, data type, constructor
 

Destaque

Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
Java Magazine : The JAVA Virtual Machine alternative languages
Java Magazine : The JAVA Virtual Machine alternative languagesJava Magazine : The JAVA Virtual Machine alternative languages
Java Magazine : The JAVA Virtual Machine alternative languagesErik Gur
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaJaved Rashid
 
Architecture diagram of jvm
Architecture diagram of jvmArchitecture diagram of jvm
Architecture diagram of jvmhome
 
Java package
Java packageJava package
Java packageCS_GDRCST
 
5.interface and packages
5.interface and packages5.interface and packages
5.interface and packagesDeepak Sharma
 
An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAbhishek Asthana
 
العمارة الذكية و العمارة المستدامة
العمارة الذكية و العمارة المستدامةالعمارة الذكية و العمارة المستدامة
العمارة الذكية و العمارة المستدامةAhmed SHoukry ELhfnawy
 
العمارة الذكية وعلاقتها بلبيئة
العمارة الذكية وعلاقتها بلبيئةالعمارة الذكية وعلاقتها بلبيئة
العمارة الذكية وعلاقتها بلبيئةYaser Al-shahethi
 
Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Marcos García
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in JavaRavi_Kant_Sahu
 
What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)Rudy De Busscher
 

Destaque (20)

Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Java Magazine : The JAVA Virtual Machine alternative languages
Java Magazine : The JAVA Virtual Machine alternative languagesJava Magazine : The JAVA Virtual Machine alternative languages
Java Magazine : The JAVA Virtual Machine alternative languages
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
 
Architecture diagram of jvm
Architecture diagram of jvmArchitecture diagram of jvm
Architecture diagram of jvm
 
Java package
Java packageJava package
Java package
 
5.interface and packages
5.interface and packages5.interface and packages
5.interface and packages
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Packages in java
Packages in javaPackages in java
Packages in java
 
An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in Java
 
Java beans
Java beansJava beans
Java beans
 
Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
 
Virtual instrumentation (LabVIEW)
Virtual instrumentation (LabVIEW)Virtual instrumentation (LabVIEW)
Virtual instrumentation (LabVIEW)
 
Sustainability
SustainabilitySustainability
Sustainability
 
العمارة الذكية و العمارة المستدامة
العمارة الذكية و العمارة المستدامةالعمارة الذكية و العمارة المستدامة
العمارة الذكية و العمارة المستدامة
 
العمارة الذكية وعلاقتها بلبيئة
العمارة الذكية وعلاقتها بلبيئةالعمارة الذكية وعلاقتها بلبيئة
العمارة الذكية وعلاقتها بلبيئة
 
Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Control structures in Java
Control structures in JavaControl structures in Java
Control structures in Java
 
Operators in java
Operators in javaOperators in java
Operators in java
 
What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)
 

Semelhante a CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs

Java user group 2015 02-09-java8
Java user group 2015 02-09-java8Java user group 2015 02-09-java8
Java user group 2015 02-09-java8Marc Tritschler
 
Java user group 2015 02-09-java8
Java user group 2015 02-09-java8Java user group 2015 02-09-java8
Java user group 2015 02-09-java8marctritschler
 
Grow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackGrow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackKeitaSugiyama1
 
Perf onjs final
Perf onjs finalPerf onjs final
Perf onjs finalqi yang
 
Javaforum 20110915
Javaforum 20110915Javaforum 20110915
Javaforum 20110915Squeed
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesAlexandra Masterson
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»DataArt
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatientGrant Steinfeld
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Rittercatherinewall
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profilerIhor Bobak
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Agora Group
 
What’s expected in Java 9
What’s expected in Java 9What’s expected in Java 9
What’s expected in Java 9Gal Marder
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentationnrjoshiee
 

Semelhante a CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs (20)

Java user group 2015 02-09-java8
Java user group 2015 02-09-java8Java user group 2015 02-09-java8
Java user group 2015 02-09-java8
 
Java user group 2015 02-09-java8
Java user group 2015 02-09-java8Java user group 2015 02-09-java8
Java user group 2015 02-09-java8
 
Grow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM StackGrow and Shrink - Dynamically Extending the Ruby VM Stack
Grow and Shrink - Dynamically Extending the Ruby VM Stack
 
Perf onjs final
Perf onjs finalPerf onjs final
Perf onjs final
 
Javaforum 20110915
Javaforum 20110915Javaforum 20110915
Javaforum 20110915
 
AMIS Oracle OpenWorld 2013 Review Part 3 - Fusion Middleware
AMIS Oracle OpenWorld 2013 Review Part 3 - Fusion MiddlewareAMIS Oracle OpenWorld 2013 Review Part 3 - Fusion Middleware
AMIS Oracle OpenWorld 2013 Review Part 3 - Fusion Middleware
 
Java 7 New Features
Java 7 New FeaturesJava 7 New Features
Java 7 New Features
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatient
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Ritter
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profiler
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
 
What’s expected in Java 9
What’s expected in Java 9What’s expected in Java 9
What’s expected in Java 9
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentation
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
java slides
java slidesjava slides
java slides
 

Mais de Kwangshin Oh

Ruby Programming Language - Introduction
Ruby Programming Language - IntroductionRuby Programming Language - Introduction
Ruby Programming Language - IntroductionKwangshin Oh
 
핀테크 코리아 2014 후기 - 오광신
핀테크 코리아 2014 후기 - 오광신핀테크 코리아 2014 후기 - 오광신
핀테크 코리아 2014 후기 - 오광신Kwangshin Oh
 
CS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design PatternsCS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design PatternsKwangshin Oh
 
CS6270 Virtual Machines - Retargetable Binary Translators
CS6270 Virtual Machines - Retargetable Binary TranslatorsCS6270 Virtual Machines - Retargetable Binary Translators
CS6270 Virtual Machines - Retargetable Binary TranslatorsKwangshin Oh
 
CS5261 Group 8 Presentation - US Mobile Industry
CS5261 Group 8 Presentation - US Mobile IndustryCS5261 Group 8 Presentation - US Mobile Industry
CS5261 Group 8 Presentation - US Mobile IndustryKwangshin Oh
 
Jini Network Technology
Jini Network TechnologyJini Network Technology
Jini Network TechnologyKwangshin Oh
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming ConceptsKwangshin Oh
 

Mais de Kwangshin Oh (7)

Ruby Programming Language - Introduction
Ruby Programming Language - IntroductionRuby Programming Language - Introduction
Ruby Programming Language - Introduction
 
핀테크 코리아 2014 후기 - 오광신
핀테크 코리아 2014 후기 - 오광신핀테크 코리아 2014 후기 - 오광신
핀테크 코리아 2014 후기 - 오광신
 
CS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design PatternsCS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design Patterns
 
CS6270 Virtual Machines - Retargetable Binary Translators
CS6270 Virtual Machines - Retargetable Binary TranslatorsCS6270 Virtual Machines - Retargetable Binary Translators
CS6270 Virtual Machines - Retargetable Binary Translators
 
CS5261 Group 8 Presentation - US Mobile Industry
CS5261 Group 8 Presentation - US Mobile IndustryCS5261 Group 8 Presentation - US Mobile Industry
CS5261 Group 8 Presentation - US Mobile Industry
 
Jini Network Technology
Jini Network TechnologyJini Network Technology
Jini Network Technology
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
 

Último

QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 

Último (20)

QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 

CS6270 Virtual Machines - Java Virtual Machine Architecture and APIs

  • 1. Java Virtual MachineJava Virtual Machine ArchitectureArchitecture and APIsand APIs 22 Oct 200722 Oct 2007 National University of SingaporeNational University of Singapore School of ComputingSchool of Computing OH KWANG SHINOH KWANG SHIN
  • 2. The JVM Architecture and APIs 22 Oct 2007 2 AgendaAgenda • Big Picture of Java • The Java Virtual Machine Architecture – Data Types & Storage – Java Instruction Set – Exceptions and Errors – Binary Classes – The Java Native Interface • Completing the Platform: APIs – Java Platforms – Java APIs: Serializability
  • 3. The JVM Architecture and APIs 22 Oct 2007 3 Big Picture of JavaBig Picture of Java Java Source ( *.java ) Java Compiler ( javac ) Java Class ( *.class ) Java Platform Java Virtual Machine Java APIs Object.class
  • 4. The JVM Architecture and APIs 22 Oct 2007 4 JVM – Data TypesJVM – Data Types • Primitive Data Types – int, char, byte, short, float, double – Implementation-dependent fashion • Defined according to the values they can take, not the number of bits of storage • Integer in the range -231 to +231 -1 – 32-bit words + two’s complement – Could use more storage bits • References – Can hold reference values • Reference value points to an object stored in memory
  • 5. The JVM Architecture and APIs 22 Oct 2007 5 JVM – Data TypesJVM – Data Types • Objects and Arrays – Object • Composed of primitive data types and references that may point to other object – Array • Has a fixed number of elements • Elements of an array – Must all be of the same primitive type – Must all be references which point to objects of the same type
  • 6. The JVM Architecture and APIs 22 Oct 2007 6 JVM – Data StorageJVM – Data Storage • Global Storage – Main memory, where globally declared variables reside • Local Storage – Temporary storage for variables that are local to a method • Operand Storage – Holds variables while they are being operated on by the functional instructions
  • 7. The JVM Architecture and APIs 22 Oct 2007 7 JVM – Data StorageJVM – Data Storage • The Stack – Local and operand storage are allocated on the stack – Not arrays and objects, but only references and individual array elements on the stack – As each method is called, a stack frame is allocated Locals Operands Arguments Locals Operands Arguments Locals Operands Java Stack Structure
  • 8. The JVM Architecture and APIs 22 Oct 2007 8 JVM – Data StorageJVM – Data Storage • Memory Hierarchy
  • 9. The JVM Architecture and APIs 22 Oct 2007 9 JVM – Java Instruction SetJVM – Java Instruction Set • Instruction Formats (a) opcode (b) opcode index (c) opcode index1 index2 (d) opcode data (e) opcode data1 data2 Typical Bytecode Instruction Formats
  • 10. The JVM Architecture and APIs 22 Oct 2007 10 JVM – Java Instruction SetJVM – Java Instruction Set • Data-Movement Instructions – Push constant values onto the stack •iconst1: single-byte instruction that pushes the integer constant 1 onto the stack •bipush data, sipush data1 data2, ldc index, ldc_w index1 index2, etc – Manipulate the stack entries •pop: pops the top element from the stack and discards it •swap: swaps the positions of the top two stack elements
  • 11. The JVM Architecture and APIs 22 Oct 2007 11 JVM – Java Instruction SetJVM – Java Instruction Set • Data-Movement Instructions – Moves values : local storage ↔ operand stack • iload_1: takes the integer from local storage slot 1 and pushes it onto the stack • istore_1: moves data from the stack to local storage in the current stack frame – Deal with global memory data (objects, arrays) • new: new instance of the object is created on the heap and initialized. A reference to the object is pushed onto the stack • newarray: creates an array containing elements of a specified primitive type • getfield, putfield: accesses data held in objects
  • 12. The JVM Architecture and APIs 22 Oct 2007 12 JVM – Java Instruction SetJVM – Java Instruction Set • Type Conversion – Convert one type of data item on the stack to another •i2f: pops an integer from the stack, converts it to a float, and pushes the float back onto the stack
  • 13. The JVM Architecture and APIs 22 Oct 2007 13 JVM – Java Instruction SetJVM – Java Instruction Set • Functional Instructions – Take input operands, perform operations on them, and produce a result – Single byte: operands are always taken from the stack and results are placed onto the stack – Example • iadd: pops two integers from the stack  adds them  pushes the sum onto the stack • iand: pops two integers from the stack  performs a logical AND on them  pushes the result onto the stack • ishfl: pops two integers from the stack  shifts the top element left by an amount specified by the second element  pushes the result onto the stack
  • 14. The JVM Architecture and APIs 22 Oct 2007 14 JVM – Java Instruction SetJVM – Java Instruction Set • Control Flow Instructions – ifeq data1 data2 • pops an integer from the stack  compares it with zero – True: PC relative branch to an offset found by concatenating the two data bytes – if_icmpeq data1 data2 • pops two integer values from the stack  compares the first with the second – True: PC relative branch to an offset found by concatenating the two data bytes – ifnull data1 data2 • pops a reference from the stack  check it for null – True: PC relative branch to an offset found by concatenating the two data bytes
  • 15. The JVM Architecture and APIs 22 Oct 2007 15 JVM – Java Instruction SetJVM – Java Instruction Set • Example Program – javap: The Java Class File Disassembler class Rectangle { protected int sides []; ……………… ……………… public int perimeter () { return 2*(sides[0] + sides[1]); } public int area () { return (sides[0] * sides[1]); } } Java Source Rectangle.java public int perimeter(); Code: 0: iconst_2 1: aload_0 2: getfield #2; //Field sides:[I 5: iconst_0 6: iaload 7: aload_0 8: getfield #2; //Field sides:[I 11: iconst_1 12: iaload 13: iadd 14: imul 15: ireturn Disassembled Code
  • 16. The JVM Architecture and APIs 22 Oct 2007 16 Rectangle Objectsides[0] JVM – Java Instruction SetJVM – Java Instruction Set • Example Program Scenario public int perimeter () { return 2*(sides[0] + sides[1]); } public int perimeter(); Code: 0: iconst_2 1: aload_0 2: getfield #2; 5: iconst_0 6: iaload 7: aload_0 8: getfield #2; 11: iconst_1 12: iaload 13: iadd 14: imul 15: ireturn Constant 2 Operand Stack Pushes a constant 2 onto the operand stack Pushes local variable 0 onto the stack (argument  reference to the rectangle object) Pushes the reference to the sides array sides Array Pushes index number 0 onto the stack Index Number 0 Load element 0 from the array sides Pushes local variable 0 onto the stack (argument  reference to the rectangle object) Pushes the reference to the sides array Pushes index number 1 onto the stack Load element 1 from the array sides Rectangle Object sides Array Index Number 1 sides[1] Pushes addition of the top two stack elements Pushes multiplication of top two stack elements Returns with the integer result on top of stack sides[0]+sides[1] 2*( sides[0]+sides[1])
  • 17. The JVM Architecture and APIs 22 Oct 2007 17 JVM – Exceptions & ErrorsJVM – Exceptions & Errors • All exceptions must be handled somewhere – No global way to turn them off – If there is no handler, then calling method takes over – Overall program robustness consideration • Errors – Caused by limitation of the VM implementation or VM bugs • Exceptions – Caused by program behavior that occurs dynamically – as the program executes
  • 18. The JVM Architecture and APIs 22 Oct 2007 18 JVM – Exceptions & ErrorsJVM – Exceptions & Errors • Exception table with each method – Makes it possible to specify an exception handler, depending on where an exception occurs From To Target Type 8 12 96 Arithmetic Exception Exception Table
  • 19. The JVM Architecture and APIs 22 Oct 2007 19 JVM – Exceptions & ErrorsJVM – Exceptions & Errors • Example of exception table class Rectangle { protected int sides []; ……………… public int perimeter () { try { return 2*(sides[0] + sides[1]); } catch(ArithmeticException e) { return -1; } } public int area () { return (sides[0] * sides[1]); } } public int perimeter(); Code: 0: iconst_2 1: aload_0 2: getfield #2; //Field sides:[I 5: iconst_0 6: iaload 7: aload_0 8: getfield #2; //Field sides:[I 11: iconst_1 12: iaload 13: iadd 14: imul 15: ireturn 16: astore_1 17: iconst_m1 18: ireturn Exception table: from to target type 0 15 16 Class java/lang/ArithmeticException
  • 20. The JVM Architecture and APIs 22 Oct 2007 20 JVM – Binary ClassesJVM – Binary Classes • Binary class – Typically included in a class file – Code + Metadata • Metadata is a detailed specification of the data structures and their relationships – Can be loaded on demand • At the time they are needed by the program • Saves bandwidth for loading binary classes that are never used • Allows a Java program to start up quickly
  • 21. The JVM Architecture and APIs 22 Oct 2007 21 JVM – Binary Class FormatJVM – Binary Class Format Magic Number Version Information Constant Pool Size Constant Pool Access Flags This Class Super Class Interface Count Interfaces Field Count Field Information Method Count Methods Attribute Count Attributes • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • Identifier of java binary class Minor and major version numbers of this class file Number of entries in the constant pool + 1 All the constant values and references Provide access information Name of this class (Valid index of Constant Pool) Name of super class (Valid index of Constant Pool or 0) Number of direct superinterfaces Number of references to the superinterfaces (Valid index into the Constant Pool table) Number of field_info structures in the Field Information field_info structures giving a complete description of a field in this class or interface Number of method_info structures in the Methods method_info structure giving a complete description of a method in this class or interface Number of attributes in the Attributes Detailed information regarding the other components listed earlier
  • 22. The JVM Architecture and APIs 22 Oct 2007 22 JVM – Java Native InterfaceJVM – Java Native Interface • JNI (Java Native Interface) – Allows java code and native compiled code to interoperate
  • 23. The JVM Architecture and APIs 22 Oct 2007 23 Java PlatformJava Platform • Java Platform = JVM + Java APIs • Java APIs – A set of standard libraries – Provide most of the features that are visible to users and software developers • Support for secure network computing, component-based software, graphical user interfaces (GUIs), etc.
  • 24. The JVM Architecture and APIs 22 Oct 2007 24 Java PlatformJava Platform • J2EE, J2SE and J2ME
  • 25. The JVM Architecture and APIs 22 Oct 2007 25 Java APIs - SerializationJava APIs - Serialization • Process of converting an object into an implementation-independent form Object Platform A- Dependent Representation Serialization Deserialization Object Platform B- Dependent Representation Platform- Independent Representation Persistent Storage Network
  • 26. The JVM Architecture and APIs 22 Oct 2007 26 Java APIs - ThreadJava APIs - Thread • Multithreading support is provided by Java libraries that are part of java.lang • Monitors – Support the synchronization among threads – Lock and two Java bytecode instructions • Lock – Associated with each object and each class – Operated as a counter, rather than flag • Two Java bytecode instructions – Monitorenter – monitorexit
  • 27. The JVM Architecture and APIs 22 Oct 2007 27 210 Java APIs - ThreadJava APIs - Thread public int perimeter () { synchronized (sides) { synchronized (sides) { return 2*(sides[0] + sides[1]); } } } public int perimeter(); Code: ……… 6: monitorenter ……… 13: monitorenter 14: iconst_2 ……… 35: aload_2 36: monitorexit ……… 41: aload_1 42: monitorexit ……… Lock of sides Acquires the lock for the object, the lock is incremented Acquiring thread may already hold the lock , the lock is incremented Decrements the lock for the object Decrements the lock for the object If the lock becomes zero, then it is released and can be acquired by a waiting thread (if there is one)
  • 28. The JVM Architecture and APIs 22 Oct 2007 28 ReferencesReferences • James E. Smith and Ravi Nair, Virtual Machines: Versatile Platform for Systems and Processes. Morgan Kaufmann Publishers, 2005. • Java Technology – The Source for Java Developers Available: http://java.sun.com • Bill Venners, Inside the Java 2 Virtual Machine, McGraw- Hill, 1999. • Tim Lindholm and Frank Yellin, The JavaTM Virtual Machine Specification – Second Edition, Addison-Wesley Longman Publishing Co., Inc., Boston, MA, 1999.