How does the JVM work considering computer organization?

508 views Asked by At

I thought I've always understood why Java was portable, until I took Computer Organization.

This is my interpretation of a C program from start to finish:

C program --> compiler --> assembly --> machine code --> ISA --> micro architecture (how the computer interprets ISA) --> logic gate --> circuit --> device

Where the compiler must have knowledge of the ISA. Also, the assembly and machine code will vary based on ISA.

Java is as such: (inside JVM): Java program --> compiler --> bytecode

bytecode is the ISA for a JVM.

So, I am guessing the JVM also has it's own micro architecture to interpret it's ISA (bytecode).

Is this accurate?

So the overall cycle would be: (inside JVM) Java program --> bytecode(ISA) --> JVM micro architecture --> host hardware

Also, if the micro architecture is implemented in the processor, does the JVM need to use one of the hosts' processors?

2

There are 2 answers

2
M A On BEST ANSWER

It's more like (following your layering for C):

Java program --> Java compiler --> bytecode --> JVM compiler --> assembly 
--> machine code --> ISA --> micro architecture (how the computer interprets ISA)
--> logic gate --> circuit --> device

Note that there are essentially two compilers. That's how Java achieves portability.

0
M J On

First, java compiler compiles the source code into byte code. At the run time,Java Virtual Machine (JVM) interprets this byte code and generates machine code which will be directly executed by the machine in which java program runs.

Visit good tutorial of JVM,JRE and JDK https://javatutorialdetails.blogspot.com/2017/10/java-tutorial-in-details-step-by-step.html