koolViru said:
But I am interested in knowing the whole under-the-hood process
I think that you'll find a lot of the answers to these question (which,
unfortunately I was not able to read) if you realise the following:
When a Java program is started, the program that starts it is a normal C (or
C++) program that uses the defined JNI interfaces to create and initialise a
JVM[*], and then uses more JNI interfaces to find the main() class and method,
and call it.
(The JMP implementation is packaged as a DLL on Windows, or as something
similar on Unix, so "creating" a JVM is basically a matter of loading the DLL,
then calling the functions defined in that library.)
You can find the source (it's not long or complicated) to the java.exe program
as part of the standard JDK. I think it's in src.zip, in the launcher/
subdirectory.
You can read all about JNI as part of the standard Java documentation that
comes with the JDK. There is also a trail about JNI in the Java tutorial on
Sun's website. Also the complete text of a book about JNI is somewhere on the
Sun website too (I can't remember where offhand).
If you want to get deeper into this, and study things like memory allocation,
and other implementation details, then you will need to look into the
implementation of the whatever JVM you are using. There are a few good books
(and no bad books that I know of) about JVM implementation in general. For
details about any specific version of any specific vendor's JVM implementation
then you will have to look for that vendor's documentation. Both Sun and IBM
publish quite a lot of information about their respective implementations.
For information about the /kinds/ of advanced techniques that are used in
modern JVMs you can also look for research papers. There are many such on the
web. Don't only look at papers about Java VMs -- most of the techniques were
originally invented for use for other (better) languages such as Lisp or
Smalltalk.
There are also several free JVM implementations for which the source is
available (including "advanced" implementations like the IBM "jikes" JVM (not
to be confused with the "jikes" compiler)). In fact you can download the Sun
JVM source from their website too, but I advise that you check the licence
conditions /very/ carefully -- there are two licenses, and one of them
effectively prohibits you from ever working on a JVM implementation of any sort
unless you work for Sun.
-- chris