I am confused with jvm.
what does exactly jvm do takes bytycode and interpret to native code is native code assembly language?
is native code assembly language?
Assembly language is a way of writing code that will be assembled (by an assembler) into machine code, which is what is written to executable files and such. That is, assembly code is source code for humans, just at a very low level; machine code is the result of running an assembler on that source code. (This is analogous to when you write a higher-level language like C++ and compile it to machine code with a compiler.)
what does exactly jvm do takes bytycode and interpret to native code
A JVM could be written that just interpreted bytecode, but modern JVMs don't do that; they have a built-in Just-In-Time Compiler (JIT) which takes the bytecode and, effectively, assembles it on the-fly into machine code. In fact, Sun's JVM has a two-stage JIT: One stage that runs really quickly (so apps and classes get converted to machine code quickly when run, to avoid startup delays), and another stage it kicks in that does aggressive optimization, which it uses when it identifies "hot spots" (code that runs a lot) in the code (so that performance-critical code runs quickly).
So modern JVMs read bytecode from .class
files, run it through the JIT to compile it to machine code, and have the computer run that machine code. While doing that, a good one monitors hot spots and aggressively optimizes them, creating new, replacement machine code that's more efficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With