Module attribute

The module declaration: its name, and everything it requires, exports, opens, uses and provides.

Appears on
class
Since
class file 53.0 (Java 9)
javac writes it
for module-info.class
Needed by the JVM
no: it is for the class libraries (reflection), compilers or tools

Layout

TypeFieldWhat it holds
u2attribute_name_indexa Utf8: "Module"
u4attribute_lengthbytes after this field
u2module_name_indexa Module
u2module_flagsopen, synthetic, mandated
u2module_version_index
…requires, exports, opens, uses, provideseach a count and a table

What it is for

The module declaration: its name, and everything it requires, exports, opens, uses and provides. Only module-info.class has it. javac writes Module itself; the jar tool and jlink add ModulePackages, ModuleMainClass and the JDK-specific ModuleTarget and ModuleHashes.

How common it is

JDK 25.0.5's java.base has 1 Module attributes, in 1 of its 7,391 classes (1 on classs).

A real one, byte by byte

From module-info.class (compiled by javac 25), on the class:

OffsetBytesFieldValue
18842 bytesModule
18800 05attribute_name_index#5
19000 00 00 24attribute_length36
19400 06module_name_index#6
19600 00module_flags0
19800 00module_version_index#0
20000 02requires_count2
2026 bytesrequires 0
20200 08requires_index#8
20480 00requires_flags32768
20600 0arequires_version_index#10
2086 bytesrequires 1
20800 0brequires_index#11
21000 00requires_flags0
21200 0arequires_version_index#10
21400 01exports_count1
2166 bytesexports 0
21600 0dexports_index#13
21800 00exports_flags0
22000 00exports_to_count0
22200 00opens_count0
22400 01uses_count1
2262 bytesuses 0
22600 0fuses_index#15
22800 00provides_count0

Open in the viewer

Specification: JVMS §4.7, The Module Attribute (Java SE 25).