12. Java bytecode is the instruction set
of the Java virtual machine
opcode = 1 or 2 bytes
256 possible opcodes
198 are currently in use
51 are reserved for future use
3 are set aside as permanently unimplemented
list of all opcodes: http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html
13. variable declaration
int i;
0: iconst_0 // push 0 to top of the operand stack
1: istore_1 // Pop value from top of operand stack and
store as local variable 1
14. object instantiation
Object ftd = new Object();
0: new #2 // Class java/lang/Object
1: dup // duplicate the value on top of the stack
2: invokespecial #3 // Method java/lang/Object “<init>()V”
16. Runtime Constant Pool
The constant pool contains the following
types:
● Integer, Long, Float, Double
● String, Uft8
● Class
● NameAndType
● Fieldref, Methodref, InterfaceMethodref
17. Java Bytecode Type Description
B byte signed byte
C char Unicode character
D double double-precision floating-point value
F float single-precision floating-point value
I int integer
J long long integer
L<classname> reference an instance of class <classname>
S short signed short
Z boolean true or false
[ reference one array dimension
33. Class File Format
ClassFile {
u4 magic;
u2 minor_version;
u2 major_version;
u2 constant_pool_count;
cp_info contant_pool[constant_pool_count – 1];
u2 access_flags;
u2 this_class;
u2 super_class;
u2 interfaces_count;
u2 interfaces[interfaces_count];
u2 fields_count;
field_info fields[fields_count];
u2 methods_count;
method_info methods[methods_count];
u2 attributes_count;
attribute_info attributes[attributes_count];
}
36. JVM initialization order
1. Create a initial class using Bootstrap
classloader;
2. links the initial class;
3. initializes it;
4. and invokes the public class method void
main(String[])
37. find, check headers class file, super loading, binary created
3 steps, verifying and preparing the type and its direct supers
structurally correct, and obeys the semantic requirements
allocation of memory foe data structures
(optional) checking corrected symbolic references
executing initialization method <clinit>
41. THANK YOU!
FTD Group
JOIN US!
“And be not conformed to this world: but be ye transformed by
the renewing of your mind, that ye may prove what {is} that good,
and acceptable, and perfect, will of God.” (Romans 12:2)