< prev index next >
src/java.base/share/classes/jdk/internal/module/ModuleReferences.java
Print this page
*** 21,37 ****
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
! package java.lang.module;
import java.io.File;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
--- 21,39 ----
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
! package jdk.internal.module;
import java.io.File;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
+ import java.lang.module.ModuleReader;
+ import java.lang.module.ModuleReference;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
*** 49,62 ****
import java.util.zip.ZipFile;
import jdk.internal.jmod.JmodFile;
import jdk.internal.misc.JavaLangAccess;
import jdk.internal.misc.SharedSecrets;
- import jdk.internal.module.ModuleBootstrap;
- import jdk.internal.module.ModuleHashes;
import jdk.internal.module.ModuleHashes.HashSupplier;
- import jdk.internal.module.ModulePatcher;
import jdk.internal.util.jar.VersionedStream;
import sun.net.www.ParseUtil;
/**
--- 51,61 ----
*** 73,120 ****
/**
* Creates a ModuleReference to a module or to patched module when
* creating modules for the boot Layer and --patch-module is specified.
*/
! private static ModuleReference newModule(ModuleDescriptor md,
URI uri,
Supplier<ModuleReader> supplier,
HashSupplier hasher) {
! ModuleReference mref = new ModuleReference(md, uri, supplier, hasher);
if (JLA.getBootLayer() == null)
mref = ModuleBootstrap.patcher().patchIfNeeded(mref);
return mref;
}
/**
* Creates a ModuleReference to a module packaged as a modular JAR.
*/
! static ModuleReference newJarModule(ModuleDescriptor md, Path file) {
URI uri = file.toUri();
Supplier<ModuleReader> supplier = () -> new JarModuleReader(file, uri);
HashSupplier hasher = (a) -> ModuleHashes.computeHash(file, a);
! return newModule(md, uri, supplier, hasher);
}
/**
* Creates a ModuleReference to a module packaged as a JMOD.
*/
! static ModuleReference newJModModule(ModuleDescriptor md, Path file) {
URI uri = file.toUri();
Supplier<ModuleReader> supplier = () -> new JModModuleReader(file, uri);
HashSupplier hasher = (a) -> ModuleHashes.computeHash(file, a);
! return newModule(md, file.toUri(), supplier, hasher);
}
/**
* Creates a ModuleReference to an exploded module.
*/
! static ModuleReference newExplodedModule(ModuleDescriptor md, Path dir) {
Supplier<ModuleReader> supplier = () -> new ExplodedModuleReader(dir);
! return newModule(md, dir.toUri(), supplier, null);
}
/**
* A base module reader that encapsulates machinery required to close the
--- 72,125 ----
/**
* Creates a ModuleReference to a module or to patched module when
* creating modules for the boot Layer and --patch-module is specified.
*/
! private static ModuleReference newModule(ModuleInfo.Attributes attrs,
URI uri,
Supplier<ModuleReader> supplier,
HashSupplier hasher) {
! ModuleReference mref = new ModuleReferenceImpl(attrs.descriptor(),
! uri,
! supplier,
! null,
! attrs.recordedHashes(),
! hasher,
! attrs.moduleResolution());
if (JLA.getBootLayer() == null)
mref = ModuleBootstrap.patcher().patchIfNeeded(mref);
return mref;
}
/**
* Creates a ModuleReference to a module packaged as a modular JAR.
*/
! static ModuleReference newJarModule(ModuleInfo.Attributes attrs, Path file) {
URI uri = file.toUri();
Supplier<ModuleReader> supplier = () -> new JarModuleReader(file, uri);
HashSupplier hasher = (a) -> ModuleHashes.computeHash(file, a);
! return newModule(attrs, uri, supplier, hasher);
}
/**
* Creates a ModuleReference to a module packaged as a JMOD.
*/
! static ModuleReference newJModModule(ModuleInfo.Attributes attrs, Path file) {
URI uri = file.toUri();
Supplier<ModuleReader> supplier = () -> new JModModuleReader(file, uri);
HashSupplier hasher = (a) -> ModuleHashes.computeHash(file, a);
! return newModule(attrs, uri, supplier, hasher);
}
/**
* Creates a ModuleReference to an exploded module.
*/
! static ModuleReference newExplodedModule(ModuleInfo.Attributes attrs, Path dir) {
Supplier<ModuleReader> supplier = () -> new ExplodedModuleReader(dir);
! return newModule(attrs, dir.toUri(), supplier, null);
}
/**
* A base module reader that encapsulates machinery required to close the
< prev index next >