1 / 17

SNU EE Shin Jin Woo

The Java Virtual Machine (Design & APIs). SNU EE Shin Jin Woo. 2005. 10. 19. Table of Contents. What is JVM? Terminologies The Java Class Files Data Types in JVM Runtime Data Area Java Instruction Set Verification of Class Files Java APIs. 1. What is a Java Virtual Machine?.

kiara
Télécharger la présentation

SNU EE Shin Jin Woo

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Java Virtual Machine(Design & APIs) SNU EE Shin Jin Woo 2005. 10. 19

  2. Table of Contents • What is JVM? • Terminologies • The Java Class Files • Data Types in JVM • Runtime Data Area • Java Instruction Set • Verification of Class Files • Java APIs

  3. 1. What is a Java Virtual Machine? Java Virtual Machine Module 1 • an abstract computing machine • own instruction set(Java ISA) • memory manipulation at runtime user class files class loader The Java API’s class file bytecodes execution engine JVM native method invocation Host OS

  4. 2. Terminologies JRE(Java Runtime Environment) • : contains the Java virtual machine, classes comprising the Java 2 Platform API, and supporting files JDK(Java Development Kit) • : JRE, Development Tools(compiler, debugger), additional library compile-time environment run-time environment a.java b.java c.java a.class b.class c.class Java compiler JVM a.class b.class c.class Object.class String.class

  5. 3. What is a Class File? Java Class Files - precisely defined binary file format for Java programs - put only one class or interface in a single class file - primary vehicle for delivering program to JVM Java Class File Java Language Program Compiler Java Class File C Language Program Compiler

  6. 3. What is a Class File? What is in Class Files Magic Number 0xCAFEBABE, 4byte Version Information Constant Pool size Constant Pool Access Flags This Class Super Class Interface Count Interfaces Field Count Field Information Method Count Methods Attributes Count Attributes

  7. 4. Data Type in JVM Primitive Data Types • - int • - char • - byte • - short • - float • - double • returnAddress : used by subroutine mechanism • jsr places return address on operand stack Reference Data Types - reference : points to an object stored in memory

  8. 5. Runtime Data Areas PC Registers : each JVM thread has its own program counter : the index in bytecode of the instruction Java Virtual Machine Stacks : each JVM thread has its own stacks : invoke method -> new frame is allocated on stack : store operand stack, local variables, state variables foo() boo() Thread 1 Local Variables Local Variables Operand Stacks Operand Stacks draw() Thread 2 Local Variables Operand Stacks

  9. 5. Runtime Data Areas The Operand Stack - used to pass arguments - receive return results - interpreter is responsible for transferring return result to the caller operand stack Local Variables - number of local variables in stack is determined at compile time - local variables are numbered ex) dconst_0 dstore 1

  10. 5. Runtime Data Areas Heap - one heap per one JVM - created on VM start-up - all class instance and arrays are allocated in heap - objects are never deallocated Method Area - one M.A for one JVM - created on VM start-up - analogous to ‘text’ segment - stores constant pool, field and method data, code for method

  11. 5. Runtime Data Areas Constant Pool - analogous to ‘symbol table’ - a collection of all symbolic data need by a class - each constant pool is private to its class : 5: add g0, FSIZE(class)+GC_HEAD, it0 6: call 0 7: sethi %hi(class->dtable), rt2 8: or r3, rt2, %lo(class->itable) :

  12. 6. Java Instruction Sets Java Instruction Sets • - opcode is just one byte (256 combination possible) • additional index bytes • additional date bytes opcode opcode index1 index2 opcode date

  13. 20 10 10 20 20 20 20 6. Java Instruction Sets Data Movement Instructions • 1. stack manipulation instructions • iconst_1, bipush, pop, dup, swap • ex) bipush 10 • bipush 20 • swap • pop • dup • pop2

  14. 6. Java Instruction Sets Type Conversion - convert one type of item on the stack to another ex) i2f, i2d, i2l, f2i, f2l… Functional Instructions • operands are always taken from the stack and results are placed on the stack • ex) iadd, iand Control Flow Instructions • conditional branches ex) ifeq, if_icmpeq • unconditional branches ex) jsr, ret returnAddress type used

  15. 7. Verification of Class Files Verification of Class Files Module 1 It is done at Linking Time pass 1 – ensure that the file has the basic format of a class file pass 2 – verification without looking at actual code pass 3 – verifier checks the code array -> operand stack tracking

  16. 8. Java APIs Java Platforms - J2SE, J2EE, J2ME Java APIs java.lang : core API package : have Obejct class java.awt : contains classes for constructing GUIs java.io : manage data stream, file I/O

  17. 8. Java APIs Serialization & Reflection platform 1 network platform 2 platform independent form storage - Serialization : make a implementation independent form of objects In Java implement Serializable interface to do this - Reflection : find all of objects members

More Related