int computeAttributesSize ( ) { symbolTable . addConstantUtf8 ( Constants . MODULE ) ; // 6 attribute header bytes, 6 bytes for name, flags and version, and 5 * 2 bytes for counts. int size = 22 + requires . length + exports . length + opens . length + usesIndex . length + provides . length ; if ( packageCount > 0 ) { symbolTable . addConstantUtf8 ( Constants . MODULE_PACKAGES ) ; // 6 attribute header bytes, and 2 bytes for package_count. size += 8 + packageIndex . length ; } if ( mainClassIndex > 0 ) { symbolTable . addConstantUtf8 ( Constants . MODULE_MAIN_CLASS ) ; // 6 attribute header bytes, and 2 bytes for main_class_index. size += 8 ; } return size ; }
Returns the size of the Module ModulePackages and ModuleMainClass attributes generated by this ModuleWriter . Also add the names of these attributes in the constant pool .