Request Review: JDK-6479237 (cl) Add support for classloader names
Mandy Chung
mandy.chung at oracle.com
Mon Oct 31 21:34:04 UTC 2016
> On Oct 31, 2016, at 6:51 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
>>
>> if (VM.isModuleSystemInited() && !HashedModules.contains(m)) {
> Looks okay, an alternative would be to move that that check to L439.
What do you think about this?
http://cr.openjdk.java.net/~mchung/jdk9/webrevs/6479237/webrev.03/
/**
* Returns true if the module is hashed with java.base.
* <p>
* This method returns false when running on the exploded image
* since JDK modules are not hashed. They have no Version attribute
* and so "@<version>" part will be omitted anyway.
*/
private static boolean isHashedInJavaBase(Module m) {
// return true if module system is not initialized as the code
// must be in java.base
if (!VM.isModuleSystemInited())
return true;
return Layer.boot() == m.getLayer() && HashedModules.contains(m);
}
/*
* Finds JDK non-upgradeable modules, i.e. the modules that are
* included in the hashes in java.base.
*/
private static class HashedModules {
static Set<String> HASHED_MODULES = hashedModules();
static Set<String> hashedModules() {
Module javaBase = Layer.boot().findModule("java.base").get();
Optional<ModuleHashes> ohashes =
SharedSecrets.getJavaLangModuleAccess()
.hashes(javaBase.getDescriptor());
if (ohashes.isPresent()) {
Set<String> names = new HashSet<>(ohashes.get().names());
names.add("java.base");
return names;
}
return Set.of();
}
static boolean contains(Module m) {
return HASHED_MODULES.contains(m.getName());
}
}
More information about the jigsaw-dev
mailing list