gpt4 book ai didi

java - JVM如何检查程序中发生了哪种类型的异常?

转载 作者:行者123 更新时间:2023-12-02 10:46:28 25 4
gpt4 key购买 nike

JVM如何获取发生什么类型的异常的信息,然后显示出是什么类型的异常,以及JVM使用哪个线程来通知我们。

最佳答案

程序员可以使用throw抛出异常陈述。 字节码使用操作码 athrow :

The objectref must be of type reference and must refer to an object that is an instance of class Throwable or of a subclass of Throwable. It is popped from the operand stack. The objectref is then thrown by searching the current method (§2.6) for the first exception handler that matches the class of objectref, as given by the algorithm in §2.10.

If an exception handler that matches objectref is found, it contains the location of the code intended to handle this exception. The pc register is reset to that location, the operand stack of the current frame is cleared, objectref is pushed back onto the operand stack, and execution continues.

参见2.10. Exception来自 JLS,以便更好地理解异常。

关于java - JVM如何检查程序中发生了哪种类型的异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20517489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com