元空间和运行时常量池

标签:cat   时代   compile   cep   nta   col   row   field   clu   

元空间是方法区的实现

方法区是什么呢?

  从java虚拟机规范9里摘抄的

It stores per-class structures such as the run-time
constant pool, field and method data, and the code for methods and constructors,
including the special methods used in class and interface initialization and in
instance initialization 

包括了如下的几个部分

  1 运行时常量池

  2 字段和方法数据

  3 方法和构造方法的字节码

而关于运行时常量池

A run-time constant pool is a per-class or per-interface run-time representation
of the constant_pool table in a class file (§4.4). It contains several kinds of
constants, ranging from numeric literals known at compile-time to method and field
references that must be resolved at run-time. The run-time constant pool serves a
function similar to that of a symbol table for a conventional programming language,
although it contains a wider range of data than a typical symbol table.
Each run-time constant pool is allocated from the Java Virtual Machine‘s method
area (§2.5.4). The run-time constant pool for a class or interface is constructed
when the class or interface is created (§5.3) by the Java Virtual Machine.
The following exceptional condition is associated with the construction of the runtime constant pool for a class or interface:
? When creating a class or interface, if the construction of the run-time constant
pool requires more memory than can be made available in the method area of the
Java Virtual Machine, the Java Virtual Machine throws an OutOfMemoryError.
See §5 (Loading, Linking, and Initializing) for information about the construction of the
run-time constant pool.

翻译过来就是,运行时常量池是class文件里常量池的运行时代表(run-time representation) 实在不知道怎么翻译好,各位理解就行了。

numeric literals数字字面量。

method and field references that must be resolved at run-time 方法和字段的引用只有在运行时才能解析,很好理解不到jvm里没法知道代码所在地址

 

元空间和运行时常量池

标签:cat   时代   compile   cep   nta   col   row   field   clu   

原文地址:https://www.cnblogs.com/juniorMa/p/13901878.html

版权声明:完美者 发表于 2020-10-31 1:53:14。
转载请注明:元空间和运行时常量池 | 完美导航

暂无评论

暂无评论...