Professional Documents
Culture Documents
JVM - Java Virtual Machine
JVM - Java Virtual Machine
A platform independent
Instruction Set is needed.
29 / 43
Java Bytecode: A platform independent Instruction Set
• Instruction Set:
Arithmetic,
Load and store,
Type conversion
Object creation and manipulation
Operand stack manipulation
Control transfer
Method invocation and return
• Arithmetic Instruction:
Operate on the values from the stack Who executes Java Bytecode?
Push the result back onto the stack
Instructions for int, long, float and double
No direct support for byte, short or char types
Handled by int operations and type conversion
30 / 43
• Java class file starts with a header,
Java Class File Format
containing a "magic number" (0xCAFEBABE)
and the version number.
• A list of interfaces
implemented by the class.
31 / 43
java -classpath ${java_home}/rt.jar myapp
32 / 43
• Loading:
Finding and importing the binary data for a type.
• Linking:
Performing verification, preparation,
and (optionally) resolution.
• Linking (Verification):
Ensuring the correctness of the imported type.
• Linking (Preparation):
Allocating memory for class variables,
and initializing the memory to default values.
• Linking (Resolution):
Transforming symbolic references
from the type into direct references.
• Initialization:
Invoking Java code that initializes class variables Java ClassLoader
to their proper starting values.
33 / 43