The Java Virtual Machine: - JVM Runtime Behaviour - JVM Architecture - .Class File Format - JVM Instruction Set
The Java Virtual Machine: - JVM Runtime Behaviour - JVM Architecture - .Class File Format - JVM Instruction Set
The Java Virtual Machine: - JVM Runtime Behaviour - JVM Architecture - .Class File Format - JVM Instruction Set
• JVM architecture
SE209 JVM - 1
James Power
Main source:
• http://java.sun.com/docs/books/vmspec/
SE209 JVM - 2
James Power
• VM startup
• Class Loading/Linking/Initialisation
• Instance Creation/Finalisation
• Unloading Classes
• VM exit
SE209 JVM - 3
James Power
Startup
• Exit when:
– all non-daemon threads end, or
– some thread explicitly calls exit() method
SE209 JVM - 4
James Power
Class Loading
• Find the binary code for a class and create a corresponding Class object
SE209 JVM - 5
James Power
Class Loaders
• A class is unloaded when its class loader becomes unreachable (bootstrap class
loader is never unreachable)
SE209 JVM - 6
James Power
More later...
SE209 JVM - 7
James Power
• Set these fields to the standard default values (N.B. not explicit initialisers)
SE209 JVM - 8
James Power
SE209 JVM - 9
James Power
Class Initialisation
Happens once just before first instance creation, or first use of static variable.
SE209 JVM - 10
James Power
Instance Creation/Finalisation
• Process:
1. Allocate space for all the instance variables (including the inherited ones),
2. Initialise them with the default values
3. Call the appropriate constructor (do parent’s first)
• finalize() called just before garbage collector takes the object (so timing is
unpredictable)
SE209 JVM - 11
James Power
JVM Architecture
SE209 JVM - 12
James Power
SE209 JVM - 13
James Power
The Heap
• Object information: instance field values, pointer to class, locking info, virtual
method table(?)
SE209 JVM - 14
James Power
Java Stack
SE209 JVM - 15