mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8263968: CDS: java/lang/ModuleLayer.EMPTY_LAYER should be singleton
Reviewed-by: iklam, dholmes, alanb, redestad
This commit is contained in:
parent
3aee5ad2dd
commit
133a63b4a1
3 changed files with 22 additions and 3 deletions
|
@ -48,6 +48,8 @@ import jdk.internal.loader.ClassLoaderValue;
|
|||
import jdk.internal.loader.Loader;
|
||||
import jdk.internal.loader.LoaderPool;
|
||||
import jdk.internal.module.ServicesCatalog;
|
||||
import jdk.internal.misc.CDS;
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
|
||||
|
@ -147,9 +149,15 @@ import sun.security.util.SecurityConstants;
|
|||
|
||||
public final class ModuleLayer {
|
||||
|
||||
// the empty layer
|
||||
private static final ModuleLayer EMPTY_LAYER
|
||||
= new ModuleLayer(Configuration.empty(), List.of(), null);
|
||||
// the empty layer (may be initialized from the CDS archive)
|
||||
private static @Stable ModuleLayer EMPTY_LAYER;
|
||||
static {
|
||||
CDS.initializeFromArchive(ModuleLayer.class);
|
||||
if (EMPTY_LAYER == null) {
|
||||
// create a new empty layer if there is no archived version.
|
||||
EMPTY_LAYER = new ModuleLayer(Configuration.empty(), List.of(), null);
|
||||
}
|
||||
}
|
||||
|
||||
// the configuration from which this layer was created
|
||||
private final Configuration cf;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue