How the JVM throws an exception

I know that the JVM has an exception table that displays possible exceptions that can be thrown in these bytecode indexes. I also read that the atrow bytecode gives an excetion of the reference type that is present at the top of the stack. My question is more about how instructions like throwing irem exceptions.

Does the JVM check the top of the stack after each command execution to see if there is an exception? I would love any understanding of what is happening under the hood.

+4
source share
1 answer

irem is the logical int remainder operator. The Java Virtual Machine Specification writes :

Runtime exception

If the divisor value for the remainder operator intis 0, iremthrows ArithmeticException.

How JVM implementation is implemented that is not specified. It can instruct the processor to compare the divisor to zero before doing the division, or to do the division and react to the fact that the CPU in question indicates that division by 0. Since division by zero is probably rare, the last strategy is probably more effective.

For example, the Intel 64 and IA-32 Architecture Software Developer's Guide , combined volumes 3A, 3B, and 3C: System Programming Guide, writes:

6.1

, , . , , . Pentium 4, Intel Xeon, P6 Pentium .

, , ha ndler. , . , .

, JVM , -.

+2

All Articles