Reads the module attribute and visit it. @param classVisitor the current class visitor @param context information about the class being parsed. @param moduleOffset the offset of the Module attribute (excluding the attribute_info's attribute_name_index and attribute_length fields). @param module
(
final ClassVisitor classVisitor,
final Context context,
final int moduleOffset,
final int modulePackagesOffset,
final String moduleMainClass)
| 699 | * @param moduleMainClass the string corresponding to the ModuleMainClass attribute, or null. |
| 700 | */ |
| 701 | private void readModule( |
| 702 | final ClassVisitor classVisitor, |
| 703 | final Context context, |
| 704 | final int moduleOffset, |
| 705 | final int modulePackagesOffset, |
| 706 | final String moduleMainClass) { |
| 707 | char[] buffer = context.charBuffer; |
| 708 | |
| 709 | // Read the module_name_index, module_flags and module_version_index fields and visit them. |
| 710 | int currentOffset = moduleOffset; |
| 711 | String moduleName = readModule(currentOffset, buffer); |
| 712 | int moduleFlags = readUnsignedShort(currentOffset + 2); |
| 713 | String moduleVersion = readUTF8(currentOffset + 4, buffer); |
| 714 | currentOffset += 6; |
| 715 | ModuleVisitor moduleVisitor = classVisitor.visitModule(moduleName, moduleFlags, moduleVersion); |
| 716 | if (moduleVisitor == null) { |
| 717 | return; |
| 718 | } |
| 719 | |
| 720 | // Visit the ModuleMainClass attribute. |
| 721 | if (moduleMainClass != null) { |
| 722 | moduleVisitor.visitMainClass(moduleMainClass); |
| 723 | } |
| 724 | |
| 725 | // Visit the ModulePackages attribute. |
| 726 | if (modulePackagesOffset != 0) { |
| 727 | int packageCount = readUnsignedShort(modulePackagesOffset); |
| 728 | int currentPackageOffset = modulePackagesOffset + 2; |
| 729 | while (packageCount-- > 0) { |
| 730 | moduleVisitor.visitPackage(readPackage(currentPackageOffset, buffer)); |
| 731 | currentPackageOffset += 2; |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | // Read the 'requires_count' and 'requires' fields. |
| 736 | int requiresCount = readUnsignedShort(currentOffset); |
| 737 | currentOffset += 2; |
| 738 | while (requiresCount-- > 0) { |
| 739 | // Read the requires_index, requires_flags and requires_version fields and visit them. |
| 740 | String requires = readModule(currentOffset, buffer); |
| 741 | int requiresFlags = readUnsignedShort(currentOffset + 2); |
| 742 | String requiresVersion = readUTF8(currentOffset + 4, buffer); |
| 743 | currentOffset += 6; |
| 744 | moduleVisitor.visitRequire(requires, requiresFlags, requiresVersion); |
| 745 | } |
| 746 | |
| 747 | // Read the 'exports_count' and 'exports' fields. |
| 748 | int exportsCount = readUnsignedShort(currentOffset); |
| 749 | currentOffset += 2; |
| 750 | while (exportsCount-- > 0) { |
| 751 | // Read the exports_index, exports_flags, exports_to_count and exports_to_index fields |
| 752 | // and visit them. |
| 753 | String exports = readPackage(currentOffset, buffer); |
| 754 | int exportsFlags = readUnsignedShort(currentOffset + 2); |
| 755 | int exportsToCount = readUnsignedShort(currentOffset + 4); |
| 756 | currentOffset += 6; |
| 757 | String[] exportsTo = null; |
| 758 | if (exportsToCount != 0) { |
no test coverage detected