Java Compiler: Rearrange or Rewrite (Data, Software, Etc.) To Improve Efficiency of Retrieval or Processing
Java Compiler: Rearrange or Rewrite (Data, Software, Etc.) To Improve Efficiency of Retrieval or Processing
Java Compiler: Rearrange or Rewrite (Data, Software, Etc.) To Improve Efficiency of Retrieval or Processing
(Linux)
Java Compiler: A Java compiler is a compiler for the programming language Java. The most common form of output from a Java compiler is Java
class files containing platform-neutral Java bytecode, but there are also compilers that gives optimized native machine code for a particular
hardware/operating system combination.
Most Java-to-bytecode compilers, Jikes being a well known exception, do virtually no optimization, leaving this until run time to be done by
the JRE
optimization - rearrange or rewrite (data, software, etc.) to improve efficiency of retrieval or processing.
Java virtual machine: The JVM loads the class files and either interprets the bytecode or just-in-time compiles it to machine code and then
possibly optimizes it using dynamic compilation.
Dynamic compilation is a process used by some programming language implementations to gain performance during program execution. Since
the machine code emitted (produced) by a dynamic compiler is constructed and optimized at program runtime, the use of dynamic compilation
enables optimizations for efficiency not available to compiled programs except through code duplication or metaprogramming.
In computer science, an interpreter is a computer program that directly executes, i.e. performs, instructions written in
a programming or scripting language, without previously compiling them into a machine language program. An interpreter generally uses one of
the following strategies for program execution:
Parse is the process of analysing (examining) a string of symbols, either in natural language or in computer languages, conforming to the rules of
a formal grammar. The term is used to refer to the formal analysis by a computer of a sentence or other string of words into its constituents
(part of something), resulting in a parse tree showing their syntactic (set of rules) relation to each other, which may also contain semantic and
other information.
In computing, source code is any collection of computer instructions, possibly with comments, written using a human-readable programming
language, usually as ordinary text
An Intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An
IR is designed to be conducive for further processing, such as optimization and translation.
a) Interpreter: Reads your source code or some intermediate representation (bytecode) of it, and executes it directly.
b) JIT compiler: Reads your source code, or more typically some intermediate representation (bytecode) of it, compiles that
on the fly and executes native code.
compiles that on the fly - Compiles the given bytecode instruction sequence to machine code at runtime before
executing it natively. It's main purpose is to do heavy optimizations (make something perfect) in performance
Java Compiler - A Java compiler is a compiler for the programming language Java. The most common form of output from a Java compiler is Java
class files containing platform-neutral Java bytecode, but there are also compilers that gives optimized native machine code for a particular
hardware/operating system combination.
JIT Compiler – It is activated when a Java method is called. It converts the source code to native machine code just before running the program
JVM Architecture:
JVM is also an abstract machine (that does not have a physical existence, we cannot touch it.). It is a specification that provides the runtime
environment in which Java byte code can be executed. An instance of JVM is created, whenever you write Java command on the command
prompt to run the class.
Execution on JVM:
1. JVM executes “Java byte codes”, instead of executing source code directly.
2. The codes of other programming language can also be executed by JVM, if codes are converted to adequate Java byte codes.
3. Java Virtual Machine is different for different platforms and can also act as a platform itself.
4. JVM also supports the automatic error handling by intercepting the errors which can be controlled easily.
5. The above feature is useful in platform independency and multi-user ability of Java.
Note: The Java Compiler (Javac) reads the source code and converts it into byte code files known as class files.
JVM threads:
Basically JVM has two main threads, which are as following.
1. Demon thread
The Demon threads are being run by JVM for itself, and JVM only decides on a thread for being a demon thread. It is also used for
garbage collection.
2. Non-demon thread
Program’s main() is the initial and non-demon thread. The other implementations of threads are also known as non-demon threads. As
far as any non-demon thread is active, Java Virtual Machine is also active.
Architecture of JVM:
1. Class loader: It is a subsystem of Java Virtual Machine that is used to accept and load files.
2. Class or Method area: It stores per-class structure such as runtime constant pool, field and method data, the codes for methods, etc.
Interim memory is required during execution. It consists of heap, stack, registers to store data, etc.
a) Interpreter that reads byte code stream and then execute the instructions.
b) A virtual processor i.e. JVM (Java Virtual Machine)
c) JIT (Just-In-Time) compiler which improves the performance by reducing the processing time.