Cross-compiler vs JVM

后端 未结 3 1333
终归单人心
终归单人心 2021-01-20 16:32

I am wondering about the purpose of JVM. If JVM was created to allow platform independent executable code, then can\'t a cross-compiler which is capable of producing platfor

3条回答
  •  误落风尘
    2021-01-20 16:44

    platform independent executable code

    That's what Java bytecode is. The problem with "platform independent executable code" is that it can't be native to every platform (otherwise being platform independent would be a trivial, uninteresting property). In other words, there is no format which runs without natively on all platforms. The JVM is, depending on your definition of the term, either the ISA which defines Java bytecode, or the component that allows Java bytecode to be run on platforms whose native format for executable code isn't Java bytecode.

    Of course, there is an infinite design space for alternative platform independent executable code and the above is true for any other occupant of said space. So yes, in a sense you can replace the JVM with another thing which fulfills the same function for another platform independent executable code format.

提交回复
热议问题