当前位置:网站首页>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.
边栏推荐
- Solutions to Chinese garbled code in CMD window
- Say goodbye to 996. What are the necessary plug-ins in idea?
- Gocv split color channel
- Leetcode sword finger offer brush questions - day 23
- [go practical basis] how can gin get the request parameters of get and post
- Mysql安装时mysqld.exe报`应用程序无法正常启动(0xc000007b)`
- 西瓜书--第六章.支持向量机(SVM)
- Oracle修改表空间名称以及数据文件
- Troubleshooting and handling of an online problem caused by redis zadd
- WSL installation, beautification, network agent and remote development
猜你喜欢

西瓜书--第六章.支持向量机(SVM)

Cloudrev self built cloud disk practice, I said that no one can limit my capacity and speed

Solutions to Chinese garbled code in CMD window

Microservice practice | declarative service invocation openfeign practice

Servlet全解:继承关系、生命周期、容器和请求转发与重定向等

Matplotlib剑客行——初相识Matplotlib

C4D quick start tutorial - C4d mapping

2022/2/13 summary

【Go实战基础】gin 如何获取 GET 和 POST 的请求参数

Cloudreve自建云盘实践,我说了没人能限制得了我的容量和速度
随机推荐
Pdf document of distributed service architecture: principle + Design + practice, (collect and see again)
查看was发布的应用程序的端口
聊聊消息队列高性能的秘密——零拷贝技术
微服务实战|手把手教你开发负载均衡组件
Gocv boundary fill
Knife4j 2.X版本文件上传无选择文件控件问题解决
西瓜书--第六章.支持向量机(SVM)
Redis sorted set data type API and application scenario analysis
Microservice practice | declarative service invocation openfeign practice
Webflux responsive programming
Gocv image cutting and display
Win10 uses docker to pull the redis image and reports an error read only file system: unknown
Number structure (C language) -- Chapter 4, compressed storage of matrices (Part 2)
机器学习实战:《美人鱼》属于爱情片还是动作片?KNN揭晓答案
win10使用docker拉取redis镜像报错read-only file system: unknown
Redis installation and deployment (windows/linux)
Matplotlib swordsman line - first acquaintance with Matplotlib
概率还不会的快看过来《统计学习方法》——第四章、朴素贝叶斯法
[go practical basis] how to set the route in gin
C language implementation of mine sweeping game