src/java.base/share/classes/jdk/internal/module/ArchivedModuleGraph.java
changeset 51371 3ab8b84e93cd
parent 50951 b96466cdfc45
child 52872 357d2b80748d
equal deleted inserted replaced
51370:fbb62267e5e9 51371:3ab8b84e93cd
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package jdk.internal.module;
    26 package jdk.internal.module;
    27 
    27 
       
    28 import java.lang.module.Configuration;
    28 import java.lang.module.ModuleFinder;
    29 import java.lang.module.ModuleFinder;
    29 import java.util.Objects;
    30 import java.util.Objects;
    30 import jdk.internal.misc.VM;
    31 import jdk.internal.misc.VM;
    31 
    32 
    32 /**
    33 /**
    34  */
    35  */
    35 final class ArchivedModuleGraph {
    36 final class ArchivedModuleGraph {
    36     private static String archivedMainModule;
    37     private static String archivedMainModule;
    37     private static SystemModules archivedSystemModules;
    38     private static SystemModules archivedSystemModules;
    38     private static ModuleFinder archivedModuleFinder;
    39     private static ModuleFinder archivedModuleFinder;
       
    40     private static Configuration archivedConfiguration;
    39 
    41 
    40     private final SystemModules systemModules;
    42     private final SystemModules systemModules;
    41     private final ModuleFinder finder;
    43     private final ModuleFinder finder;
       
    44     private final Configuration configuration;
    42 
    45 
    43     private ArchivedModuleGraph(SystemModules modules, ModuleFinder finder) {
    46     private ArchivedModuleGraph(SystemModules modules,
       
    47                                 ModuleFinder finder,
       
    48                                 Configuration configuration) {
    44         this.systemModules = modules;
    49         this.systemModules = modules;
    45         this.finder = finder;
    50         this.finder = finder;
       
    51         this.configuration = configuration;
    46     }
    52     }
    47 
    53 
    48     SystemModules systemModules() {
    54     SystemModules systemModules() {
    49         return systemModules;
    55         return systemModules;
    50     }
    56     }
    51 
    57 
    52     ModuleFinder finder() {
    58     ModuleFinder finder() {
    53         return finder;
    59         return finder;
    54     }
    60     }
    55 
    61 
       
    62     Configuration configuration() {
       
    63         return configuration;
       
    64     }
       
    65 
    56     // A factory method that ModuleBootstrap can use to obtain the
    66     // A factory method that ModuleBootstrap can use to obtain the
    57     // ArchivedModuleGraph.
    67     // ArchivedModuleGraph.
    58     static ArchivedModuleGraph get(String mainModule) {
    68     static ArchivedModuleGraph get(String mainModule) {
    59         if (Objects.equals(mainModule, archivedMainModule)
    69         if (Objects.equals(mainModule, archivedMainModule)
    60                 && archivedSystemModules != null
    70                 && archivedSystemModules != null
    61                 && archivedModuleFinder != null) {
    71                 && archivedModuleFinder != null
       
    72                 && archivedConfiguration != null) {
    62             return new ArchivedModuleGraph(archivedSystemModules,
    73             return new ArchivedModuleGraph(archivedSystemModules,
    63                                            archivedModuleFinder);
    74                                            archivedModuleFinder,
       
    75                                            archivedConfiguration);
    64         } else {
    76         } else {
    65             return null;
    77             return null;
    66         }
    78         }
    67     }
    79     }
    68 
    80 
    69     // Used at CDS dump time
    81     // Used at CDS dump time
    70     static void archive(String mainModule, SystemModules systemModules,
    82     static void archive(String mainModule,
    71                         ModuleFinder finder) {
    83                         SystemModules systemModules,
       
    84                         ModuleFinder finder,
       
    85                         Configuration configuration) {
    72         if (archivedMainModule != null)
    86         if (archivedMainModule != null)
    73             throw new UnsupportedOperationException();
    87             throw new UnsupportedOperationException();
    74         archivedMainModule = mainModule;
    88         archivedMainModule = mainModule;
    75         archivedSystemModules = systemModules;
    89         archivedSystemModules = systemModules;
    76         archivedModuleFinder = finder;
    90         archivedModuleFinder = finder;
       
    91         archivedConfiguration = configuration;
    77     }
    92     }
    78 
    93 
    79     static {
    94     static {
    80         VM.initializeFromArchive(ArchivedModuleGraph.class);
    95         VM.initializeFromArchive(ArchivedModuleGraph.class);
    81     }
    96     }