Reputation: 91
a JVM implementation is an interpreter that converts a bytecode to machine code. But in the meantime a JVM implementation throws runtime error. Does it mean that an interpreter checks runtime error in Java? Or does it mean that Java's runtime occurs during the stage from bypecode to machine code?
Upvotes: 0
Views: 732
Reputation: 91
After research, I've found that a classical compiler converts source code to machine code, ready for computer to execute it, while a classical interpreter directly execute source code.
In C, the compiler converts its source code to almost machine code (an object file). When we "run" a C program, it means the machine execute the object file. So the runtime error is thrown by the machine.
While in Java, the compiler converts its source code to bytecode, an intermediate code between source code and machine code. After compilation, an non-classical interpreter (an bytecode interpreter) directly executes this bytecode. So the runtime error is thrown by this kind of interpreter, which is called "virtual machine" in Java, as it acts like the machine in C which execute the program.
Return to the question I asked, the interpreter (JVM) in Java throws runtime error because it acts like machine itself rather than acting as an intermediate stage before the actual execution.
Upvotes: 0
Reputation: 32535
It means that during run time of the application (when app was actually running) some exception was thrown eg attempt to divide by 0 which happen to be an user input.
Upvotes: 3