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 JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
64 ArchivedClassLoaders archivedClassLoaders = ArchivedClassLoaders.get();
65 if (archivedClassLoaders != null) {
66 UNNAMED_MODULE = archivedClassLoaders.unnamedModuleForBootLoader();
67 } else {
68 UNNAMED_MODULE = jla.defineUnnamedModule(null);
69 }
70 jla.addEnableNativeAccess(UNNAMED_MODULE);
71 setBootLoaderUnnamedModule0(UNNAMED_MODULE);
72 }
73
74 // ClassLoaderValue map for the boot class loader
75 private static final ConcurrentHashMap<?, ?> CLASS_LOADER_VALUE_MAP
76 = new ConcurrentHashMap<>();
77
78 // native libraries loaded by the boot class loader
79 private static final NativeLibraries NATIVE_LIBS
80 = NativeLibraries.newInstance(null);
81
82 /**
83 * Returns the unnamed module for the boot loader.
84 */
85 public static Module getUnnamedModule() {
86 return UNNAMED_MODULE;
87 }
88
89 /**
90 * Returns the ServiceCatalog for modules defined to the boot class loader.
91 */
92 public static ServicesCatalog getServicesCatalog() {
93 return ServicesCatalog.getServicesCatalog(ClassLoaders.bootLoader());
94 }
95
96 /**
97 * Returns the ClassLoaderValue map for the boot class loader.
98 */
99 public static ConcurrentHashMap<?, ?> getClassLoaderValueMap() {
100 return CLASS_LOADER_VALUE_MAP;
101 }
102
103 /**
104 * Returns NativeLibraries for the boot class loader.
105 */
106 public static NativeLibraries getNativeLibraries() {
107 return NATIVE_LIBS;
108 }
109
110 /**
111 * Returns {@code true} if there is a class path associated with the
112 * BootLoader.
113 */
114 public static boolean hasClassPath() {
115 return ClassLoaders.bootLoader().hasClassPath();
116 }
117
118 /**
119 * Registers a module with this class loader so that its classes
120 * (and resources) become visible via this class loader.
121 */
122 public static void loadModule(ModuleReference mref) {
123 ClassLoaders.bootLoader().loadModule(mref);
124 }
125
126 /**
127 * Loads the Class object with the given name defined to the boot loader.
|
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 JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
64 ArchivedClassLoaders archivedClassLoaders = ArchivedClassLoaders.get();
65 if (archivedClassLoaders != null) {
66 UNNAMED_MODULE = archivedClassLoaders.unnamedModuleForBootLoader();
67 } else {
68 UNNAMED_MODULE = jla.defineUnnamedModule(null);
69 }
70 jla.addEnableNativeAccess(UNNAMED_MODULE);
71 setBootLoaderUnnamedModule0(UNNAMED_MODULE);
72 }
73
74 // ClassLoaderValue map for the boot class loader
75 private static final ConcurrentHashMap<?, ?> CLASS_LOADER_VALUE_MAP
76 = new ConcurrentHashMap<>();
77
78 // Holder has the field(s) that need to be initialized during JVM bootstrap even if
79 // the outer is aot-initialized.
80 private static class Holder {
81 // native libraries loaded by the boot class loader
82 private static final NativeLibraries NATIVE_LIBS
83 = NativeLibraries.newInstance(null);
84 }
85
86 /**
87 * Returns the unnamed module for the boot loader.
88 */
89 public static Module getUnnamedModule() {
90 return UNNAMED_MODULE;
91 }
92
93 /**
94 * Returns the ServiceCatalog for modules defined to the boot class loader.
95 */
96 public static ServicesCatalog getServicesCatalog() {
97 return ServicesCatalog.getServicesCatalog(ClassLoaders.bootLoader());
98 }
99
100 /**
101 * Returns the ClassLoaderValue map for the boot class loader.
102 */
103 public static ConcurrentHashMap<?, ?> getClassLoaderValueMap() {
104 return CLASS_LOADER_VALUE_MAP;
105 }
106
107 /**
108 * Returns NativeLibraries for the boot class loader.
109 */
110 public static NativeLibraries getNativeLibraries() {
111 return Holder.NATIVE_LIBS;
112 }
113
114 /**
115 * Returns {@code true} if there is a class path associated with the
116 * BootLoader.
117 */
118 public static boolean hasClassPath() {
119 return ClassLoaders.bootLoader().hasClassPath();
120 }
121
122 /**
123 * Registers a module with this class loader so that its classes
124 * (and resources) become visible via this class loader.
125 */
126 public static void loadModule(ModuleReference mref) {
127 ClassLoaders.bootLoader().loadModule(mref);
128 }
129
130 /**
131 * Loads the Class object with the given name defined to the boot loader.
|