“在Java虚拟机运行期间"的定义是什么? [英] What's the definition of "during the operation of the Java Virtual Machine"?

查看:104
本文介绍了“在Java虚拟机运行期间"的定义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自 JVMS第6.3章:

[...]在[InternalErrorOutOfMemoryErrorStackOverflowErrorUnknownError]下定义的任何VirtualMachineError子类可以在操作期间随时抛出 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

JVMS如何定义短语在Java虚拟机运行期间的任何时间"?

How does the JVMS define the phrase "at any time during the operation of the Java Virtual Machine"?

当前的JVM如何解释该短语?

How do current JVMs interpret that phrase?

具体来说,这是否意味着这四个错误 java.lang.InternalError java.lang.OutOfMemoryError java.lang.StackOverflowError java.lang.UnknownError 可能会被抛出 语句之间? :

Specifically, does it mean that the four errors, java.lang.InternalError, java.lang.OutOfMemoryError, java.lang.StackOverflowError, and java.lang.UnknownError, may be thrown between statements? :

// ....
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();
// ....

推荐答案

Java虚拟机由许多部分组成.例如,垃圾收集器作为持久性背景Thread运行.它可能会抛出那些Exception之一,并且肯定肯定会在任何时候出现 (尤其是如果由于gc而停止了您自己的代码)!

The Java Virtual Machine consists of many parts. For example, the garbage collector runs as a persistent background Thread. It might throw one of those Exception and it might certainly appear to occur at any time (especially if your own code is stopped due to gc)!

来自 Java垃圾收集基础

什么是自动垃圾收集?

自动垃圾收集是查看堆内存,识别正在使用的对象和不使用的对象以及删除未使用的对象的过程.使用中的对象或引用的对象意味着程序的某些部分仍维护着指向该对象的指针.程序的任何部分都不再引用未使用的对象或未引用的对象.因此,可以回收未引用对象使用的内存.

Automatic garbage collection is the process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects. An in use object, or a referenced object, means that some part of your program still maintains a pointer to that object. An unused object, or unreferenced object, is no longer referenced by any part of your program. So the memory used by an unreferenced object can be reclaimed.

tl;博士

是的.它们可能会在语句之间抛出.

Yes. They could be thrown between statements.

这篇关于“在Java虚拟机运行期间"的定义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆