< prev index next >

src/java.base/share/classes/jdk/internal/module/ModuleInfo.java

Print this page

        

*** 87,108 **** --- 87,114 ---- * that represent the non-standard class file attributes that are read from * the class file. */ public static final class Attributes { private final ModuleDescriptor descriptor; + private final ModuleTarget target; private final ModuleHashes recordedHashes; private final ModuleResolution moduleResolution; Attributes(ModuleDescriptor descriptor, + ModuleTarget target, ModuleHashes recordedHashes, ModuleResolution moduleResolution) { this.descriptor = descriptor; + this.target = target; this.recordedHashes = recordedHashes; this.moduleResolution = moduleResolution; } public ModuleDescriptor descriptor() { return descriptor; } + public ModuleTarget target() { + return target; + } public ModuleHashes recordedHashes() { return recordedHashes; } public ModuleResolution moduleResolution() { return moduleResolution;
*** 219,230 **** Set<String> attributes = new HashSet<>(); Builder builder = null; Set<String> allPackages = null; String mainClass = null; ! String[] osValues = null; ! ModuleHashes hashes = null; ModuleResolution moduleResolution = null; for (int i = 0; i < attributes_count ; i++) { int name_index = in.readUnsignedShort(); String attribute_name = cpool.getUtf8(name_index); --- 225,236 ---- Set<String> attributes = new HashSet<>(); Builder builder = null; Set<String> allPackages = null; String mainClass = null; ! ModuleTarget moduleTarget = null; ! ModuleHashes moduelHashes = null; ModuleResolution moduleResolution = null; for (int i = 0; i < attributes_count ; i++) { int name_index = in.readUnsignedShort(); String attribute_name = cpool.getUtf8(name_index);
*** 249,264 **** case MODULE_MAIN_CLASS : mainClass = readModuleMainClassAttribute(in, cpool); break; case MODULE_TARGET : ! osValues = readModuleTargetAttribute(in, cpool); break; case MODULE_HASHES : if (parseHashes) { ! hashes = readModuleHashesAttribute(in, cpool); } else { in.skipBytes(length); } break; --- 255,270 ---- case MODULE_MAIN_CLASS : mainClass = readModuleMainClassAttribute(in, cpool); break; case MODULE_TARGET : ! moduleTarget = readModuleTargetAttribute(in, cpool); break; case MODULE_HASHES : if (parseHashes) { ! moduelHashes = readModuleHashesAttribute(in, cpool); } else { in.skipBytes(length); } break;
*** 280,298 **** // the Module attribute is required if (builder == null) { throw invalidModuleDescriptor(MODULE + " attribute not found"); } ! // ModuleMainClass and ModuleTarget attributes if (mainClass != null) { builder.mainClass(mainClass); } - if (osValues != null) { - if (osValues[0] != null) builder.osName(osValues[0]); - if (osValues[1] != null) builder.osArch(osValues[1]); - if (osValues[2] != null) builder.osVersion(osValues[2]); - } // If the ModulePackages attribute is not present then the packageFinder // is used to find the set of packages boolean usedPackageFinder = false; if (allPackages == null && packageFinder != null) { --- 286,299 ---- // the Module attribute is required if (builder == null) { throw invalidModuleDescriptor(MODULE + " attribute not found"); } ! // ModuleMainClass attribute if (mainClass != null) { builder.mainClass(mainClass); } // If the ModulePackages attribute is not present then the packageFinder // is used to find the set of packages boolean usedPackageFinder = false; if (allPackages == null && packageFinder != null) {
*** 321,331 **** } builder.packages(allPackages); } ModuleDescriptor descriptor = builder.build(); ! return new Attributes(descriptor, hashes, moduleResolution); } /** * Reads the Module attribute, returning the ModuleDescriptor.Builder to * build the corresponding ModuleDescriptor. --- 322,335 ---- } builder.packages(allPackages); } ModuleDescriptor descriptor = builder.build(); ! return new Attributes(descriptor, ! moduleTarget, ! moduelHashes, ! moduleResolution); } /** * Reads the Module attribute, returning the ModuleDescriptor.Builder to * build the corresponding ModuleDescriptor.
*** 420,430 **** int exports_to_count = in.readUnsignedShort(); if (exports_to_count > 0) { Set<String> targets = new HashSet<>(exports_to_count); for (int j=0; j<exports_to_count; j++) { int exports_to_index = in.readUnsignedShort(); ! targets.add(cpool.getModuleName(exports_to_index)); } builder.exports(mods, pkg, targets); } else { builder.exports(mods, pkg); } --- 424,438 ---- int exports_to_count = in.readUnsignedShort(); if (exports_to_count > 0) { Set<String> targets = new HashSet<>(exports_to_count); for (int j=0; j<exports_to_count; j++) { int exports_to_index = in.readUnsignedShort(); ! String target = cpool.getModuleName(exports_to_index); ! if (!targets.add(target)) { ! throw invalidModuleDescriptor(pkg + " exported to " ! + target + " more than once"); ! } } builder.exports(mods, pkg, targets); } else { builder.exports(mods, pkg); }
*** 456,466 **** int open_to_count = in.readUnsignedShort(); if (open_to_count > 0) { Set<String> targets = new HashSet<>(open_to_count); for (int j=0; j<open_to_count; j++) { int opens_to_index = in.readUnsignedShort(); ! targets.add(cpool.getModuleName(opens_to_index)); } builder.opens(mods, pkg, targets); } else { builder.opens(mods, pkg); } --- 464,478 ---- int open_to_count = in.readUnsignedShort(); if (open_to_count > 0) { Set<String> targets = new HashSet<>(open_to_count); for (int j=0; j<open_to_count; j++) { int opens_to_index = in.readUnsignedShort(); ! String target = cpool.getModuleName(opens_to_index); ! if (!targets.add(target)) { ! throw invalidModuleDescriptor(pkg + " opened to " ! + target + " more than once"); ! } } builder.opens(mods, pkg, targets); } else { builder.opens(mods, pkg); }
*** 484,494 **** int with_count = in.readUnsignedShort(); List<String> providers = new ArrayList<>(with_count); for (int j=0; j<with_count; j++) { index = in.readUnsignedShort(); String pn = cpool.getClassName(index); ! providers.add(pn); } builder.provides(sn, providers); } } --- 496,509 ---- int with_count = in.readUnsignedShort(); List<String> providers = new ArrayList<>(with_count); for (int j=0; j<with_count; j++) { index = in.readUnsignedShort(); String pn = cpool.getClassName(index); ! if (!providers.add(pn)) { ! throw invalidModuleDescriptor(sn + " provides " + pn ! + " more than once"); ! } } builder.provides(sn, providers); } }
*** 526,553 **** } /** * Reads the ModuleTarget attribute */ ! private String[] readModuleTargetAttribute(DataInput in, ConstantPool cpool) throws IOException { ! String[] values = new String[3]; int name_index = in.readUnsignedShort(); if (name_index != 0) ! values[0] = cpool.getUtf8(name_index); int arch_index = in.readUnsignedShort(); if (arch_index != 0) ! values[1] = cpool.getUtf8(arch_index); ! ! int version_index = in.readUnsignedShort(); ! if (version_index != 0) ! values[2] = cpool.getUtf8(version_index); ! return values; } /** * Reads the ModuleHashes attribute --- 541,565 ---- } /** * Reads the ModuleTarget attribute */ ! private ModuleTarget readModuleTargetAttribute(DataInput in, ConstantPool cpool) throws IOException { ! String osName = null; ! String osArch = null; int name_index = in.readUnsignedShort(); if (name_index != 0) ! osName = cpool.getUtf8(name_index); int arch_index = in.readUnsignedShort(); if (arch_index != 0) ! osArch = cpool.getUtf8(arch_index); ! return new ModuleTarget(osName, osArch); } /** * Reads the ModuleHashes attribute
< prev index next >