Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
Inside the Java Virtual Machine
Bill Venners
Inside the Java Virtual Machine ............................................................................................1
Bill Venners...........................................................................................................................1
Preface.............................................................................................................................................25
Introduction.....................................................................................................................................27
Chapter by Chapter Summary.................................................................................................31
Part One: Javaís Architecture ..................................................................................................31
Chapter 1. Introduction to Javaís Architecture....................................................................31
Chapter 2. Platform independence ......................................................................................31
Chapter 3. Security..............................................................................................................31
Chapter 4. Network-mobility ..............................................................................................31
Part Two: Java Internals ..........................................................................................................32
Chapter 5. The Java Virtual Machine..................................................................................32
Chapter 6. The Java Class File............................................................................................32
Chapter 7. The Lifetime of a Class......................................................................................32
Chapter 8. The Linking Model............................................................................................32
Chapter 9. Garbage Collection............................................................................................32
Chapter 10. Stack and Local Variable Operations...............................................................32
Chapter 11. Type Conversion..............................................................................................33
Chapter 12. Integer Arithmetic............................................................................................33
Chapter 13. Logic................................................................................................................33
Chapter 14. Floating Point Arithmetic ................................................................................33
Chapter 15. Objects and Arrays...........................................................................................34
Chapter 16. Control Flow....................................................................................................34
Chapter 17. Exceptions .......................................................................................................34
Chapter 18. Finally Clauses ................................................................................................34
Chapter 19. Method Invocation and Return ........................................................................35
Chapter 20. Thread Synchronization...................................................................................35
The Appendices.......................................................................................................................35
Appendix A. Instruction Set by Opcode Mnemonic ...........................................................35
Appendix B. Opcode Mnemonic by Functional Group.......................................................35
Appendix C. Opcode Mnemonic by Opcode ......................................................................35
Chapter One ....................................................................................................................................36
Introduction to Java’s Architecture .........................................................................................36
Chapter Two....................................................................................................................................61
Platform Independence ...........................................................................................................61
Chapter Three..................................................................................................................................76
Security ...................................................................................................................................76
Chapter Four ...................................................................................................................................96
Network mobility ....................................................................................................................96
1
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
Chapter Five..................................................................................................................................109
The Java Virtual Machine .....................................................................................................109
Chapter Six....................................................................................................................................179
The Java Class File ...............................................................................................................179
Chapter Seven ...............................................................................................................................230
The Lifetime of a Class.........................................................................................................230
Chapter Eight ................................................................................................................................304
The Linking Model ...............................................................................................................304
Chapter Nine .................................................................................................................................427
Garbage Collection ...............................................................................................................427
Chapter Ten...................................................................................................................................446
Stack and Local Variable Operations ....................................................................................446
Chapter Eleven..............................................................................................................................462
Type Conversion ...................................................................................................................462
Chapter Twelve .............................................................................................................................476
Integer Arithmetic .................................................................................................................476
Chapter Thirteen ...........................................................................................................................492
Logic .....................................................................................................................................492
Chapter Fourteen...........................................................................................................................501
Floating-Point Arithmetic .....................................................................................................501
Chapter Fifteen..............................................................................................................................515
Objects and Arrays................................................................................................................515
Chapter Sixteen.............................................................................................................................532
Control Flow .........................................................................................................................532
Chapter Seventeen.........................................................................................................................544
Exceptions.............................................................................................................................544
Chapter Eighteen...........................................................................................................................567
Finally Clauses......................................................................................................................567
Chapter Nineteen...........................................................................................................................588
Method Invocation and Return..............................................................................................588
Chapter Twenty .............................................................................................................................624
Thread Synchronization ........................................................................................................624
Appendix A ...................................................................................................................................654
Instruction Set by Opcode Mnemonic...................................................................................654
aaload ............................................................................................................................656
Opcode: .............................................................................................................................656
Instruction Format:............................................................................................................657
Stack:.................................................................................................................................657
Description: ......................................................................................................................657
aastore..........................................................................................................................657
Opcode:.............................................................................................................................657
Instruction Format:...........................................................................................................658
Stack:.................................................................................................................................658
Description: ......................................................................................................................658
2
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
aconst_null ................................................................................................................659
Opcode:.............................................................................................................................659
Instruction Format:...........................................................................................................659
Stack:.................................................................................................................................659
Description: ......................................................................................................................659
aload...............................................................................................................................659
Opcode:.............................................................................................................................659
Instruction Format:...........................................................................................................660
Stack:.................................................................................................................................660
Description: ......................................................................................................................660
aload_0..........................................................................................................................660
Opcode:.............................................................................................................................661
Instruction Format:...........................................................................................................661
Stack:.................................................................................................................................661
Description: ......................................................................................................................661
aload_1..........................................................................................................................661
Opcode:.............................................................................................................................662
Instruction Format:...........................................................................................................662
Stack:.................................................................................................................................662
Description: ......................................................................................................................662
aload_2..........................................................................................................................662
Opcode:.............................................................................................................................663
Instruction Format:...........................................................................................................663
Stack:.................................................................................................................................663
Description: ......................................................................................................................663
aload_3..........................................................................................................................663
Opcode:.............................................................................................................................664
Instruction Format:...........................................................................................................664
Stack:.................................................................................................................................664
Description: ......................................................................................................................664
anewarray .....................................................................................................................664
Opcode:.............................................................................................................................665
Instruction Format:...........................................................................................................665
Stack:.................................................................................................................................665
Description: ......................................................................................................................665
areturn..........................................................................................................................666
Opcode:..........................................................................................................................666
Instruction Format: .............................................................................................666
Stack: ............................................................................................................................666
Description:..............................................................................................................666
arraylength ................................................................................................................666
Opcode:..........................................................................................................................666
Instruction Format: .............................................................................................667
Stack: ............................................................................................................................667
3
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
Description:..............................................................................................................667
astore ............................................................................................................................667
Opcode:..........................................................................................................................667
Instruction Format: .............................................................................................667
Stack: ............................................................................................................................667
Description:..............................................................................................................667
astore_0 .......................................................................................................................668
Opcode:..........................................................................................................................668
Instruction Format: .............................................................................................668
Stack: ............................................................................................................................668
Description:..............................................................................................................668
astore_1 .......................................................................................................................669
Opcode:..........................................................................................................................669
Instruction Format: .............................................................................................669
Stack: ............................................................................................................................669
Description:..............................................................................................................669
astore_2 .......................................................................................................................669
Opcode:..........................................................................................................................669
Instruction Format: .............................................................................................669
Stack: ............................................................................................................................669
Description:..............................................................................................................670
astore_3 .......................................................................................................................670
Opcode:..........................................................................................................................670
Instruction Format: .............................................................................................670
Stack: ............................................................................................................................670
Description:..............................................................................................................670
athrow ............................................................................................................................671
Opcode:..........................................................................................................................671
Instruction Format: .............................................................................................671
Stack: ............................................................................................................................671
Description:..............................................................................................................671
baload ............................................................................................................................672
Opcode:..........................................................................................................................672
Instruction Format: .............................................................................................672
Stack: ............................................................................................................................672
Description:..............................................................................................................672
bastore..........................................................................................................................673
Opcode:..........................................................................................................................673
Instruction Format: .............................................................................................673
Stack: ............................................................................................................................673
Description:..............................................................................................................673
bipush ............................................................................................................................673
Opcode:..........................................................................................................................673
Instruction Format: .............................................................................................674
4
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
Stack: ............................................................................................................................674
Description:..............................................................................................................674
caload ............................................................................................................................674
Opcode:..........................................................................................................................674
Instruction Format: .............................................................................................674
Stack: ............................................................................................................................674
Description:..............................................................................................................674
castore..........................................................................................................................675
Opcode:..........................................................................................................................675
Instruction Format: .............................................................................................675
Stack: ............................................................................................................................675
Description:..............................................................................................................675
checkcast .....................................................................................................................675
Opcode:..........................................................................................................................676
Instruction Format: .............................................................................................676
Stack: ............................................................................................................................676
Description:..............................................................................................................676
d2f ...................................................................................................................................677
Opcode:..........................................................................................................................677
Instruction Format: .............................................................................................677
Stack: ............................................................................................................................677
Description:..............................................................................................................677
d2i ...................................................................................................................................678
Opcode:..........................................................................................................................678
Instruction Format: .............................................................................................678
Stack: ............................................................................................................................678
Description:..............................................................................................................678
d2l ...................................................................................................................................679
Opcode:..........................................................................................................................679
Instruction Format: .............................................................................................679
Stack: ............................................................................................................................679
Description:..............................................................................................................679
dadd.................................................................................................................................680
Opcode:..........................................................................................................................680
Instruction Format: .............................................................................................680
Stack: ............................................................................................................................680
Description:..............................................................................................................680
daload ............................................................................................................................680
Opcode:..........................................................................................................................681
Instruction Format: .............................................................................................681
Stack: ............................................................................................................................681
Description:..............................................................................................................681
dastore..........................................................................................................................681
Opcode:..........................................................................................................................681
5
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
Instruction Format: .............................................................................................681
Stack: ............................................................................................................................681
Description:..............................................................................................................682
dcmpg...............................................................................................................................682
Opcode:..........................................................................................................................682
Instruction Format: .............................................................................................682
Stack: ............................................................................................................................682
Description:..............................................................................................................682
dcmpl...............................................................................................................................683
Opcode:..........................................................................................................................683
Instruction Format: .............................................................................................683
Stack: ............................................................................................................................683
Description:..............................................................................................................683
dconst_0 .......................................................................................................................684
Opcode:..........................................................................................................................684
Instruction Format: .............................................................................................684
Stack: ............................................................................................................................684
Description: ......................................................................................................................684
dconst_1 .......................................................................................................................684
Opcode:.............................................................................................................................684
Instruction Format:...........................................................................................................685
Stack:.................................................................................................................................685
Description: ......................................................................................................................685
ddiv.................................................................................................................................685
Opcode:.............................................................................................................................685
Instruction Format:...........................................................................................................685
Stack:.................................................................................................................................685
Description: ......................................................................................................................686
dload...............................................................................................................................686
Opcode:.............................................................................................................................686
Instruction Format:...........................................................................................................686
Stack:.................................................................................................................................686
Description: ......................................................................................................................686
dload_0..........................................................................................................................687
Opcode:.............................................................................................................................687
Instruction Format:...........................................................................................................687
Stack:.................................................................................................................................687
Description: ......................................................................................................................687
dload_1..........................................................................................................................688
Opcode:.............................................................................................................................688
Instruction Format:...........................................................................................................688
Stack:.................................................................................................................................688
Description: ......................................................................................................................688
dload_2..........................................................................................................................688
6
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
Opcode:.............................................................................................................................688
Instruction Format:...........................................................................................................688
Stack:.................................................................................................................................689
Description: ......................................................................................................................689
dload_3..........................................................................................................................689
Opcode:.............................................................................................................................689
Instruction Format:...........................................................................................................689
Stack:.................................................................................................................................689
Description: ......................................................................................................................689
dmul.................................................................................................................................690
Opcode:.............................................................................................................................690
Instruction Format:...........................................................................................................690
Stack:.................................................................................................................................690
Description: ......................................................................................................................690
dneg.................................................................................................................................691
Opcode:.............................................................................................................................691
Instruction Format:...........................................................................................................691
Stack:.................................................................................................................................691
Description: ......................................................................................................................691
drem.................................................................................................................................692
Opcode:.............................................................................................................................692
Instruction Format:...........................................................................................................692
Stack:.................................................................................................................................692
Description: ......................................................................................................................692
dreturn..........................................................................................................................693
Opcode:.............................................................................................................................693
Instruction Format:...........................................................................................................693
Stack:.................................................................................................................................693
Description: ......................................................................................................................693
dstore ............................................................................................................................694
Opcode:.............................................................................................................................694
Instruction Format:...........................................................................................................694
Stack:.................................................................................................................................694
Description: ......................................................................................................................694
dstore_0 .......................................................................................................................694
Opcode:.............................................................................................................................695
Instruction Format:...........................................................................................................695
Stack:.................................................................................................................................695
Description: ......................................................................................................................695
dstore_1 .......................................................................................................................695
Opcode:.............................................................................................................................695
Instruction Format:...........................................................................................................695
Stack:.................................................................................................................................696
Description: ......................................................................................................................696
7
Generated by Foxit PDF Creator © Foxit Software
http://www.foxitsoftware.com For evaluation only.
dstore_2 .......................................................................................................................696
Opcode:.............................................................................................................................696
Instruction Format:...........................................................................................................696
Stack:.................................................................................................................................696
Description: ......................................................................................................................696
dstore_3 .......................................................................................................................697
Opcode:.............................................................................................................................697
Instruction Format:...........................................................................................................697
Stack:.................................................................................................................................697
Description: ......................................................................................................................697
dsub.................................................................................................................................698
Opcode:.............................................................................................................................698
Instruction Format:...........................................................................................................698
Stack:.................................................................................................................................698
Description: ......................................................................................................................698
dup ...................................................................................................................................698
Opcode:.............................................................................................................................699
Instruction Format:...........................................................................................................699
Stack:.................................................................................................................................699
Description: ......................................................................................................................699
dup_x1 ............................................................................................................................699
Opcode:.............................................................................................................................699
Instruction Format:...........................................................................................................699
Stack:.................................................................................................................................700
Description: ......................................................................................................................700
dup_x2 ............................................................................................................................700
Opcode:.............................................................................................................................700
Instruction Format:...........................................................................................................700
Stack:.................................................................................................................................700
Description: ......................................................................................................................700
dup2.................................................................................................................................701
Opcode:.............................................................................................................................701
Instruction Format:...........................................................................................................701
Stack:.................................................................................................................................701
Description: ......................................................................................................................701
dup2_x1..........................................................................................................................702
Opcode:.............................................................................................................................702
Instruction Format:...........................................................................................................702
Stack:.................................................................................................................................702
Description: ......................................................................................................................702
dup2_x2..........................................................................................................................702
Opcode:.............................................................................................................................703
Instruction Format:...........................................................................................................703
Stack:.................................................................................................................................703
8