238 239 // special-case java.base as it is created before the boot layer 240 if (loader == null && name.equals("java.base")) { 241 return ModuleLayer.boot(); 242 } 243 } 244 return null; 245 } 246 247 // -- 248 249 // special Module to mean "all unnamed modules" 250 private static final Module ALL_UNNAMED_MODULE; 251 private static final Set<Module> ALL_UNNAMED_MODULE_SET; 252 253 // special Module to mean "everyone" 254 private static final Module EVERYONE_MODULE; 255 private static final Set<Module> EVERYONE_SET; 256 257 private static class ArchivedData { 258 private static ArchivedData singleton; 259 260 private final Module ALL_UNNAMED_MODULE; 261 private final Set<Module> ALL_UNNAMED_MODULE_SET; 262 private final Module EVERYONE_MODULE; 263 private final Set<Module> EVERYONE_SET; 264 265 public ArchivedData(Module ALL_UNNAMED_MODULE, 266 Set<Module> ALL_UNNAMED_MODULE_SET, 267 Module EVERYONE_MODULE, 268 Set<Module> EVERYONE_SET) { 269 this.ALL_UNNAMED_MODULE = ALL_UNNAMED_MODULE; 270 this.ALL_UNNAMED_MODULE_SET = ALL_UNNAMED_MODULE_SET; 271 this.EVERYONE_MODULE = EVERYONE_MODULE; 272 this.EVERYONE_SET = EVERYONE_SET; 273 } 274 275 static void archive(ArchivedData archivedData) { 276 singleton = archivedData; 277 } 278 279 static ArchivedData get() { 280 return singleton; 281 } 282 283 static { 284 VM.initializeFromArchive(ArchivedData.class); 285 } 286 } 287 288 static { 289 ArchivedData archivedData = ArchivedData.get(); 290 if (archivedData != null) { 291 ALL_UNNAMED_MODULE = archivedData.ALL_UNNAMED_MODULE; 292 ALL_UNNAMED_MODULE_SET = archivedData.ALL_UNNAMED_MODULE_SET; 293 EVERYONE_MODULE = archivedData.EVERYONE_MODULE; 294 EVERYONE_SET = archivedData.EVERYONE_SET; 295 } else { 296 ALL_UNNAMED_MODULE = new Module(null); 297 ALL_UNNAMED_MODULE_SET = Set.of(ALL_UNNAMED_MODULE); 298 EVERYONE_MODULE = new Module(null); 299 EVERYONE_SET = Set.of(EVERYONE_MODULE); 300 301 ArchivedData.archive(new ArchivedData(ALL_UNNAMED_MODULE, 302 ALL_UNNAMED_MODULE_SET, 303 EVERYONE_MODULE, 304 EVERYONE_SET)); 305 } 306 } 307 308 /** 309 * The holder of data structures to support readability, exports, and 310 * service use added at runtime with the reflective APIs. 311 */ 312 private static class ReflectionData { 313 /** 314 * A module (1st key) reads another module (2nd key) 315 */ 316 static final WeakPairMap<Module, Module, Boolean> reads = 317 new WeakPairMap<>(); 318 319 /** 320 * A module (1st key) exports or opens a package to another module 321 * (2nd key). The map value is a map of package name to a boolean 322 * that indicates if the package is opened. 323 */ 324 static final WeakPairMap<Module, Module, Map<String, Boolean>> exports = | 238 239 // special-case java.base as it is created before the boot layer 240 if (loader == null && name.equals("java.base")) { 241 return ModuleLayer.boot(); 242 } 243 } 244 return null; 245 } 246 247 // -- 248 249 // special Module to mean "all unnamed modules" 250 private static final Module ALL_UNNAMED_MODULE; 251 private static final Set<Module> ALL_UNNAMED_MODULE_SET; 252 253 // special Module to mean "everyone" 254 private static final Module EVERYONE_MODULE; 255 private static final Set<Module> EVERYONE_SET; 256 257 private static class ArchivedData { 258 private static ArchivedData archivedData; 259 private final Module allUnnamedModule; 260 private final Set<Module> allUnnamedModules; 261 private final Module everyoneModule; 262 private final Set<Module> everyoneSet; 263 264 private ArchivedData() { 265 this.allUnnamedModule = ALL_UNNAMED_MODULE; 266 this.allUnnamedModules = ALL_UNNAMED_MODULE_SET; 267 this.everyoneModule = EVERYONE_MODULE; 268 this.everyoneSet = EVERYONE_SET; 269 } 270 271 static void archive() { 272 archivedData = new ArchivedData(); 273 } 274 275 static ArchivedData get() { 276 return archivedData; 277 } 278 279 static { 280 VM.initializeFromArchive(ArchivedData.class); 281 } 282 } 283 284 static { 285 ArchivedData archivedData = ArchivedData.get(); 286 if (archivedData != null) { 287 ALL_UNNAMED_MODULE = archivedData.allUnnamedModule; 288 ALL_UNNAMED_MODULE_SET = archivedData.allUnnamedModules; 289 EVERYONE_MODULE = archivedData.everyoneModule; 290 EVERYONE_SET = archivedData.everyoneSet; 291 } else { 292 ALL_UNNAMED_MODULE = new Module(null); 293 ALL_UNNAMED_MODULE_SET = Set.of(ALL_UNNAMED_MODULE); 294 EVERYONE_MODULE = new Module(null); 295 EVERYONE_SET = Set.of(EVERYONE_MODULE); 296 ArchivedData.archive(); 297 } 298 } 299 300 /** 301 * The holder of data structures to support readability, exports, and 302 * service use added at runtime with the reflective APIs. 303 */ 304 private static class ReflectionData { 305 /** 306 * A module (1st key) reads another module (2nd key) 307 */ 308 static final WeakPairMap<Module, Module, Boolean> reads = 309 new WeakPairMap<>(); 310 311 /** 312 * A module (1st key) exports or opens a package to another module 313 * (2nd key). The map value is a map of package name to a boolean 314 * that indicates if the package is opened. 315 */ 316 static final WeakPairMap<Module, Module, Map<String, Boolean>> exports = |