51 import jdk.internal.module.ModuleHashes;
52 import jdk.internal.module.ModuleHashes.HashSupplier;
53 import jdk.internal.module.ModulePatcher;
54 import sun.net.www.ParseUtil;
55
56
57 /**
58 * A factory for creating ModuleReference implementations where the modules are
59 * packaged as modular JAR file, JMOD files or where the modules are exploded
60 * on the file system.
61 */
62
63 class ModuleReferences {
64
65 private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
66
67 private ModuleReferences() { }
68
69 /**
70 * Creates a ModuleReference to a module or to patched module when
71 * creating modules for the boot Layer and -Xpatch is specified.
72 */
73 private static ModuleReference newModule(ModuleDescriptor md,
74 URI uri,
75 Supplier<ModuleReader> supplier,
76 HashSupplier hasher) {
77
78 ModuleReference mref = new ModuleReference(md, uri, supplier, hasher);
79
80 if (JLA.getBootLayer() == null)
81 mref = ModulePatcher.interposeIfNeeded(mref);
82
83 return mref;
84 }
85
86 /**
87 * Creates a ModuleReference to a module packaged as a modular JAR.
88 */
89 static ModuleReference newJarModule(ModuleDescriptor md, Path file) {
90 URI uri = file.toUri();
91 Supplier<ModuleReader> supplier = () -> new JarModuleReader(file, uri);
|
51 import jdk.internal.module.ModuleHashes;
52 import jdk.internal.module.ModuleHashes.HashSupplier;
53 import jdk.internal.module.ModulePatcher;
54 import sun.net.www.ParseUtil;
55
56
57 /**
58 * A factory for creating ModuleReference implementations where the modules are
59 * packaged as modular JAR file, JMOD files or where the modules are exploded
60 * on the file system.
61 */
62
63 class ModuleReferences {
64
65 private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
66
67 private ModuleReferences() { }
68
69 /**
70 * Creates a ModuleReference to a module or to patched module when
71 * creating modules for the boot Layer and --patch-module is specified.
72 */
73 private static ModuleReference newModule(ModuleDescriptor md,
74 URI uri,
75 Supplier<ModuleReader> supplier,
76 HashSupplier hasher) {
77
78 ModuleReference mref = new ModuleReference(md, uri, supplier, hasher);
79
80 if (JLA.getBootLayer() == null)
81 mref = ModulePatcher.interposeIfNeeded(mref);
82
83 return mref;
84 }
85
86 /**
87 * Creates a ModuleReference to a module packaged as a modular JAR.
88 */
89 static ModuleReference newJarModule(ModuleDescriptor md, Path file) {
90 URI uri = file.toUri();
91 Supplier<ModuleReader> supplier = () -> new JarModuleReader(file, uri);
|