java virtual machine n.
Skip this Video
Download Presentation
Java Virtual Machine

Loading in 2 Seconds...

play fullscreen
1 / 21

Java Virtual Machine - PowerPoint PPT Presentation

  • Uploaded on

Java Virtual Machine. Student Name: Wei Liu Student ID: 104076. Java Virtual Machine. JVM is part of Java programming language. JVM is a software, staying on top of Operating System, such as UNIX, Windows NT.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Java Virtual Machine' - igor-morin

Download Now 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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
java virtual machine

Java Virtual Machine

Student Name: Wei Liu

Student ID: 104076

java virtual machine1
Java Virtual Machine
  • JVM is part of Java programming language.
  • JVM is a software, staying on top of Operating System, such as UNIX, Windows NT.
  • It help Java create high level of portability by hiding the difference between the Operating System implementations.
  • It creates an environment that Java language lives.
why jvm
Why JVM?
  • An ordinary language can not create a system independent program.
  • Java’s goal is “Write-Once-Run-Anywhere”. Java programs are not computer, operating system dependent.
  • Need to create an “abstract computer” of its own and runs on it, a kind of virtual machine which hiding the different OS implementations.
how jvm works
How JVM works?
  • Java programs are compiled into byte code.
  • JVM interprets and converts Java byte code into machine code in order to execute on a CPU.
  • Most web browser has an integrated JVM to run applets.
how jvm works1
How JVM works?
  • Other JVM tasks include:
  • Object creations of Java programs.
  • Garbage collection.
  • Security responsibility.
jvm fundamental parts
JVM Fundamental Parts.
  • A byte code instruction set
  • A set of registers
  • A stack
  • A garbage-collected heap
  • An area for storing methods

All five parts are necessary, may be implemented by a compiler, an interpreter or a hardware chip.

byte code instruction set
Byte Code Instruction Set
  • JVM keeps a compact set of Byte Code Instructions in order to interpret byte code into native binary code.
  • Java compilers do not translate programs directly into native binary code, which is system dependent. Instead, programs are translated into byte code, just in its mid-way to a runnable.
  • JVM interprets these half-cooked byte code into executable machine code on different computer systems and platforms.
  • The registers of the Java virtual machine are just like the registers inside a “real” computer. (32 bit wide)
  • PC: program counter
  • OPTOP: Pointer to operation stack.
  • FRAME: Pointer to execution environment of current method.
  • VARS: Pointer to the first local variable of current method.
  • JVM is stack based.
  • The stack is used to supply parameters to byte codes and methods, and to receive results back from them.
  • Each stack frame contains three (possibly empty) sets of data: the local variables for the method call, its execution environment, and its operand stack.
  • The heap is that part of memory from which newly created instances (objects) are allocated.
  • The heap is often assigned a large, fixed size when the Java run-time system is started, but on systems that support virtual memory, it can grow as needed, in a nearly unbounded fashion.
  • Objects in heap are automatically garbage-collected when they are not needed.
the method area
The Method Area.
  • The method area stores the Java byte codes that implement almost every method in the Java system.
  • The method area also stores the symbol tables needed for dynamic linking, and any other additional information debuggers or development environments might want to associate with each method’s implementation.
drawbacks of jvm
Drawbacks of JVM.
  • JVM is a layer on the top of your operating system that consumes additional memory.
  • JVM is additional layer between compiler and machine. (Comparing Java program and fast C program!)
  • Byte code is compiled for system independence so it does not take advantage of any particular operating system.
jit compiler
JIT Compiler.
  • JIT stands for “Just In Time”.
  • 10 years ago, a smart idea was discovered by Peter Deutsch while trying to make Smalltalk run faster. He called it “dynamic translation” during interpretation.
  • Every time JIT compiler interprets byte codes, it will keep the binary code in log and optimize it. Next time, when the same method is running, the optimized code will run. Experiments show Java programs using JIT could be as fast as a compiled C program.
jit example
JIT Example.
  • ( Loop with 1000 times )

for(int i=0;i<1000;i++){

do_action( );


Without JIT, JVM will interpret do_action() method 1000 times. (A waste of time!)

With JIT, JVM interprets do_action() method only once and keeps it in log, and the binary native code will execute for the rest 999 loops.

jit compiler1
JIT Compiler.

Java Compiler


Byte Code

Java Virtual


JIT Compiler


& Kept in Log

Native Machine



jvm security capability
JVM Security Capability.
  • JVM has many capabilities to keep the security of the computer system.
  • “Sandbox”: prohibit a Java applet:
  • Reading or writing to the local disk
  • Making a network connection to any host, except the host from which the applet came
  • Creating a new process
  • Loading a new dynamic library and directly calling a native method
security holes of jvm
Security Holes of JVM
  • Netscape 4.X consists of JVM that has flaws.
  • A hostile applet could turn the client browser into an http server that allows almost anyone in the world to read/modify/delete files residing on the client (turned server) machine.
  • Ways to deal with “malicious” applets.
current jvm
Current JVM.
  • Microsoft Java Virtual Machine.
  • Netscape Java Virtual Machine.
  • Sun Java Virtual Machine.
  • All these Java Virtual Machines implement Java core class packages and their own specific class packages.