Access flags are 16-bit masks, each bit a modifier. The class, every field and every method has one. Their layout is the same as in the class files that came after, and readers apply the flags of JDK 1.0 to them. Which of these bits the pre-release compilers actually wrote has not been confirmed. The explorer shows each flags field as hexadecimal followed by the names of the bits that are set, and names any other bit by the meaning it has in later class files.
Class flags
| Flag | Value | Source | Meaning |
|---|---|---|---|
ACC_PUBLIC | 0x0001 | public | Usable from outside its package |
ACC_FINAL | 0x0010 | final | No subclasses allowed |
| (0x0020) | 0x0020 | No meaning in this format; see below | |
ACC_INTERFACE | 0x0200 | interface | An interface, not a class |
ACC_ABSTRACT | 0x0400 | abstract | Must not be instantiated |
The JVM Specification notes that in JDK releases before 1.0.2, the compiler wrote
class flags in which the bit later called ACC_SUPER (0x0020) had no meaning, and the
JVM ignored it. JDK 1.0.2 gave the bit its meaning, a different way of running
invokespecial on superclass methods. So in this format the bit says
nothing, and the explorer shows it as super only because that is its
later name.
Field flags
| Flag | Value | Source | Meaning |
|---|---|---|---|
ACC_PUBLIC | 0x0001 | public | Usable from anywhere |
ACC_PRIVATE | 0x0002 | private | Usable only within its class |
ACC_PROTECTED | 0x0004 | protected | Usable from its package and subclasses |
ACC_STATIC | 0x0008 | static | One per class, not per object |
ACC_FINAL | 0x0010 | final | Never assigned after initialisation |
ACC_VOLATILE | 0x0040 | volatile | Cannot be cached |
ACC_TRANSIENT | 0x0080 | transient | Not part of the object’s persistent state |
Method flags
| Flag | Value | Source | Meaning |
|---|---|---|---|
ACC_PUBLIC | 0x0001 | public | Callable from anywhere |
ACC_PRIVATE | 0x0002 | private | Callable only within its class |
ACC_PROTECTED | 0x0004 | protected | Callable from its package and subclasses |
ACC_STATIC | 0x0008 | static | No this; called with invokestatic |
ACC_FINAL | 0x0010 | final | Must not be overridden |
ACC_SYNCHRONIZED | 0x0020 | synchronized | The JVM takes the object’s monitor around the call |
ACC_NATIVE | 0x0100 | native | Written in another language; no Code attribute |
ACC_ABSTRACT | 0x0400 | abstract | No implementation; no Code attribute |
The same bit means different things in different places: 0x0020 is
synchronized on a method but has no meaning on a class.
Example
The example file’s class flags are
00 01, just ACC_PUBLIC, and its one method’s flags are also
00 01: a public constructor.