当前位置:网站首页>Methods of classfile
Methods of classfile
2022-07-02 09:20:00 【kq1983】
Methods
Each method, including each instance initialization method ( §2.9) and the class or interface initialization method ( §2.9), is described by a method_info structure.
No two methods in one class file may have the same name and descriptor ( §4.3.3).
The structure has the following format:
method_info {
u2 access_flags;
u2 name_index;
u2 descriptor_index;
u2 attributes_count;
attribute_info attributes[attributes_count];
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
The items of the method_info structure are as follows:
access_flags
The value of the access_flags item is a mask of flags used to denote access permission to and properties of this method. The interpretation of each flag, when set, is specified in Table 4.6-A.
Table 4.6-A. Method access and property flags
Flag Name | Value | Interpretation |
| 0x0001 | Declared |
| 0x0002 | Declared |
| 0x0004 | Declared |
| 0x0008 | Declared |
| 0x0010 | Declared |
| 0x0020 | Declared |
| 0x0040 | A bridge method, generated by the compiler. |
| 0x0080 | Declared with variable number of arguments. |
| 0x0100 | Declared |
| 0x0400 | Declared |
| 0x0800 | Declared |
| 0x1000 | Declared synthetic; not present in the source code. |
Methods of classes may have any of the flags in Table 4.6-A set. However, each method of a class may have at most one of its ACC_PUBLIC, ACC_PRIVATE, and ACC_PROTECTED flags set (JLS §8.4.3).
Methods of interfaces may have any of the flags in Table 4.6-A set except ACC_PROTECTED, ACC_FINAL, ACC_SYNCHRONIZED, and ACC_NATIVE (JLS §9.4). In a class file whose version number is less than 52.0, each method of an interface must have its ACC_PUBLIC and ACC_ABSTRACTflags set; in a class file whose version number is 52.0 or above, each method of an interface must have exactly one of its ACC_PUBLIC and ACC_PRIVATE flags set.
If a method of a class or interface has its ACC_ABSTRACT flag set, it must not have any of its ACC_PRIVATE, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, or ACC_STRICT flags set.
Each instance initialization method ( §2.9) may have at most one of its ACC_PUBLIC, ACC_PRIVATE, and ACC_PROTECTED flags set, and may also have its ACC_VARARGS, ACC_STRICT, and ACC_SYNTHETIC flags set, but must not have any of the other flags in Table 4.6-A set.
Class and interface initialization methods are called implicitly by the Java Virtual Machine. The value of their access_flags item is ignored except for the setting of the ACC_STRICT flag.
The ACC_BRIDGE flag is used to indicate a bridge method generated by a compiler for the Java programming language.
The ACC_VARARGS flag indicates that this method takes a variable number of arguments at the source code level. A method declared to take a variable number of arguments must be compiled with the ACC_VARARGS flag set to 1. All other methods must be compiled with the ACC_VARARGS flag set to 0.
The ACC_SYNTHETIC flag indicates that this method was generated by a compiler and does not appear in source code, unless it is one of the methods named in §4.7.8.
All bits of the access_flags item not assigned in Table 4.6-A are reserved for future use. They should be set to zero in generated class files and should be ignored by Java Virtual Machine implementations.
name_index
The value of the name_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info structure ( §4.4.7) representing either one of the special method names <init> or <clinit> ( §2.9), or a valid unqualified name denoting a method ( §4.2.2).
descriptor_index
The value of the descriptor_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info structure representing a valid method descriptor ( §4.3.3).
A future edition of this specification may require that the last parameter descriptor of the method descriptor is an array type if the ACC_VARARGS flag is set in the access_flags item.
attributes_count
The value of the attributes_count item indicates the number of additional attributes of this method.
attributes[]
Each value of the attributes table must be an attribute_info structure ( §4.7).
A method can have any number of optional attributes associated with it.
The attributes defined by this specification as appearing in the attributes table of a method_info structure are listed in Table 4.7-C.
The rules concerning attributes defined to appear in the attributes table of a method_info structure are given in §4.7.
The rules concerning non-predefined attributes in the attributes table of a method_info structure are given in §4.7.1.
边栏推荐
- 告别996,IDEA中必装插件有哪些?
- WSL installation, beautification, network agent and remote development
- [go practical basis] how to set the route in gin
- 微服务实战|负载均衡组件及源码分析
- In depth analysis of how the JVM executes Hello World
- 十年开发经验的程序员告诉你,你还缺少哪些核心竞争力?
- Redis sorted set data type API and application scenario analysis
- Function ‘ngram‘ is not defined
- 知识点很细(代码有注释)数构(C语言)——第三章、栈和队列
- "Interview high frequency question" is 1.5/5 difficult, and the classic "prefix and + dichotomy" application question
猜你喜欢

DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!

微服务实战|原生态实现服务的发现与调用

Win10 uses docker to pull the redis image and reports an error read only file system: unknown
![[go practical basis] how to install and use gin](/img/0d/3e899bf69abf4e8cb7e6a0afa075a9.png)
[go practical basis] how to install and use gin

微服务实战|Eureka注册中心及集群搭建

Break the cocoon | one article explains what is the real cloud primordial

I've taken it. MySQL table 500W rows, but someone doesn't partition it?
![[go practical basis] how to set the route in gin](/img/23/f38d68c4fd238d453b9a7670483002.png)
[go practical basis] how to set the route in gin

Chrome user script manager tempermonkey monkey

Cloud computing in my eyes - PAAS (platform as a service)
随机推荐
Long summary (code with comments) number structure (C language) -- Chapter 4, string (Part 1)
《统计学习方法》——第五章、决策树模型与学习(上)
Shengshihaotong and Guoao (Shenzhen) new energy Co., Ltd. build the charging pile industry chain
双非本科生进大厂,而我还在底层默默地爬树(上)
win10使用docker拉取redis镜像报错read-only file system: unknown
"Redis source code series" learning and thinking about source code reading
C4D quick start tutorial - C4d mapping
Matplotlib swordsman line - layout guide and multi map implementation (Updated)
概率还不会的快看过来《统计学习方法》——第四章、朴素贝叶斯法
[staff] common symbols of staff (Hualian clef | treble clef | bass clef | rest | bar line)
[go practical basis] how to bind and use URL parameters in gin
Gocv boundary fill
Essay: RGB image color separation (with code)
Sentinel reports failed to fetch metric connection timeout and connection rejection
How to realize asynchronous programming in a synchronous way?
【Go实战基础】如何安装和使用 gin
"Interview high frequency question" is 1.5/5 difficult, and the classic "prefix and + dichotomy" application question
Actual combat of microservices | discovery and invocation of original ecosystem implementation services
聊聊消息队列高性能的秘密——零拷贝技术
1、 QT's core class QObject