Java Virtual Machine, An inside story!!
Java Virtual Machine, or JVM as its name suggest is a “virtual” computer that resides in the “real” computer as a software process. JVM gives Java the flexibility of platform independence. Let us see first how exactly Java program is created, compiled and executed. Java code is written in .java file. This code contains one or more Java language attributes like Classes, Methods, Variable, Objects etc. Javac is used to compile this code and to generate .class file. Class file is also known as “byte code“. The name byte code is given may be because of the structure of the instruction set of Java program. We will see more about the instruction set later in this tutorial. Java byte code is an input to Java Virtual Machine. JVM read this code and interpret it and executes the program.
Java Virtual Machine
Java Virtual Machine like its real counter part, executes the program and generate output. To execute any code, JVM utilizes different components. JVM is divided into several components like the stack, the garbage-collected heap, the registers and the method area. Let us see diagram representation of JVM.
Stack in Java virtual machine stores various method arguments as well as the local variables of any method. Stack also keep track of each an every method invocation. This is called Stack Frame. There are three registers thats help in stack manipulation. They are vars, frame, optop. This registers points to different parts of current Stack. There are three sections in Java stack frame:
The local variables section contains all the local variables being used by the current method invocation. It is pointed to by the vars register. Execution Environment
The execution environment section is used to maintain the operations of the stack itself. It is pointed to by the frame register. Operand Stack
The operand stack is used as a work space by bytecode instructions. It is here that the parameters...
Please join StudyMode to read the full document