jdk/src/java.base/share/classes/java/lang/module/Configuration.java
changeset 44359 c6761862ca0b
parent 43712 5dfd0950317c
child 44545 83b611b88ac8
equal deleted inserted replaced
44210:5a8499c4b32c 44359:c6761862ca0b
   110     private final Map<String, ResolvedModule> nameToModule;
   110     private final Map<String, ResolvedModule> nameToModule;
   111 
   111 
   112     // module constraints on target
   112     // module constraints on target
   113     private final String osName;
   113     private final String osName;
   114     private final String osArch;
   114     private final String osArch;
   115     private final String osVersion;
       
   116 
   115 
   117     String osName() { return osName; }
   116     String osName() { return osName; }
   118     String osArch() { return osArch; }
   117     String osArch() { return osArch; }
   119     String osVersion() { return osVersion; }
       
   120 
   118 
   121     private Configuration() {
   119     private Configuration() {
   122         this.parents = Collections.emptyList();
   120         this.parents = Collections.emptyList();
   123         this.graph = Collections.emptyMap();
   121         this.graph = Collections.emptyMap();
   124         this.modules = Collections.emptySet();
   122         this.modules = Collections.emptySet();
   125         this.nameToModule = Collections.emptyMap();
   123         this.nameToModule = Collections.emptyMap();
   126         this.osName = null;
   124         this.osName = null;
   127         this.osArch = null;
   125         this.osArch = null;
   128         this.osVersion = null;
       
   129     }
   126     }
   130 
   127 
   131     private Configuration(List<Configuration> parents,
   128     private Configuration(List<Configuration> parents,
   132                           Resolver resolver,
   129                           Resolver resolver,
   133                           boolean check)
   130                           boolean check)
   150         this.modules = Set.of(moduleArray);
   147         this.modules = Set.of(moduleArray);
   151         this.nameToModule = Map.ofEntries(nameEntries);
   148         this.nameToModule = Map.ofEntries(nameEntries);
   152 
   149 
   153         this.osName = resolver.osName();
   150         this.osName = resolver.osName();
   154         this.osArch = resolver.osArch();
   151         this.osArch = resolver.osArch();
   155         this.osVersion = resolver.osVersion();
       
   156     }
   152     }
   157 
   153 
   158     /**
   154     /**
   159      * Resolves a collection of root modules, with this configuration as its
   155      * Resolves a collection of root modules, with this configuration as its
   160      * parent, to create a new configuration. This method works exactly as
   156      * parent, to create a new configuration. This method works exactly as
   279      *
   275      *
   280      * <p> Resolution may fail with {@code FindException} for the following
   276      * <p> Resolution may fail with {@code FindException} for the following
   281      * <em>observability-related</em> reasons: </p>
   277      * <em>observability-related</em> reasons: </p>
   282      *
   278      *
   283      * <ul>
   279      * <ul>
       
   280      *
   284      *     <li><p> A root module, or a direct or transitive dependency, is not
   281      *     <li><p> A root module, or a direct or transitive dependency, is not
   285      *     found. </p></li>
   282      *     found. </p></li>
   286      *
   283      *
   287      *     <li><p> An error occurs when attempting to find a module.
   284      *     <li><p> An error occurs when attempting to find a module.
   288      *     Possible errors include I/O errors, errors detected parsing a module
   285      *     Possible errors include I/O errors, errors detected parsing a module
   289      *     descriptor ({@code module-info.class}) or two versions of the same
   286      *     descriptor ({@code module-info.class}) or two versions of the same
   290      *     module are found in the same directory. </p></li>
   287      *     module are found in the same directory. </p></li>
   291      *
   288      *
   292      *     <li><p> A module with the required name is found but the module
       
   293      *     requires a different {@link ModuleDescriptor#osName() operating
       
   294      *     system}, {@link ModuleDescriptor#osArch() architecture}, or {@link
       
   295      *     ModuleDescriptor#osVersion() version} to other modules that have
       
   296      *     been resolved for the new configuration or modules in the parent
       
   297      *     configurations. </p></li>
       
   298      *
       
   299      * </ul>
   289      * </ul>
   300      *
   290      *
   301      * <p> Post-resolution consistency checks may fail with {@code
   291      * <p> Post-resolution consistency checks may fail with {@code
   302      * ResolutionException} for the following reasons: </p>
   292      * ResolutionException} for the following reasons: </p>
   303      *
   293      *
   304      * <ul>
   294      * <ul>
   305      *
   295      *
   306      *     <li><p> A cycle is detected, say where module {@code m1} requires
   296      *     <li><p> A cycle is detected, say where module {@code m1} requires
   307      *     module {@code m2} and {@code m2} requires {@code m1}. </p></li>
   297      *     module {@code m2} and {@code m2} requires {@code m1}. </p></li>
       
   298      *
       
   299      *     <li><p> A module reads two or more modules with the same name. This
       
   300      *     includes the case where a module reads another with the same name as
       
   301      *     itself. </p></li>
   308      *
   302      *
   309      *     <li><p> Two or more modules in the configuration export the same
   303      *     <li><p> Two or more modules in the configuration export the same
   310      *     package to a module that reads both. This includes the case where a
   304      *     package to a module that reads both. This includes the case where a
   311      *     module {@code M} containing package {@code p} reads another module
   305      *     module {@code M} containing package {@code p} reads another module
   312      *     that exports {@code p} to {@code M}. </p></li>
   306      *     that exports {@code p} to {@code M}. </p></li>
   317      *     {@code M} reads. </p></li>
   311      *     {@code M} reads. </p></li>
   318      *
   312      *
   319      * </ul>
   313      * </ul>
   320      *
   314      *
   321      * @implNote In the implementation then observability of modules may depend
   315      * @implNote In the implementation then observability of modules may depend
   322      * on referential integrity checks that ensure different builds of tightly
   316      * on referential integrity or other checks that ensure different builds of
   323      * coupled modules are not combined in the same configuration.
   317      * tightly coupled modules or modules for specific operating systems or
       
   318      * architectures are not combined in the same configuration.
   324      *
   319      *
   325      * @param  before
   320      * @param  before
   326      *         The <em>before</em> module finder to find modules
   321      *         The <em>before</em> module finder to find modules
   327      * @param  parents
   322      * @param  parents
   328      *         The list parent configurations in search order
   323      *         The list parent configurations in search order