How the Java language works
I don't know Java very well, so I want to ask how this language works I mean not only "language", but also virtual machines
This is my understanding
>The java compiler converts code into Java byte code With Form of java file > when the file is running, the JVM reads (timely) bytecode and converts it into machine code. > The computer reads the machine code and the program seems to run like a compiler (to the user)
Is this absolutely wrong?
Solution
There are many answers, but I missed a key point:
This is not quite true
>The JVM first interprets the code > it looks at the most time-consuming part, hotspots > it analyzes the trace, that is, the typical execution process > it generates machine code optimized for hotspots and traces
Less time - consuming parts of the code may be interpreted If the situation changes (for example, by loading new classes), some compiled code may appear to be no longer optimized or even incorrect, and it will be discarded and the JVM will resume interpretation for some time, and then recompile it again