0
点赞
收藏
分享

微信扫一扫

access_flags

崭新的韭菜 2022-02-15 阅读 52
javasedide


 access_flags

The value of the ​​access_flags​​​ 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 specified in ​​Table 4.1-A​​.


Table 4.1-A. Class access and property modifiers

Flag Name

Value

Interpretation

​ACC_PUBLIC​

0x0001

Declared ​​public​​; may be accessed from outside its package.

​ACC_FINAL​

0x0010

Declared ​​final​​; no subclasses allowed.

​ACC_SUPER​

0x0020

Treat superclass methods specially when invoked by the invokespecial instruction.

​ACC_INTERFACE​

0x0200

Is an interface, not a class.

​ACC_ABSTRACT​

0x0400

Declared ​​abstract​​; must not be instantiated.

​ACC_SYNTHETIC​

0x1000

Declared synthetic; not present in the source code.

​ACC_ANNOTATION​

0x2000

Declared as an annotation type.

​ACC_ENUM​

0x4000

Declared as an ​​enum​​ type.


An interface is distinguished by the ​​ACC_INTERFACE​​​ flag being set. If the ​​ACC_INTERFACE​​​ flag is not set, this ​​class​​ file defines a class, not an interface.

If the ​​ACC_INTERFACE​​​ flag is set, the ​​ACC_ABSTRACT​​​ flag must also be set, and the ​​ACC_FINAL​​​, ​​ACC_SUPER​​​, and ​​ACC_ENUM​​ flags set must not be set.

If the ​​ACC_INTERFACE​​​ flag is not set, any of the other flags in ​​Table 4.1-A​​​ may be set except ​​ACC_ANNOTATION​​​. However, such a ​​class​​​ file must not have both its ​​ACC_FINAL​​​ and ​​ACC_ABSTRACT​​ flags set (JLS §8.1.1.2).

The ​​ACC_SUPER​​ flag indicates which of two alternative semantics is to be expressed by the invokespecial instruction (​​§invokespecial​​​) if it appears in this class or interface. Compilers to the instruction set of the Java Virtual Machine should set the ​​ACC_SUPER​​​ flag. In Java SE 8 and above, the Java Virtual Machine considers the ​​ACC_SUPER​​​ flag to be set in every ​​class​​​ file, regardless of the actual value of the flag in the ​​class​​​ file and the version of the ​​class​​ file.

The ​​ACC_SUPER​​​ flag exists for backward compatibility with code compiled by older compilers for the Java programming language. In JDK releases prior to 1.0.2, the compiler generated ​​access_flags​​​ in which the flag now representing ​​ACC_SUPER​​ had no assigned meaning, and Oracle's Java Virtual Machine implementation ignored the flag if it was set.

The ​​ACC_SYNTHETIC​​ flag indicates that this class or interface was generated by a compiler and does not appear in source code.

An annotation type must have its ​​ACC_ANNOTATION​​​ flag set. If the ​​ACC_ANNOTATION​​​ flag is set, the ​​ACC_INTERFACE​​ flag must also be set.

The ​​ACC_ENUM​​ flag indicates that this class or its superclass is declared as an enumerated type.

All bits of the ​​access_flags​​​ item not assigned in ​​Table 4.1-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.




举报

相关推荐

0 条评论