栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

java虚拟机规范阅读

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

java虚拟机规范阅读

https://docs.oracle.com/javase/specs/jvms/se8/jvms8.pdf

2.5 Run-Time Data Areas

运行时数据

PC

STACK

HEAP

The Java Virtual Machine has a method area that is shared among all Java Virtual Machine threads

方法区是所有线程共享的,不过和heap的区别是,堆存储的是实例和数组

类似于,操作系统的正文段,也就是编译后的方法代码

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 (§2.9) used in class and instance initialization and interface initialization.

2.5.5 Run-Time Constant Pool

运行时常量池

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).

其实就是一个表,具体哪个表,参考:

IDEA使用jclasslib-bytecode-viewer插件查看字节码_newbaby2012的博客-CSDN博客

首先这些不是实例,所以不在heap,其次是所有线程共享的,所以不会再stack里

A class file consists of a single ClassFile structure:

类描述

 The field descriptor of an instance variable of the multidimensional array type double[] [][] is [[[D

方法描述

 常量池由两部分组成,一个标记,一个信息,常见的标记如下

 CONSTANT_Class_info 

name_INDEX是一个index,必须指向CONSTANT_Utf8_info结构

The constant_pool entry at that index must be a CONSTANT_Utf8_info structure 

而CONSTANT_Utf8_info如下,哦这么看。class其实指向一个字节数组,里面其实就是类信息对应的字节码,所以常量池就是CONSTANT_Utf8_info这一类CONSTANT开头的东西?

 field

 method 咋感觉和field一模一样

 里面的attributes_info就是

 总共有23种attributes

The number of method parameters is limited to 255 by the definition of a method descriptor (§4.3.3), where the limit includes one unit for this in the case of instance or interface method invocations.

The size of an operand stack in a frame (§2.6) is limited to 65535 values by the max_stack field of the Code attribute (§4.7.3).

Loading, Linking, and Initializing

Loading就是找到二进制文件(classloader的功能),并且据此创建class字节码文件

符号引用( symbolic reference):就是不是直接指向内存地址,类似于spring中的${ocr.port}

The Run-Time Constant Pool

运行时常量池,其实首先取决于常量池,会有很多符号引用,而这些符号引用都来自于constant_pool的各种info

All references in the run-time constant pool are initially symbolic. 

A symbolic reference to a field of a class or an interface is derived from a CONSTANT_Fieldref_info structure (§4.4.2) in the binary representation of a class or interface. Such a reference gives the name and descriptor of the field, as well as a symbolic reference to the class or interface in which the field is to be found.

一个引用会给出Field的名字和描述符,并且给出另一个引用,这个引用指向Field对应的class

Run-time constant values are derived from CONSTANT_Integer_info, CONSTANT_Float_info, CONSTANT_Long_info, or CONSTANT_Double_info structures (§4.4.4, §4.4.5) in the binary representation of a class or interface.

看到5.2

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1013631.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号