< prev index next >

src/java.base/share/classes/jdk/internal/loader/BootLoader.java

Print this page


  26 
  27 import java.io.IOException;
  28 import java.io.InputStream;
  29 import java.lang.module.ModuleReference;
  30 import java.net.MalformedURLException;
  31 import java.net.URI;
  32 import java.net.URL;
  33 import java.nio.file.Files;
  34 import java.nio.file.Path;
  35 import java.security.AccessController;
  36 import java.security.PrivilegedAction;
  37 import java.util.Arrays;
  38 import java.util.Enumeration;
  39 import java.util.concurrent.ConcurrentHashMap;
  40 import java.util.jar.JarInputStream;
  41 import java.util.jar.Manifest;
  42 import java.util.stream.Stream;
  43 
  44 import jdk.internal.access.JavaLangAccess;
  45 import jdk.internal.access.SharedSecrets;

  46 import jdk.internal.module.Modules;
  47 import jdk.internal.module.ServicesCatalog;
  48 import jdk.internal.util.StaticProperty;
  49 
  50 /**
  51  * Find resources and packages in modules defined to the boot class loader or
  52  * resources and packages on the "boot class path" specified via -Xbootclasspath/a.
  53  */
  54 
  55 public class BootLoader {
  56     private BootLoader() { }
  57 
  58     // The unnamed module for the boot loader
  59     private static final Module UNNAMED_MODULE;
  60     private static final String JAVA_HOME = StaticProperty.javaHome();
  61 
  62     static {
  63         UNNAMED_MODULE = SharedSecrets.getJavaLangAccess().defineUnnamedModule(null);
  64         setBootLoaderUnnamedModule0(UNNAMED_MODULE);
  65     }
  66 
  67     // ServiceCatalog for the boot class loader
  68     private static final ServicesCatalog SERVICES_CATALOG = ServicesCatalog.create();















  69 
  70     // ClassLoaderValue map for the boot class loader
  71     private static final ConcurrentHashMap<?, ?> CLASS_LOADER_VALUE_MAP
  72         = new ConcurrentHashMap<>();
  73 
  74     // native libraries loaded by the boot class loader
  75     private static final NativeLibraries NATIVE_LIBS
  76         = NativeLibraries.jniNativeLibraries(null);
  77 
  78     /**
  79      * Returns the unnamed module for the boot loader.
  80      */
  81     public static Module getUnnamedModule() {
  82         return UNNAMED_MODULE;
  83     }
  84 
  85     /**
  86      * Returns the ServiceCatalog for modules defined to the boot class loader.
  87      */
  88     public static ServicesCatalog getServicesCatalog() {




  26 
  27 import java.io.IOException;
  28 import java.io.InputStream;
  29 import java.lang.module.ModuleReference;
  30 import java.net.MalformedURLException;
  31 import java.net.URI;
  32 import java.net.URL;
  33 import java.nio.file.Files;
  34 import java.nio.file.Path;
  35 import java.security.AccessController;
  36 import java.security.PrivilegedAction;
  37 import java.util.Arrays;
  38 import java.util.Enumeration;
  39 import java.util.concurrent.ConcurrentHashMap;
  40 import java.util.jar.JarInputStream;
  41 import java.util.jar.Manifest;
  42 import java.util.stream.Stream;
  43 
  44 import jdk.internal.access.JavaLangAccess;
  45 import jdk.internal.access.SharedSecrets;
  46 import jdk.internal.misc.VM;
  47 import jdk.internal.module.Modules;
  48 import jdk.internal.module.ServicesCatalog;
  49 import jdk.internal.util.StaticProperty;
  50 
  51 /**
  52  * Find resources and packages in modules defined to the boot class loader or
  53  * resources and packages on the "boot class path" specified via -Xbootclasspath/a.
  54  */
  55 
  56 public class BootLoader {
  57     private BootLoader() { }
  58 
  59     // The unnamed module for the boot loader
  60     private static final Module UNNAMED_MODULE;
  61     private static final String JAVA_HOME = StaticProperty.javaHome();
  62 
  63     static {
  64         UNNAMED_MODULE = SharedSecrets.getJavaLangAccess().defineUnnamedModule(null);
  65         setBootLoaderUnnamedModule0(UNNAMED_MODULE);
  66     }
  67 
  68     // ServiceCatalog for the boot class loader
  69     private static final ServicesCatalog SERVICES_CATALOG;
  70     static {
  71         if (ArchivedData.servicesCatalog != null) {
  72             SERVICES_CATALOG = ArchivedData.servicesCatalog;
  73         } else {
  74             SERVICES_CATALOG = ServicesCatalog.create();
  75             ArchivedData.servicesCatalog = SERVICES_CATALOG;
  76         }
  77     }
  78 
  79     static class ArchivedData {
  80         static ServicesCatalog servicesCatalog;
  81         static {
  82             VM.initializeFromArchive(ArchivedData.class);
  83         }
  84     }
  85 
  86     // ClassLoaderValue map for the boot class loader
  87     private static final ConcurrentHashMap<?, ?> CLASS_LOADER_VALUE_MAP
  88         = new ConcurrentHashMap<>();
  89 
  90     // native libraries loaded by the boot class loader
  91     private static final NativeLibraries NATIVE_LIBS
  92         = NativeLibraries.jniNativeLibraries(null);
  93 
  94     /**
  95      * Returns the unnamed module for the boot loader.
  96      */
  97     public static Module getUnnamedModule() {
  98         return UNNAMED_MODULE;
  99     }
 100 
 101     /**
 102      * Returns the ServiceCatalog for modules defined to the boot class loader.
 103      */
 104     public static ServicesCatalog getServicesCatalog() {


< prev index next >