< prev index next >

src/java.base/share/classes/java/lang/module/Resolver.java

Print this page

        

*** 44,53 **** --- 44,54 ---- import java.util.Set; import java.util.StringJoiner; import java.util.stream.Collectors; import jdk.internal.module.ModuleHashes; + import jdk.internal.module.ModuleReferenceImpl; /** * The resolver used by {@link Configuration#resolveRequires} and * {@link Configuration#resolveRequiresAndUses}. *
*** 436,463 **** * Checks the hashes in the module descriptor to ensure that they match * any recorded hashes. */ private void checkHashes() { for (ModuleReference mref : nameToReference.values()) { - ModuleDescriptor descriptor = mref.descriptor(); ! // get map of module hashes ! Optional<ModuleHashes> ohashes = descriptor.hashes(); ! if (!ohashes.isPresent()) continue; - ModuleHashes hashes = ohashes.get(); String algorithm = hashes.algorithm(); for (String dn : hashes.names()) { ! ModuleReference other = nameToReference.get(dn); ! if (other == null) { ResolvedModule resolvedModule = findInParent(dn); if (resolvedModule != null) ! other = resolvedModule.reference(); } // skip checking the hash if the module has been patched if (other != null && !other.isPatched()) { byte[] recordedHash = hashes.hashFor(dn); byte[] actualHash = other.computeHash(algorithm); if (actualHash == null) fail("Unable to compute the hash of module %s", dn); --- 437,472 ---- * Checks the hashes in the module descriptor to ensure that they match * any recorded hashes. */ private void checkHashes() { for (ModuleReference mref : nameToReference.values()) { ! // get the recorded hashes, if any ! if (!(mref instanceof ModuleReferenceImpl)) ! continue; ! ModuleHashes hashes = ((ModuleReferenceImpl)mref).recordedHashes(); ! if (hashes == null) continue; + ModuleDescriptor descriptor = mref.descriptor(); String algorithm = hashes.algorithm(); for (String dn : hashes.names()) { ! ModuleReference mref2 = nameToReference.get(dn); ! if (mref2 == null) { ResolvedModule resolvedModule = findInParent(dn); if (resolvedModule != null) ! mref2 = resolvedModule.reference(); ! } ! if (mref2 == null) ! continue; ! ! if (!(mref2 instanceof ModuleReferenceImpl)) { ! fail("Unable to compute the hash of module %s", dn); } // skip checking the hash if the module has been patched + ModuleReferenceImpl other = (ModuleReferenceImpl)mref2; if (other != null && !other.isPatched()) { byte[] recordedHash = hashes.hashFor(dn); byte[] actualHash = other.computeHash(algorithm); if (actualHash == null) fail("Unable to compute the hash of module %s", dn);
< prev index next >