SlideShare una empresa de Scribd logo
1 de 36
Lecture 14 Java Virtual Machine  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1
Java Program ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],2
Java ByteCode ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],3
Java ByteCode ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],3
Internal Architecture of JVM Execution engine Class loader subsystem method area heap Java stacks pc registers native method stacks Runtime data area class files Native  Method Interface Native Method Libraries
Internal Architecture of JVM ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JVM Execution ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Runtime Data Area Shared among threads class  data class  data class  data class  data class  data class  data Method area object object object object object object object object object heap
Threads  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thread’s Runtime Data Area thread 1 thread 2 thread 3 pc registers stack  frame stack  frame stack  frame stack  frame thread 1 stack  frame stack  frame stack  frame thread 2 java stacks stack  frame stack  frame thread 3 thread 3 native  method stacks
Thread’s Runtime Data Area ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Loader Subsystem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Loader Subsystem B. Linking:  2. Preparation:  A. allocating memory for class variables   and initializing the memory to default values. B. allocating data structures that are used internally    by the virtual machine:   1. method tables.   2. data structure that allows any method to be  invoked on instances of a class without  requiring a search of superclasses at invocation  time.
Class Loader Subsystem B. Linking:  3. Resolution:  A. transforming symbolic references (e.g. class.field)   into direct references. B. symbolic reference is replaced with a direct    reference that can be more efficiently processed    if the reference is used repeatedly.    (Quick instructions) C. Implementation choice:  static linkage vs. laziest resolution
Class Loader Subsystem C. Initialization: invoke java code that initializes class  variables to their proper staring values. A. execution of any class variable initializers  B. Before a class can be initialized, its direct superclass  must be initialized, as well as the direct superclass  of its direct superclass, and so on, recursively. C. Initialization may cause loading, linking, and initialization errors D. Because Java is multithreaded, initialization of a  class or interface requires careful synchronization.
Class Loader Subsystem ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Loader Subsystem ,[object Object],[object Object],[object Object],[object Object],[object Object]
Method Area ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Type Information stored in Method Area ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Type Information stored in Method Area ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Method Table ,[object Object],[object Object],[object Object],[object Object],[object Object]
Heap ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Object Representation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ptr to object pool ptr to class data the handle pool the heap instance data instance data instance data instance data the object pool class data the method area ptr to handle pool an object reference ,[object Object]
ptr to class data the heap instance data instance data instance data instance data The method area class  data ptr to heap an object reference Keeping object data all in one place.
prt to class data length=(2) ar[0] (ref)  ar[1] (ref) the heap prt to class data length=(2) ar[0][0](int)  ar[0][1] (int) prt to class data length=(2) ar[1][0] (int) ar[1][1] (int) class  data for  [[I class  data for  [I the method area ar (an array ref) int [ ] [ ] ar= new int [2][2]; One possible heap representation for arrays.
prt to full class data prt to method data prt to method data prt to method data ● ● ● entry point  into all data  for the class method  data method  data method  data prt to special structure instance data instance data the heap ptr into heap method  table the method area Keeping the method table close at hand.
Object Representation ,[object Object],[object Object],[object Object],[object Object],[object Object]
Program Counter ,[object Object],[object Object],[object Object],[object Object]
Java Stack ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
type long float double reference int type index 0 1 3 4 6 7 parameter int i long l float f double d Object o byte b reference int double int int type index 0 1 2 4 5 parameter hidden this char c short s boolean b double d runClassMethod() runInstanceMethod() Class Example3a {  // local variable in stack frame public static int runClassMethod(int i, long l, float f, double d, Object o, byte b) { return 0;} public int runInstanceMethod(int i, double d, short s, boolean b) { return 0;} }
100 98 0 1 2 local  variables operand  stack 100 98 100 0 1 2 100 98 100 98 0 1 2 100 98 198 0 1 2 100 98 198 0 1 2 before  starting after  iload_0 after  iload_1 after  iadd after  istore_2 iload_0 // push local variable 0 (an int)  iload_1 // push local variable 1 (an int) iadd  // pop two ints, add them and push result istore_2 // pop int, store into  local variable 2
Class Example3c { public static void addAndPrint() { double result = addTwoTypes(1, 88.88); System.out.println(result); } public static double addTwoTypes (int i, double d) { return i + d; } } Java Stack Example
1 88.88 0 1 0 1 1 88.88 0 1 89.88 0 1 before invoke  addTwoTypes()  After invoke  addTwoTypes()  addTwoTypes() returns frames for  addAndPrint( ) frame for  addTwoTypes( ) local  variables frame data operand  stack
0 1 0 1 0 1 before invoke  addTwoTypes()  After invoke  addTwoTypes()  addTwoTypes() returns frames for  addAndPrint( ) frame for  addTwoTypes( ) 1 88.88 1 88.88 89.88
stack frame stack frame stack frame stack frame Java stacks a native method  stack this Java method invokes  a native method. the current frame This C function invokes another C function This C function invokes a Java  method

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

More topics on Java
More topics on JavaMore topics on Java
More topics on Java
 
Oops
OopsOops
Oops
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
Core java
Core javaCore java
Core java
 
Java Tutorials
Java Tutorials Java Tutorials
Java Tutorials
 
Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)Java Beans Unit 4(Part 1)
Java Beans Unit 4(Part 1)
 
Io streams
Io streamsIo streams
Io streams
 
Ppt chapter03
Ppt chapter03Ppt chapter03
Ppt chapter03
 
Java API, Exceptions and IO
Java API, Exceptions and IOJava API, Exceptions and IO
Java API, Exceptions and IO
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Jist of Java
Jist of JavaJist of Java
Jist of Java
 
JAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICESJAVA CONCEPTS AND PRACTICES
JAVA CONCEPTS AND PRACTICES
 
Taking User Input in Java
Taking User Input in JavaTaking User Input in Java
Taking User Input in Java
 
Basic of Javaio
Basic of JavaioBasic of Javaio
Basic of Javaio
 
Lecture d-inheritance
Lecture d-inheritanceLecture d-inheritance
Lecture d-inheritance
 
Unit 2 Java
Unit 2 JavaUnit 2 Java
Unit 2 Java
 
Java Threads
Java ThreadsJava Threads
Java Threads
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Objective-c for Java Developers
Objective-c for Java DevelopersObjective-c for Java Developers
Objective-c for Java Developers
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 

Similar a Java14

Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1Todor Kolev
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction AKR Education
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAVINASH KUMAR
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satyaSatya Johnny
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 
OOPs - JAVA Quick Reference.pdf
OOPs - JAVA Quick Reference.pdfOOPs - JAVA Quick Reference.pdf
OOPs - JAVA Quick Reference.pdfArthyR3
 
Java quick reference
Java quick referenceJava quick reference
Java quick referenceArthyR3
 
Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performanceRoger Xia
 

Similar a Java14 (20)

JVM
JVMJVM
JVM
 
17515
1751517515
17515
 
Java mcq
Java mcqJava mcq
Java mcq
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction Unit 1 of java part 2 basic introduction
Unit 1 of java part 2 basic introduction
 
First fare 2010 java-introduction
First fare 2010 java-introductionFirst fare 2010 java-introduction
First fare 2010 java-introduction
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
 
Adv kvr -satya
Adv  kvr -satyaAdv  kvr -satya
Adv kvr -satya
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
OOPs - JAVA Quick Reference.pdf
OOPs - JAVA Quick Reference.pdfOOPs - JAVA Quick Reference.pdf
OOPs - JAVA Quick Reference.pdf
 
Java quick reference
Java quick referenceJava quick reference
Java quick reference
 
JAVA CONCEPTS
JAVA CONCEPTS JAVA CONCEPTS
JAVA CONCEPTS
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Java programing considering performance
Java programing considering performanceJava programing considering performance
Java programing considering performance
 
java basic .pdf
java basic .pdfjava basic .pdf
java basic .pdf
 
java training faridabad
java training faridabadjava training faridabad
java training faridabad
 

Último

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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
 
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
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Último (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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?
 
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...
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Java14

  • 1.
  • 2.
  • 3.
  • 4.
  • 5. Internal Architecture of JVM Execution engine Class loader subsystem method area heap Java stacks pc registers native method stacks Runtime data area class files Native Method Interface Native Method Libraries
  • 6.
  • 7.
  • 8. Runtime Data Area Shared among threads class data class data class data class data class data class data Method area object object object object object object object object object heap
  • 9.
  • 10. Thread’s Runtime Data Area thread 1 thread 2 thread 3 pc registers stack frame stack frame stack frame stack frame thread 1 stack frame stack frame stack frame thread 2 java stacks stack frame stack frame thread 3 thread 3 native method stacks
  • 11.
  • 12.
  • 13. Class Loader Subsystem B. Linking: 2. Preparation: A. allocating memory for class variables and initializing the memory to default values. B. allocating data structures that are used internally by the virtual machine: 1. method tables. 2. data structure that allows any method to be invoked on instances of a class without requiring a search of superclasses at invocation time.
  • 14. Class Loader Subsystem B. Linking: 3. Resolution: A. transforming symbolic references (e.g. class.field) into direct references. B. symbolic reference is replaced with a direct reference that can be more efficiently processed if the reference is used repeatedly. (Quick instructions) C. Implementation choice: static linkage vs. laziest resolution
  • 15. Class Loader Subsystem C. Initialization: invoke java code that initializes class variables to their proper staring values. A. execution of any class variable initializers B. Before a class can be initialized, its direct superclass must be initialized, as well as the direct superclass of its direct superclass, and so on, recursively. C. Initialization may cause loading, linking, and initialization errors D. Because Java is multithreaded, initialization of a class or interface requires careful synchronization.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. ptr to class data the heap instance data instance data instance data instance data The method area class data ptr to heap an object reference Keeping object data all in one place.
  • 26. prt to class data length=(2) ar[0] (ref) ar[1] (ref) the heap prt to class data length=(2) ar[0][0](int) ar[0][1] (int) prt to class data length=(2) ar[1][0] (int) ar[1][1] (int) class data for [[I class data for [I the method area ar (an array ref) int [ ] [ ] ar= new int [2][2]; One possible heap representation for arrays.
  • 27. prt to full class data prt to method data prt to method data prt to method data ● ● ● entry point into all data for the class method data method data method data prt to special structure instance data instance data the heap ptr into heap method table the method area Keeping the method table close at hand.
  • 28.
  • 29.
  • 30.
  • 31. type long float double reference int type index 0 1 3 4 6 7 parameter int i long l float f double d Object o byte b reference int double int int type index 0 1 2 4 5 parameter hidden this char c short s boolean b double d runClassMethod() runInstanceMethod() Class Example3a { // local variable in stack frame public static int runClassMethod(int i, long l, float f, double d, Object o, byte b) { return 0;} public int runInstanceMethod(int i, double d, short s, boolean b) { return 0;} }
  • 32. 100 98 0 1 2 local variables operand stack 100 98 100 0 1 2 100 98 100 98 0 1 2 100 98 198 0 1 2 100 98 198 0 1 2 before starting after iload_0 after iload_1 after iadd after istore_2 iload_0 // push local variable 0 (an int) iload_1 // push local variable 1 (an int) iadd // pop two ints, add them and push result istore_2 // pop int, store into local variable 2
  • 33. Class Example3c { public static void addAndPrint() { double result = addTwoTypes(1, 88.88); System.out.println(result); } public static double addTwoTypes (int i, double d) { return i + d; } } Java Stack Example
  • 34. 1 88.88 0 1 0 1 1 88.88 0 1 89.88 0 1 before invoke addTwoTypes() After invoke addTwoTypes() addTwoTypes() returns frames for addAndPrint( ) frame for addTwoTypes( ) local variables frame data operand stack
  • 35. 0 1 0 1 0 1 before invoke addTwoTypes() After invoke addTwoTypes() addTwoTypes() returns frames for addAndPrint( ) frame for addTwoTypes( ) 1 88.88 1 88.88 89.88
  • 36. stack frame stack frame stack frame stack frame Java stacks a native method stack this Java method invokes a native method. the current frame This C function invokes another C function This C function invokes a Java method

Notas del editor

  1. 1