@@ -0,0 +1,2310 @@
+package test.base;%0A%0Aimport static org.junit.jupiter.api.Assertions.assertLinesMatch;%0A%0Aimport java.lang.module.ModuleFinder;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.util.List;%0Aimport java.util.ServiceLoader;%0Aimport java.util.Set;%0Aimport java.util.spi.ToolProvider;%0Aimport org.junit.jupiter.api.Test;%0Aimport org.junit.jupiter.api.io.TempDir;%0A%0Aclass ModuleLayerTests %7B%0A%0A  @Test%0A  void findsOnlyFooToolProvider(@TempDir Path temp) throws Exception %7B%0A    Files.createDirectories(temp.resolve(%22src/foo/foo%22));%0A    Files.writeString(%0A        temp.resolve(%22src/foo/module-info.java%22),%0A        %22%22%22%0A        module foo %7B%0A          provides java.util.spi.ToolProvider with foo.FooToolProvider;%0A        %7D%0A        %22%22%22);%0A    Files.writeString(%0A        temp.resolve(%22src/foo/foo/FooToolProvider.java%22),%0A        %22%22%22%0A        package foo;%0A        public record FooToolProvider() implements java.util.spi.ToolProvider %7B%0A          public String name() %7B return %22foo%22; %7D%0A          public int run(java.io.PrintWriter out, java.io.PrintWriter err, String... args) %7B return 0; %7D%0A        %7D%0A        %22%22%22);%0A    ToolProviders.run(%0A        %22javac%22,%0A        %22--module-source-path%22,%0A        temp.resolve(%22src%22),%0A        %22--module%22,%0A        %22foo%22,%0A        %22-d%22,%0A        temp.resolve(%22classes%22));%0A    ToolProviders.run(%0A        %22jar%22,%0A        %22--create%22,%0A        %22--file%22,%0A        temp.resolve(%22foo.jar%22),%0A        %22-C%22,%0A        temp.resolve(%22classes/foo%22),%0A        %22.%22);%0A%0A    try %7B%0A      assertLinesMatch(List.of(%22foo%22), listNamesOfToolProviders(temp));%0A    %7D finally %7B%0A      System.gc(); // Windows...%0A    %7D%0A  %7D%0A%0A  private List%3CString%3E listNamesOfToolProviders(Path temp) %7B%0A    var before = ModuleFinder.of(temp);%0A    var after = ModuleFinder.of();%0A    var parentLayer = ModuleLayer.boot();%0A    var configuration = parentLayer.configuration().resolveAndBind(before, after, Set.of());%0A    var parentLoader = ClassLoader.getSystemClassLoader();%0A    var layer = parentLayer.defineModulesWithOneLoader(configuration, parentLoader);%0A    return%0A        ServiceLoader.load(layer, ToolProvider.class).stream()%0A            .filter(provider -%3E provider.type().getModule().getLayer() == layer)%0A            .map(ServiceLoader.Provider::get)%0A            .map(ToolProvider::name)%0A            .sorted()%0A            .toList();%0A  %7D%0A%7D%0A

Add tests for `ModuleLayer`