当前位置:网站首页>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.
边栏推荐
- 微服务实战|手把手教你开发负载均衡组件
- Double non undergraduate students enter the factory, while I am still quietly climbing trees at the bottom (Part 1)
- 一篇详解带你再次重现《统计学习方法》——第二章、感知机模型
- QT drag event
- Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)
- [staff] time mark and note duration (staff time mark | full note rest | half note rest | quarter note rest | eighth note rest | sixteenth note rest | thirty second note rest)
- Taking the upgrade of ByteDance internal data catalog architecture as an example, talk about the performance optimization of business system
- 盘点典型错误之TypeError: X() got multiple values for argument ‘Y‘
- Actual combat of microservices | discovery and invocation of original ecosystem implementation services
- I've taken it. MySQL table 500W rows, but someone doesn't partition it?
猜你喜欢

Microservice practice | load balancing component and source code analysis

队列管理器running状态下无法查看通道

hystrix 实现请求合并

京东面试官问:LEFT JOIN关联表中用ON还是WHERE跟条件有什么区别

Complete solution of servlet: inheritance relationship, life cycle, container, request forwarding and redirection, etc

Redis installation and deployment (windows/linux)

【Go实战基础】gin 如何验证请求参数

WSL installation, beautification, network agent and remote development

CSDN Q & A_ Evaluation

远程连接IBM MQ报错AMQ4036解决方法
随机推荐
Amq6126 problem solving ideas
2022/2/14 summary
《统计学习方法》——第五章、决策树模型与学习(上)
长篇总结(代码有注释)数构(C语言)——第四章、串(上)
Function ‘ngram‘ is not defined
[go practical basis] gin efficient artifact, how to bind parameters to structures
Cloudreve自建云盘实践,我说了没人能限制得了我的容量和速度
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
From concept to method, the statistical learning method -- Chapter 3, k-nearest neighbor method
Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别
【Go实战基础】gin 如何自定义和使用一个中间件
Redis安装部署(Windows/Linux)
Complete solution of servlet: inheritance relationship, life cycle, container, request forwarding and redirection, etc
Typeerror: X () got multiple values for argument 'y‘
[staff] the lines and spaces of the staff (the nth line and the nth space in the staff | the plus N line and the plus N space on the staff | the plus N line and the plus N space below the staff | the
微服务实战|手把手教你开发负载均衡组件
Number structure (C language) -- Chapter 4, compressed storage of matrices (Part 2)
Data type case of machine learning -- using data to distinguish men and women based on Naive Bayesian method
Matplotlib swordsman Tour - an artist tutorial to accommodate all rivers
Knife4j 2. Solution to the problem of file control without selection when uploading x version files