Is the Java virtual machine language agnostic?

To be sure, the Java virtual machine was originally designed for the Java programming language, but now other developers have been able to write programming languages compiled into Java bytecode, such as Scala, Jython and j ruby

There are still "object - oriented" references in Java bytecode, such as interfaces, methods, and fields For example, invokespecial is a call to an "object" method

It is not a pure stack virtual machine with a pure language agnostic instruction set For example, a pure forth implementation will only have stack operations

The question is, is the JVM language agnostic?

Solution

In a sense, JVM and Java bytecode are complete. Any other Turing complete language can be converted and compiled into Java bytecode and run on the JVM This may be very inefficient, but it is not impossible There is no such thing as the strictest definition of agnosticism At the hardware level, all processors have a defined set of binary instructions, so at any time, any language must be converted to an assembly compatible with the hardware that should be executed

Editor: JVM is not developed in a vacuum. It is developed together with Java programming language. Therefore, Java language seriously affects the design of Java bytecode and JVM So in this sense, you can say that the JVM is designed in Java However, in the architecture, the JVM consciously removes the coupling from the Java language (through the intermediate bytecode format), so it is possible to consider possible elements of alternative languages in the design

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>