JVM Overview References Virtual Machine Background JVM: operational view JVM: structural view Concluding remarks
Reading List <ul><li>Primary: </li></ul><ul><ul><li>LY99 Chapter 3. Structure of the Java Virtual Machine </li></ul></ul><...
What is a virtual machine? <ul><li>David Gelernter: Truth, beauty, and VMs </li></ul><ul><ul><li>“ A running program is of...
Design Goals <ul><li>abstract enough </li></ul><ul><li>close enough to the hardware </li></ul><ul><li>question: what is th...
What is the JVM?
Key Distinction <ul><li>what is the specification? </li></ul><ul><li>what is the implementation? </li></ul><ul><ul><li>obj...
JVM: View  <ul><li>from the language point of view </li></ul><ul><li>trace the lifetime of a virtual machine </li></ul><ul...
VM in action <ul><li>invoked “java Test args” </li></ul><ul><li>attempts to find class Test </li></ul><ul><li>VM uses the ...
Loading <ul><li>check whether already loaded </li></ul><ul><li>if not, invoke the appropriate loader.loadClass </li></ul><...
Link <ul><li>Link = verification, preparation, resolution </li></ul><ul><li>Verification: semantic checks, proper symbol t...
Initialization <ul><li>initialize class variables, static initializers </li></ul><ul><li>direct superclass need to be init...
Example class Super { static { System.out.print(“Super “); } class One { static { System.out.print(“One “); } class Two ex...
Example class Super { static int taxi = 1729; } class Sub extends Super { static { System.out.print(“Sub “); } class Test ...
Creation of new instances <ul><li>instance creation expressions: new </li></ul><ul><li>Class.newInstance() </li></ul><ul><...
Finalization <ul><li>invoked just before garbage collection </li></ul><ul><li>language does not specify when it is invoked...
VM Exit <ul><li>classFinalize similar to object finalization </li></ul><ul><li>class can be unloaded when </li></ul><ul><u...
Upcoming SlideShare
Loading in …5
×

testing ppt

333
-1

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
333
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

testing ppt

  1. 1. JVM Overview References Virtual Machine Background JVM: operational view JVM: structural view Concluding remarks
  2. 2. Reading List <ul><li>Primary: </li></ul><ul><ul><li>LY99 Chapter 3. Structure of the Java Virtual Machine </li></ul></ul><ul><ul><li>Venners98 Chapter 5. The Java Virtual Machine </li></ul></ul><ul><ul><li>GJS96 Chapter 12: Execution </li></ul></ul><ul><li>Other references </li></ul><ul><ul><li>Survey of VM Research 1974 </li></ul></ul><ul><ul><ul><li>“ Virtual machines have finally arrived. Dismissed for a number of years as academic curiosities, they are now seen as cost effective techniques for organizing computer systems…” </li></ul></ul></ul><ul><ul><li>Inferno Virtual Machine </li></ul></ul><ul><ul><li>Oak Intermediate Bytecode </li></ul></ul><ul><ul><li>Variety of web-sites </li></ul></ul>
  3. 3. What is a virtual machine? <ul><li>David Gelernter: Truth, beauty, and VMs </li></ul><ul><ul><li>“ A running program is often referred to as a VM -- a machine that doesn’t exist as a matter of actual physical reality. The virtual machine idea is … most elegant in the history of technology … a crucial step in the evolution of ideas about software.” </li></ul></ul><ul><li>an operating system </li></ul><ul><li>a control program to run multiple operating systems </li></ul>
  4. 4. Design Goals <ul><li>abstract enough </li></ul><ul><li>close enough to the hardware </li></ul><ul><li>question: what is the intended use? </li></ul><ul><li>Inferno: run OS code </li></ul><ul><li>JVM: run application code </li></ul>
  5. 5. What is the JVM?
  6. 6. Key Distinction <ul><li>what is the specification? </li></ul><ul><li>what is the implementation? </li></ul><ul><ul><li>object layout is not part of the specification </li></ul></ul><ul><ul><li>garbage collection is not part of the spec </li></ul></ul>
  7. 7. JVM: View <ul><li>from the language point of view </li></ul><ul><li>trace the lifetime of a virtual machine </li></ul><ul><li>invocation, loading-linking, object lifetime, exit </li></ul>
  8. 8. VM in action <ul><li>invoked “java Test args” </li></ul><ul><li>attempts to find class Test </li></ul><ul><li>VM uses the class loader </li></ul><ul><li>Link </li></ul><ul><li>Initialize </li></ul><ul><li>Invoke Test.main </li></ul>
  9. 9. Loading <ul><li>check whether already loaded </li></ul><ul><li>if not, invoke the appropriate loader.loadClass </li></ul><ul><li>internal table is part of the specification? </li></ul><ul><li>class loader flexibility: prefetch, load a bunch </li></ul><ul><li>prefetching can be non-transparent! </li></ul><ul><li>errors, however, need to be reported separately </li></ul><ul><li>class loader hooks: defineClass, findSystemClass, resolveClass </li></ul>
  10. 10. Link <ul><li>Link = verification, preparation, resolution </li></ul><ul><li>Verification: semantic checks, proper symbol table </li></ul><ul><ul><li>proper opcodes, good branch targets </li></ul></ul><ul><ul><li>conservation of stack depth </li></ul></ul><ul><li>Preparation: allocation of storage (method tables) </li></ul><ul><li>Resolution: resolve symbol references, check access, check concreteness </li></ul><ul><li>Resolution: eager vs lazy strategy </li></ul>
  11. 11. Initialization <ul><li>initialize class variables, static initializers </li></ul><ul><li>direct superclass need to be initialized prior </li></ul><ul><li>happens on direct use: method invocation, construction, field access </li></ul><ul><li>synchronized initializations: state in Class object </li></ul><ul><ul><li>check for recursive initializations </li></ul></ul>
  12. 12. Example class Super { static { System.out.print(“Super “); } class One { static { System.out.print(“One “); } class Two extends Super { static { System.out.print(“Two “); } class Test { public static void main(String[] args) { One o = null; Two t = new Two(); System.out.println((Object)o == (Object)t); } }
  13. 13. Example class Super { static int taxi = 1729; } class Sub extends Super { static { System.out.print(“Sub “); } class Test { public static void main(String[] args) { System.out.println(Sub.taxi); } }
  14. 14. Creation of new instances <ul><li>instance creation expressions: new </li></ul><ul><li>Class.newInstance() </li></ul><ul><li>string literals, concatenation operations </li></ul><ul><li>order: </li></ul><ul><ul><li>default field values </li></ul></ul><ul><ul><li>invoke constructor </li></ul></ul><ul><ul><li>invoke another constructor of this class </li></ul></ul><ul><ul><li>invoke super’s constructors </li></ul></ul><ul><ul><li>initialize instance variables </li></ul></ul><ul><ul><li>execute rest of the constructor </li></ul></ul>
  15. 15. Finalization <ul><li>invoked just before garbage collection </li></ul><ul><li>language does not specify when it is invoked </li></ul><ul><li>also does not specify which thread </li></ul><ul><li>no automatic invocation of super’s finalizers </li></ul><ul><li>very tricky! </li></ul>void finalize() { classVariable = field; // field is now reachable }
  16. 16. VM Exit <ul><li>classFinalize similar to object finalization </li></ul><ul><li>class can be unloaded when </li></ul><ul><ul><li>no instances exist </li></ul></ul><ul><ul><li>class object is unreachable </li></ul></ul><ul><li>VM exits when: </li></ul><ul><ul><li>all its threads terminate </li></ul></ul><ul><ul><li>Runtime.exit or System.exit assuming it is secure </li></ul></ul><ul><li>finalizers can be optionally invoked on all objects just before exit </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×