jvm“在Java虚拟机运行期间”的定义是什么?
[...] any of the
VirtualMachineError
subclasses defined below [InternalError
,OutOfMemoryError
,StackOverflowError
,UnknownError
] may be thrown at any time during the operation of the Java Virtual Machine
JVM如何定义短语“在Java虚拟机运行期间的任何时候”
当前的JVM如何解释这个短语
具体来说,这是否意味着四个错误,^{
// ....
A(); B(); C();
try {
// nothing
} catch (InternalError | OutOfMemoryError | StackOverflowError | UnknownError e) {
// may occur?
}
D(); E(); F();
try {
; // semi-colon
} catch (InternalError | OutOfMemoryError | StackOverflowError | UnknownError e) {
// may occur?
}
G(); H(); I();
try {
; ; ;; ;;;;; ; ; ;;; ;; ;; ;; ;; ; ;; ; ;; // ... semi-colons
} catch (InternalError | OutOfMemoryError | StackOverflowError | UnknownError e) {
// may occur?
}
J(); K(); L();
// ....
# 1 楼答案
Java虚拟机由许多部分组成。例如,垃圾收集器作为持久后台运行
Thread
。它可能会抛出其中一个Exception
,并且它肯定会在任何时间出现(特别是如果您自己的代码由于gc而停止)从Java Garbage Collection Basics
tl;dr
对。它们可以在语句之间抛出