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

TypeFieldWhat it holds
u2attribute_name_indexa Utf8: "ModuleMainClass"
u4attribute_lengthbytes after this field
u2main_class_indexa 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).