6. Only “javac” can generate class file?
JRuby Clojure
Jython Java Class
Groovy Scala
7. Java Class Format and Layout
Class File contains different sections.
Magic Number
Version of Class File Format
Constant Pool
Access Flags
This Class
Super Class
Interfaces
Fields
Methods
Attributes
10. Version of Class File Format
2 bytes for minor version
2 bytes for major version
Java major version starts from 45 (JDK 1.1)
Java SE 5 is 49, SE 6 is 50 (0x32), SE 7 is 51.
11. Constant Pool
2 bytes used to store constant count
Index of constant starts from 1 not 0.
12. Tag Byte Constant Type Additional Bytes
0x01 UTF8-String 2+x
0x03 Integer 4 (Big endian)
0x04 Float 4 (IEEE 754 floating-
point)
0x05 Long 8 (Big endian)
0x06 Double 8 (IEEE 754 floating-
point)
0x07 Class Reference 2
0x08 String Reference 2
0x09 Field Reference 2+2 (first 2 for class
Ref)
0x0A Method Reference 2+2 (first 2 for class
Ref)
0x0B Interface Method Ref. 2+2 (first 2 for class
Ref)
0x0C Name and Type Ref. 2+2
27. • Max Stack: 2
• Max Locals: 3
• Args Size: 2
• Code:
28. JVM Opcode
Based on stack
not register
About 200
opcode in JVM 6
29.
30. 0: push the integer in
slot 0 to stack
1: push the integer in
slot 1 to stack
2: add first 2 integers in
stack and result will be
push into stack
3: load the integer
from stack top to
integer in slot 2
4: push the integer in
slot 2 to stack
5: return an integer
33. Who can help me on this?
Magic Number
Version of Class File Format
Constant Pool
Access Flags
This Class
Super Class
Interfaces
Fields
Methods
Attributes