SlideShare une entreprise Scribd logo
1  sur  36
Let’s Talk about
Java Class File
Yongqiang Li
Outlines
 Brief
      Introduction to Java Class File
 Java Class Format and Layout
 References
Brief Introduction to Java Class
 File
 Has  .class extension
 Compiled from java source files (.java)
 Platform-independent
 Machine-readable
 Stores so-called “bytecodes”
Java Source File (ClassA.java)

                                      javac ClassA.java




     Java Class File (ClassA.class)
 Bytecode
 Only   “javac” can generate class file?

          JRuby                   Clojure




Jython             Java Class


          Groovy                   Scala
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
Magic Number
4 bytes
 Always “CAFEBABE” ( 咖啡宝贝 )
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.
Constant Pool
2  bytes used to store constant count
 Index of constant starts from 1 not 0.
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
 Constant    Count




 0x0021(hex) = 33 (dec)
 Double




           • 0x06: Double Tag
           • 0x4000 1893 74bc 6a7f: 2.012
• 0x01: UTF-8 Tag
 UTF-8   • 0x0006: “String” has 6 char.
          • 0x5374 7269 6367: “String”
 More   Strings
    Field/Method
     Name
    Field/Method
     Type
    Attribute Name
 Class   Reference




                      • 0x07: Class Ref Tag
                      • 0x0002: Constant Index
Access Flags

 For Class
 2 Bytes
This and Super
  Both  are 2 bytes
  Direct to Class Reference in Constant
   Pool.




This Ref: 0x0001
Super Ref: 0x0003
Interfaces
2  bytes for count of interfaces
 2 * interfaces_count bytes
Fields
2  bytes for fields count
 field_info * fields_count
 Attribute   Structure
 Field   Access
     2 bytes
•   0x0001: Only 1 Field
•   0x0019: public static final
•   0x0005: “obj”
•   0x0006: Descriptor “Ljava/lang/Object;”
•   0x0002: 2 Attributes
     • 1st: 0x0007 (Deprecated)
     • 2nd: 0x0008 (RuntimeVisibleAnnotations)
Methods
2 bytes for methods count
 method_info * methods_count

                          Method Access Flags
 Method Attributes
 CodeAttributes
•   Max Stack: 2
•   Max Locals: 3
•   Args Size: 2
•   Code:
 JVM   Opcode
    Based on stack
     not register
    About 200
     opcode in JVM 6
 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
 Exception   Attributes
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
References
 JVM
    6 Specification
 《深入浅出 Java 虚拟机》
Let's talk about java class file

Contenu connexe

Tendances

Core Java Basics
Core Java BasicsCore Java Basics
Core Java Basicsmhtspvtltd
 
9781439035665 ppt ch08
9781439035665 ppt ch089781439035665 ppt ch08
9781439035665 ppt ch08Terry Yoast
 
Fundamentals of oop lecture 2
Fundamentals of oop lecture 2Fundamentals of oop lecture 2
Fundamentals of oop lecture 2miiro30
 
Ifi7184 lesson7
Ifi7184 lesson7Ifi7184 lesson7
Ifi7184 lesson7Sónia
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streamsbabak danyal
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMmanish kumar
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)arvind pandey
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?kanchanmahajan23
 

Tendances (10)

Java Advanced Features
Java Advanced FeaturesJava Advanced Features
Java Advanced Features
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java Basics
 
9781439035665 ppt ch08
9781439035665 ppt ch089781439035665 ppt ch08
9781439035665 ppt ch08
 
Chap01
Chap01Chap01
Chap01
 
Fundamentals of oop lecture 2
Fundamentals of oop lecture 2Fundamentals of oop lecture 2
Fundamentals of oop lecture 2
 
Ifi7184 lesson7
Ifi7184 lesson7Ifi7184 lesson7
Ifi7184 lesson7
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
What is java input and output stream?
What is java input and output stream?What is java input and output stream?
What is java input and output stream?
 

Similaire à Let's talk about java class file

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
 
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
 
บทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูล
บทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูลบทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูล
บทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูลPriew Chakrit
 
4.เพิ่มข้อมูลลง DB ด้วย JSP&SQL
4.เพิ่มข้อมูลลง DB ด้วย JSP&SQL4.เพิ่มข้อมูลลง DB ด้วย JSP&SQL
4.เพิ่มข้อมูลลง DB ด้วย JSP&SQLsquall1735
 
บท4
บท4บท4
บท4bank_b
 
Java input output package
Java input output packageJava input output package
Java input output packageSujit Kumar
 
Harder Faster Stronger
Harder Faster StrongerHarder Faster Stronger
Harder Faster Strongersnyff
 
ORC File & Vectorization - Improving Hive Data Storage and Query Performance
ORC File & Vectorization - Improving Hive Data Storage and Query PerformanceORC File & Vectorization - Improving Hive Data Storage and Query Performance
ORC File & Vectorization - Improving Hive Data Storage and Query PerformanceDataWorks Summit
 
ORC File and Vectorization - Hadoop Summit 2013
ORC File and Vectorization - Hadoop Summit 2013ORC File and Vectorization - Hadoop Summit 2013
ORC File and Vectorization - Hadoop Summit 2013Owen O'Malley
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryPray Desai
 
Lecture 8 strings and characters
Lecture 8  strings and charactersLecture 8  strings and characters
Lecture 8 strings and charactersalvin567
 

Similaire à Let's talk about java class file (20)

บทที่4
บทที่4บทที่4
บทที่4
 
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
 
Java Day-6
Java Day-6Java Day-6
Java Day-6
 
บทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูล
บทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูลบทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูล
บทที่ 4 การเพิ่มข้อมูลลงฐานข้อมูล
 
4.เพิ่มข้อมูลลง DB ด้วย JSP&SQL
4.เพิ่มข้อมูลลง DB ด้วย JSP&SQL4.เพิ่มข้อมูลลง DB ด้วย JSP&SQL
4.เพิ่มข้อมูลลง DB ด้วย JSP&SQL
 
บท4
บท4บท4
บท4
 
บท4
บท4บท4
บท4
 
Introduction_to_Java.ppt
Introduction_to_Java.pptIntroduction_to_Java.ppt
Introduction_to_Java.ppt
 
Java input output package
Java input output packageJava input output package
Java input output package
 
Java quick reference v2
Java quick reference v2Java quick reference v2
Java quick reference v2
 
java training faridabad
java training faridabadjava training faridabad
java training faridabad
 
Java quickref
Java quickrefJava quickref
Java quickref
 
Harder Faster Stronger
Harder Faster StrongerHarder Faster Stronger
Harder Faster Stronger
 
Java14
Java14Java14
Java14
 
Java Tutorials
Java Tutorials Java Tutorials
Java Tutorials
 
ORC File & Vectorization - Improving Hive Data Storage and Query Performance
ORC File & Vectorization - Improving Hive Data Storage and Query PerformanceORC File & Vectorization - Improving Hive Data Storage and Query Performance
ORC File & Vectorization - Improving Hive Data Storage and Query Performance
 
ORC File and Vectorization - Hadoop Summit 2013
ORC File and Vectorization - Hadoop Summit 2013ORC File and Vectorization - Hadoop Summit 2013
ORC File and Vectorization - Hadoop Summit 2013
 
Scala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud FoundryScala, Play 2.0 & Cloud Foundry
Scala, Play 2.0 & Cloud Foundry
 
Lecture 8 strings and characters
Lecture 8  strings and charactersLecture 8  strings and characters
Lecture 8 strings and characters
 

Plus de Yongqiang Li

How to Recognize Henry's Face
How to Recognize Henry's FaceHow to Recognize Henry's Face
How to Recognize Henry's FaceYongqiang Li
 
Introduction to Boost regex
Introduction to Boost regexIntroduction to Boost regex
Introduction to Boost regexYongqiang Li
 
Let's talk about java class loader
Let's talk about java class loaderLet's talk about java class loader
Let's talk about java class loaderYongqiang Li
 
Brief introduction to domain-driven design
Brief introduction to domain-driven designBrief introduction to domain-driven design
Brief introduction to domain-driven designYongqiang Li
 
Eclipse GEF (Part I)
Eclipse GEF (Part I)Eclipse GEF (Part I)
Eclipse GEF (Part I)Yongqiang Li
 
Garbage Collection of Java VM
Garbage Collection of Java VMGarbage Collection of Java VM
Garbage Collection of Java VMYongqiang Li
 
Let's talk about jni
Let's talk about jniLet's talk about jni
Let's talk about jniYongqiang Li
 

Plus de Yongqiang Li (8)

Why Kotlin?
Why Kotlin?Why Kotlin?
Why Kotlin?
 
How to Recognize Henry's Face
How to Recognize Henry's FaceHow to Recognize Henry's Face
How to Recognize Henry's Face
 
Introduction to Boost regex
Introduction to Boost regexIntroduction to Boost regex
Introduction to Boost regex
 
Let's talk about java class loader
Let's talk about java class loaderLet's talk about java class loader
Let's talk about java class loader
 
Brief introduction to domain-driven design
Brief introduction to domain-driven designBrief introduction to domain-driven design
Brief introduction to domain-driven design
 
Eclipse GEF (Part I)
Eclipse GEF (Part I)Eclipse GEF (Part I)
Eclipse GEF (Part I)
 
Garbage Collection of Java VM
Garbage Collection of Java VMGarbage Collection of Java VM
Garbage Collection of Java VM
 
Let's talk about jni
Let's talk about jniLet's talk about jni
Let's talk about jni
 

Dernier

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Dernier (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Let's talk about java class file

  • 1. Let’s Talk about Java Class File Yongqiang Li
  • 2. Outlines  Brief Introduction to Java Class File  Java Class Format and Layout  References
  • 3. Brief Introduction to Java Class File  Has .class extension  Compiled from java source files (.java)  Platform-independent  Machine-readable  Stores so-called “bytecodes”
  • 4. Java Source File (ClassA.java) javac ClassA.java Java Class File (ClassA.class)
  • 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
  • 8.
  • 9. Magic Number 4 bytes  Always “CAFEBABE” ( 咖啡宝贝 )
  • 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
  • 13.  Constant Count 0x0021(hex) = 33 (dec)
  • 14.  Double • 0x06: Double Tag • 0x4000 1893 74bc 6a7f: 2.012
  • 15. • 0x01: UTF-8 Tag  UTF-8 • 0x0006: “String” has 6 char. • 0x5374 7269 6367: “String”
  • 16.  More Strings  Field/Method Name  Field/Method Type  Attribute Name
  • 17.  Class Reference • 0x07: Class Ref Tag • 0x0002: Constant Index
  • 18. Access Flags  For Class  2 Bytes
  • 19. This and Super  Both are 2 bytes  Direct to Class Reference in Constant Pool. This Ref: 0x0001 Super Ref: 0x0003
  • 20. Interfaces 2 bytes for count of interfaces  2 * interfaces_count bytes
  • 21. Fields 2 bytes for fields count  field_info * fields_count
  • 22.  Attribute Structure
  • 23.  Field Access  2 bytes
  • 24. 0x0001: Only 1 Field • 0x0019: public static final • 0x0005: “obj” • 0x0006: Descriptor “Ljava/lang/Object;” • 0x0002: 2 Attributes • 1st: 0x0007 (Deprecated) • 2nd: 0x0008 (RuntimeVisibleAnnotations)
  • 25. Methods 2 bytes for methods count  method_info * methods_count Method Access Flags
  • 26.  Method Attributes  CodeAttributes
  • 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
  • 31.
  • 32.  Exception Attributes
  • 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
  • 34.
  • 35. References  JVM 6 Specification  《深入浅出 Java 虚拟机》