jdk/src/java.base/share/classes/java/lang/module/Configuration.java
changeset 44545 83b611b88ac8
parent 44359 c6761862ca0b
child 45004 ea3137042a61
equal deleted inserted replaced
44480:2c33418a6d57 44545:83b611b88ac8
    62  * method to do resolution with service binding. There are instance and
    62  * method to do resolution with service binding. There are instance and
    63  * static variants of both methods. The instance methods create a configuration
    63  * static variants of both methods. The instance methods create a configuration
    64  * with the receiver as the parent configuration. The static methods are for
    64  * with the receiver as the parent configuration. The static methods are for
    65  * more advanced cases where there can be more than one parent configuration. </p>
    65  * more advanced cases where there can be more than one parent configuration. </p>
    66  *
    66  *
    67  * <p> Each {@link java.lang.reflect.Layer layer} of modules in the Java virtual
    67  * <p> Each {@link java.lang.ModuleLayer layer} of modules in the Java virtual
    68  * machine is created from a configuration. The configuration for the {@link
    68  * machine is created from a configuration. The configuration for the {@link
    69  * java.lang.reflect.Layer#boot() boot} layer is obtained by invoking {@code
    69  * java.lang.ModuleLayer#boot() boot} layer is obtained by invoking {@code
    70  * Layer.boot().configuration()}. The configuration for the boot layer will
    70  * ModuleLayer.boot().configuration()}. The configuration for the boot layer
    71  * often be the parent when creating new configurations. </p>
    71  * will often be the parent when creating new configurations. </p>
    72  *
    72  *
    73  * <h3> Example </h3>
    73  * <h3> Example </h3>
    74  *
    74  *
    75  * <p> The following example uses the {@link
    75  * <p> The following example uses the {@link
    76  * #resolve(ModuleFinder,ModuleFinder,Collection) resolve} method to resolve a
    76  * #resolve(ModuleFinder,ModuleFinder,Collection) resolve} method to resolve a
    79  * names of the modules that each module reads. </p>
    79  * names of the modules that each module reads. </p>
    80  *
    80  *
    81  * <pre>{@code
    81  * <pre>{@code
    82  *    ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
    82  *    ModuleFinder finder = ModuleFinder.of(dir1, dir2, dir3);
    83  *
    83  *
    84  *    Configuration parent = Layer.boot().configuration();
    84  *    Configuration parent = ModuleLayer.boot().configuration();
    85  *
    85  *
    86  *    Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("myapp"));
    86  *    Configuration cf = parent.resolve(finder, ModuleFinder.of(), Set.of("myapp"));
    87  *    cf.modules().forEach(m -> {
    87  *    cf.modules().forEach(m -> {
    88  *        System.out.format("%s -> %s%n",
    88  *        System.out.format("%s -> %s%n",
    89  *            m.name(),
    89  *            m.name(),
    93  *    });
    93  *    });
    94  * }</pre>
    94  * }</pre>
    95  *
    95  *
    96  * @since 9
    96  * @since 9
    97  * @spec JPMS
    97  * @spec JPMS
    98  * @see java.lang.reflect.Layer
    98  * @see java.lang.ModuleLayer
    99  */
    99  */
   100 public final class Configuration {
   100 public final class Configuration {
   101 
   101 
   102     // @see Configuration#empty()
   102     // @see Configuration#empty()
   103     private static final Configuration EMPTY_CONFIGURATION = new Configuration();
   103     private static final Configuration EMPTY_CONFIGURATION = new Configuration();