The ModulePackages attribute is a variable-length attribute in the attributes table of a ClassFile structure. The ModulePackages attribute indicates all the packages of a module that are exported or opened by the Module attribute, as well as all the packages of the service implementations recorded in the Module attribute. The ModulePackages attribute may also indicate packages in the module that are neither exported nor opened nor contain service implementations.
There may be at most one ModulePackages attribute in the attributes table of a ClassFile structure.
The ModulePackages attribute has the following format:
ModulePackages_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 package_count;
u2 package_index[package_count];
}
The items of the ModulePackages_attribute structure are as follows:
-
attribute_name_index
The value of the
attribute_name_indexitem must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be aCONSTANT_Utf8_infostructure representing the string "ModulePackages". -
attribute_length
The value of the
attribute_lengthitem is the length of the attribute excluding the initial six bytes. -
package_count
The value of the
package_countitem indicates the number of entries in thepackage_indextable. -
package_index[]
The value of each entry in the
package_indextable must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be aCONSTANT_Package_infostructure representing a package in the current module.At most one entry in the
package_indextable may specify a package of a given name.