本文介绍了哪些操作可能(不会)引发StackOverflowError?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

StackOverError 被扔?

或者,什么时候会抛出?

Or rather, when will it not be thrown?

对于示例,如果我们使用基本运算符++=--=== <>/%,等等:

For example, if we use the primitive operators +, +=, -, -=, == <, >, /, %, etc:

try {
     // operations +, +=, -, -=, == <, >, /, %, etc
} catch (java.lang.StackOverflowError e) {
     // will never occur?
}

是否可以保证不会抛出StackOverflowError?

Is there any guarantee that StackOverflowError will not be thrown?

推荐答案

A StackOverflowError is-a VirtualMachineError.事实证明,VirtualMachineError s没有 no 无扔保证. Java虚拟机规范说明了以下内容(强调).

A StackOverflowError is-a VirtualMachineError. It transpires that there are no no-throw guarantees about VirtualMachineErrors. The Java Virtual Machine Specification says the following (emphasis added).

这篇关于哪些操作可能(不会)引发StackOverflowError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!