Execution Engine java

Execution Engine

Well, after we are done loading the class into the main memory, and the runtime data area is also ready with the details, the next step is to execute the program, which is going to be achieved with the help of the execution engine. Some components from the execution engine include –

  • interpreter
  • JIT compiler(just in time compiler)
  • garbage collector.

Let’s have a brief look at them one by one.

Interpreter – well, the interpreter is something that reads and executes the byte code line by line. The execution of the interpreter is comparatively slower. Also, if we are calling some method, then every time, that method’s instructions need to be interpreted. But we have something to our escape here. It is called a JIT compiler. Let’s have a look at it as well.

JIT compiler – Well, as it is mentioned earlier, the byte code is read and executed line by line. But if it is found to be a repeated code, then here, the JIT compiler is used so that the line-by-line reinterpretation is avoided. It compiles the entire byte code to its native machine code. This native machine code is used for the repeated method calls so that the performance is improved.

Garbage collector – Well, the garbage collector is used to collectinging and removing the un-referenced objects, which means that the objects which are having no reference but are still there in the memory, are removed so as to have free memory at runtime.

JNI (java native interface) →

In java, the execution of native code (nonjava code) is supported via the Java Native Interface. This can be helpful when we are required to write some code that might not be entirely supported by java, but is in another language, like C/C++.

Native method libraries →

These libraries are written in some other programming languages, like C, C++, etc. We can say that this is a collection of the native libraries and interacting with the Java native interface, the required native libraries are made available.

Now, since we know a little about JDK, JRE, JVM, compiler, source code, byte code, and some other things, let’s quickly dive into understanding some features of Java, as stated earlier. First, I will list some features for you, and then explain in brief, all the stated features one by one –