Friday, June 18, 2010

Java's Magic: The Bytecode

The key that allows Java to solve both the security and the portability is Bytecode. The output of a Java compiler is not an executable code. Rather, it is bytecode. Bytecode is a highly optimized set of instructions designed to be executed by the Java Runtime System, which is called Java Virtual Machine(JVM). JVM can be said as an interpreter for the bytecode

Translating a Java program to a bytecode makes it much more easier to run the program in a wide variety of environment. The reason is straight forward : only the JVM needs to be implemented for each platform. Once the run-time package exists for a given system, any Java program can run on it. Although the details of the JVM defers from platform to platform, all interprets the same bytecode.

The interpretation helps java code to be secured. The execution of the Java code is under the control of the JVM. JVM can contain the program and prevent it from gathering the side effects from outside of the system.

The only drawback is that the compiling and interpreting makes the program execution a little bit slow, when compared to the direct compilation to the executable code.

No comments:

Post a Comment