<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>VM Spec The class File Format</title>
</head>
<body BGCOLOR=#eeeeff text=#000000 LINK=#0000ff VLINK=#000077 ALINK=#ff0000>
<table width=100%><tr>
<td><a href="VMSpecTOC.doc.html">Contents</a> | <a href="Overview.doc.html">Prev</a> | <a href="ConstantPool.doc.html">Next</a> | <a href="VMSpecIX.fm.html">Index</a></td><td align=right><i><i>The Java<sup><font size=-2>TM</font></sup> Virtual Machine Specification</i></i></td>
</tr></table>
<hr><br>
<a name="80959"></a>
<p><strong>CHAPTER 4 </strong></p>
<a name="80961"></a>
<h1>The <code><font size=+4>class</font></code> File Format</h1>
<hr><p>
<a name="80963"></a>
This chapter describes the Java virtual machine <strong></strong><code>class</code> file format. Each <code>class</code>
file contains the definition of a single class or interface. Although a class or interface
need not have an external representation literally contained in a file (for instance,
because the class is generated by a class loader), we will colloquially refer to any
valid representation of a class or interface as being in the <code>class</code> file format.
<p><a name="14580"></a>
A <code>class</code> file consists of a stream of 8-bit bytes. All 16-bit, 32-bit, and 64-bit quantities are constructed by reading in two, four, and eight consecutive 8-bit bytes, respectively. Multibyte data items are always stored in big-endian order, where the high bytes come first. In the Java and Java 2 platforms, this format is supported by interfaces <code>java.io.DataInput</code> and <code>java.io.DataOutput</code> and classes such as <code>java.io.DataInputStream</code> and <code>java.io.DataOutputStream</code>.<p>
<a name="6289"></a>
This chapter defines its own set of data types representing <code>class</code> file data: The types <code>u1</code>, <code>u2</code>, and <code>u4</code> represent an unsigned one-, two-, or four-byte quantity, respectively. In the Java and Java 2 platforms, these types may be read by methods such as <code>readUnsignedByte</code>, <code>readUnsignedShort</code>, and <code>readInt</code> of the interface <code>java.io.DataInput</code>.<p>
<a name="41600"></a>
This chapter presents the <code>class</code> file format using pseudostructures written in a C-like structure notation. To avoid confusion with the fields of classes and class instances, etc., the contents of the structures describing the <code>class</code> file format are referred to as <em>items</em>. Successive items are stored in the <code>class</code> file sequentially, without padding or alignment. <p>
<a name="74328"></a>
<em>Tables</em>, consisting of zero or more variable-sized items, are used in several <code>class</code> file structures. Although we use C-like array syntax to refer to table items, the fact that tables are streams of varying-sized structures means that it is not possible to translate a table index directly to a byte offset into the table. <p>
<a name="74331"></a>
Where we refer to a data structure as an array, it consists of zero or more contiguous fixed-sized items and can be indexed like an array.<p>
<a name="74353"></a>
<hr><h2>4.1 The <code>ClassFile</code> Structure</h2>
<a name="44115"></a>
A <code>class</code> file consists of a single <code>ClassFile</code> structure:
<p><pre><br><a name="19050"></a> <code>ClassFile {
</code> <code> u4 magic;
</code> <code> u2 minor_version;
</code> <code> u2 major_version;
</code> <code> u2 constant_pool_count;
</code> <code> cp_info constant_pool[constant_pool_count-1];
</code> <code> u2 access_flags;
</code> <code> u2 this_class;
</code> <code> u2 super_class;
</code> <code> u2 interfaces_count;
</code> <code> u2 interfaces[interfaces_count];
</code> <code> u2 fields_count;
</code> <code> field_info fields[fields_count];
</code> <code> u2 methods_count;
</code> <code> method_info methods[methods_count];
</code> <code> u2 attributes_count;
</code> <code> attribute_info attributes[attributes_count];
</code><a name="19084"></a> <code>}
</code><br></pre><a name="7456"></a>
The items in the <code>ClassFile</code> structure are as follows:
<p><a name="19719"></a>
<dl><dt><code>magic</code><a name="21106"></a>
<dd> The <code>magic</code> item supplies the magic number identifying the <code>class</code> file format; it has the value <code>0xCAFEBABE</code>.<p>
<a name="13448"></a>
<dt><code>minor_version</code>, <code>major_version</code><a name="70425"></a>
<dd> The values of the <code>minor_version</code> and <code>major_version</code> items are the minor and major version numbers of this <code>class</code> file.Together, a major and a minor version number determine the version of the <code>class</code> file format. If a <code>class</code> file has major version number M and minor version number m, we denote the version of its <code>class</code> file format as M.m. Thus, <code>class</code> file format versions may be ordered lexicographically, for example, 1.5 < 2.0 < 2.1.<p>
A Java virtual machine implementation can support a <code>class</code> file format of version v if and only if v lies in some contiguous range Mi.0 <img src="chars/lt_equal.gif"> v <img src="chars/lt_equal.gif"> Mj.m. Only Sun can specify what range of versions a Java virtual machine implementation conforming to a certain release level of the Java platform may support.<a href="#75883"><sup>1</sup></a><p>
<a name="13480"></a>
<dt><code>constant_pool_count</code><a name="31689"></a>
<dd> The value of the <code>constant_pool_count</code> item is equal to the number of entries in the <code>constant_pool</code> table plus one. A <code>constant_pool</code> index is considered valid if it is greater than zero and less than <code>constant_pool_count</code>, with the exception for constants of type <code>long</code> and <code>double</code> noted in <a href="ClassFile.doc.html#1348">§4.4.5</a>.<p>
<a name="29202"></a>
<dt><code>constant_pool[]</code><a name="19096"></a>
<dd> The <code>constant_pool</code> is a table of structures <a href="ClassFile.doc.html#20080">(§4.4)</a> representing various string constants, class and interface names, field names, and other constants that are referred to within the <code>ClassFile</code> structure and its substructures. The format of each <code>constant_pool</code> table entry is indicated by its first "tag" byte.<p>
The <code>constant_pool</code> table is indexed from <code>1</code> to <code>constant_pool_count</code>-<code>1</code>. <p>
<a name="13484"></a>
<dt><code>access_flags</code><a name="23242"></a>
<dd> The value of the <code>access_flags</code> item is a mask of flags used to denote access permissions to and properties of this class or interface. The interpretation of each flag, when set, is as shown in <a href="ClassFile.doc.html#75734">Table 4.1</a>.
</dl>
<a name="75734"></a><p><Table Border="1">
<tr><td><a name="75687"></a>
<strong>Flag Name</strong>
<td><a name="75689"></a>
<strong>Value</strong>
<td><a name="75691"></a>
<strong>Interpretation</strong>
<tr><td><a name="75695"></a>
<code>ACC_PUBLIC</code>
<td><a name="75697"></a>
<code>0x0001</code>
<td><a name="75699"></a>
Declared <code>public</code>; may be accessed from outside its package.
<tr><td><a name="75703"></a>
<code>ACC_FINAL</code>
<td><a name="75705"></a>
<code>0x0010</code>
<td><a name="75707"></a>
Declared <code>final</code>; no subclasses allowed.
<tr><td><a name="75711"></a>
<code>ACC_SUPER</code>
<td><a name="75713"></a>
<code>0x0020</code>
<td><a name="75715"></a>
Treat superclass methods specially wh
没有合适的资源?快使用搜索试试~ 我知道了~
vmspec.2nded.html
共201个文件
gif:147个
html:54个
需积分: 10 2 下载量 170 浏览量
2008-12-14
11:50:37
上传
评论
收藏 395KB ZIP 举报
温馨提示
vmspec.2nded.html.zip vmspec.2nded.html.zip
资源详情
资源评论
资源推荐
收起资源包目录
vmspec.2nded.html (201个子文件)
VMSpecIX.fm.anc.gif 33KB
Instructions.doc.anc.gif 12KB
Threads.doc.anc1.gif 4KB
Threads.doc.anc2.gif 4KB
Threads.doc.anc.gif 3KB
ampersnd.gif 209B
Instructions2.doc.anc9.gif 183B
Instructions2.doc.anc13.gif 183B
ClassFile.doc.anc1.gif 178B
Instructions2.doc.anc10.gif 164B
Instructions2.doc.anc6.gif 164B
ClassFile.doc.anc.gif 163B
capphi.gif 161B
capmu.gif 159B
capnu.gif 156B
aleph.gif 155B
arrwboth.gif 154B
captheta.gif 153B
rfraktur.gif 153B
weierstr.gif 153B
capomega.gif 152B
beta.gif 151B
theta1.gif 148B
alpha.gif 147B
psi.gif 146B
ifraktur.gif 146B
arrwdbbo.gif 145B
chi.gif 145B
capomicr.gif 145B
tm.gif 145B
theta.gif 144B
omega1.gif 144B
xi.gif 144B
capchi.gif 144B
capkappa.gif 143B
phi1.gif 143B
phi.gif 142B
zeta.gif 142B
capdelta.gif 141B
capbeta.gif 141B
notelemn.gif 141B
delta.gif 141B
omega.gif 140B
capupsil.gif 140B
infinity.gif 139B
capeta.gif 139B
caplambd.gif 139B
Instructions2.doc.anc11.gif 138B
capxi.gif 138B
capzeta.gif 138B
cappsi.gif 138B
arrwdbdn.gif 138B
capalpha.gif 138B
Instructions2.doc.anc7.gif 138B
TitlePage.doc.anc.gif 138B
lambda.gif 137B
arrwdbup.gif 137B
partldif.gif 137B
gradient.gif 136B
Instructions2.doc.anc12.gif 136B
Instructions2.doc.anc8.gif 136B
sigma1.gif 135B
univrsal.gif 135B
arrwup.gif 135B
integbot.gif 134B
rho.gif 134B
pi.gif 134B
club.gif 134B
upsilon.gif 133B
caprho.gif 133B
heart.gif 133B
eta.gif 132B
gamma.gif 132B
proportn.gif 132B
omicron.gif 132B
cappi.gif 132B
sigma.gif 132B
upsilon1.gif 131B
integtop.gif 131B
arrwdown.gif 131B
capsigma.gif 131B
arrwrite.gif 131B
arrwleft.gif 131B
capepsil.gif 130B
union.gif 129B
notsbset.gif 129B
lozenge.gif 129B
parertbt.gif 127B
intrsect.gif 126B
gtequal.gif 126B
parelttp.gif 126B
arrwdblt.gif 126B
pareltbt.gif 126B
approx.gif 125B
bracrtmd.gif 125B
nu.gif 124B
lt_equal.gif 124B
parerttp.gif 124B
refspset.gif 124B
kappa.gif 124B
共 201 条
- 1
- 2
- 3
juicewall
- 粉丝: 21
- 资源: 228
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 自动驾驶定位系列教程十:闭环修正.pdf
- HM2333-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- Python实现插入排序算法(源代码)
- 123.cpp
- HM2319-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- modbus4j-3.0.4.jar
- 蒙特·卡罗实验、使用蒙特·卡罗方法计算圆周率近似值.docx
- HM2319A-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- JAVA SpringBoot 集成华为云OBS,多镜像配置settings
- 一个文件共享系统,包括前端文件展示系统和后台管理系统,基于SpringBoot + MyBatis实现
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0