ModulePackages attribute
Every package in the module, including those it does not export, so the module system does not have to scan the module's contents..
- Appears on
- class
- Since
- class file 53.0 (Java 9)
- javac writes it
- not by javac; the jar tool and jlink add 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: "ModulePackages" |
u4 | attribute_length | bytes after this field |
u2 | package_count | |
u2[…] | package_index | Package entries |
What it is for
Every package in the module, including those it does not export, so the module system does not have to scan the module's contents.
How common it is
JDK 25.0.5's java.base has 1 ModulePackages attributes, in 1 of its 7,391 classes (1 on classs).
Specification: JVMS §4.7, The ModulePackages Attribute (Java SE 25).