javajvmorganizationprocessors

How does the JVM work considering computer organization?


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?


Solution

  • 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.