JVM学习笔记-属性格式(Attributes Types)

本文深入探讨了Java虚拟机规范中定义的8种属性,包括Code、ConstantValue、Exceptions、Deprecated、InnerClasses和Synthetic,解释了它们在Javaclass文件中的作用及应用。

 

Attributes

The Java Virtual Machine specification defines eight types of attributes, shown in Table 6-25. All Java Virtual Machine implementations must recognize three of these attributes: Code, ConstantValue, and Exceptions. Implementations can choose whether to recognize or ignore the other predefined attributes. (The InnerClasses and Synthetic attributes were added in Java 1.1). All of these predefined attributes are described in detail later in this chapter.

如表6-24所示,Java虚拟机规范定义了8种属性(实际上是9种)。为了正确地解释Javaclass文件,所有Java虚拟机实现都必须能够识别下列三种属性:Code,ConstantValue和Exception。为了正确地实现Java和Java 2 平台类库,虚拟机实现必须能够识别InnerClasses和Synthetic属性,但可以自主选择究竟是识别还是忽略其他一些与定义的属性(在Java1.1中,加入了Deprecated、InnerClasses和Synthetic属性(attribute))。所有这些预定义的属性将在本章详细阐述。

 

Table 6-25. Types of attribute_info tables defined by the specification

NameUsed ByDescription
Codemethod_infoThe bytecodes and other data for one method
ConstantValuefield_info

The value of a final variable

 

Deprecatedfield_info、method_infoThe fields and methods are discouraged from using
Exceptionsmethod_infoThe checked exceptions that a method may throw
InnerClassesClassFileA description of the inner classes defined inside a class
LineNumberTableCode_attributeA mapping of line numbers to bytecodes for one method
LocalVariableTableCode_attributeA description of the local variables for one method
SourceFileClassFileThe name of the source file
Synthetic field_info, method_info An indicator that a field or method was generated by the compiler

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值