ModuleMainClass attribute
The module's main class, which java --module name runs when no class is given..
- Appears on
- class
- Since
- class file 53.0 (Java 9)
- javac writes it
- not by javac; jar --main-class adds it
- Needed by the JVM
- no: it is for the class libraries (reflection), compilers or tools
Layout
| Type | Field | What it holds |
|---|---|---|
u2 | attribute_name_index | a Utf8: "ModuleMainClass" |
u4 | attribute_length | bytes after this field |
u2 | main_class_index | a Class |
What it is for
The module's main class, which java --module name runs when no class is given.
How common it is
None of the 7,391 classes in JDK 25.0.5's java.base has one.
Specification: JVMS §4.7, The ModuleMainClass Attribute (Java SE 25).