Search in sources :

Example 6 with ModuleReader

use of java.lang.module.ModuleReader in project Bytecoder by mirkosertic.

the class SystemModuleFinders method toModuleReference.

/**
 * Creates a ModuleReference to the system module.
 */
static ModuleReference toModuleReference(ModuleDescriptor descriptor, ModuleTarget target, ModuleHashes recordedHashes, HashSupplier hasher, ModuleResolution mres) {
    String mn = descriptor.name();
    URI uri = JNUA.create("jrt", "/".concat(mn));
    Supplier<ModuleReader> readerSupplier = new Supplier<>() {

        @Override
        public ModuleReader get() {
            return new SystemModuleReader(mn, uri);
        }
    };
    ModuleReference mref = new ModuleReferenceImpl(descriptor, uri, readerSupplier, null, target, recordedHashes, hasher, mres);
    // may need a reference to a patched module if --patch-module specified
    mref = ModuleBootstrap.patcher().patchIfNeeded(mref);
    return mref;
}
Also used : ModuleReader(java.lang.module.ModuleReader) ModuleReference(java.lang.module.ModuleReference) Supplier(java.util.function.Supplier) HashSupplier(jdk.internal.module.ModuleHashes.HashSupplier) URI(java.net.URI)

Aggregations

ModuleReader (java.lang.module.ModuleReader)6 IOException (java.io.IOException)5 ModuleReference (java.lang.module.ModuleReference)5 ByteBuffer (java.nio.ByteBuffer)4 UncheckedIOException (java.io.UncheckedIOException)3 URI (java.net.URI)3 Supplier (java.util.function.Supplier)3 HashSupplier (jdk.internal.module.ModuleHashes.HashSupplier)3 File (java.io.File)2 IOError (java.io.IOError)2 InputStream (java.io.InputStream)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 List (java.util.List)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Lock (java.util.concurrent.locks.Lock)2 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)2 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)2 JarEntry (java.util.jar.JarEntry)2