Skip to content

Commit 6bb847e

Browse files
authored
Use immutable maps in ModuleDiscoverer
Signed-off-by: ascopes <73482956+ascopes@users.noreply.github.com>
1 parent 837229c commit 6bb847e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/ModuleDiscoverer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package io.github.ascopes.jct.utils;
1717

18-
import static java.util.stream.Collectors.toMap;
18+
import static java.util.stream.Collectors.toUnmodifiableMap;
1919

2020
import java.lang.module.FindException;
2121
import java.lang.module.ModuleFinder;
@@ -51,7 +51,7 @@ private ModuleDiscoverer() {
5151
* or are an {@code Automatic-Module} in an accessible {@code MANIFEST.MF}.
5252
*
5353
* @param path the path to look within.
54-
* @return a map of module names to the path of the module's package root.
54+
* @return an immutable map of module names to the path of the module's package root.
5555
*/
5656
public static Map<String, Path> findModulesIn(Path path) {
5757
try {
@@ -60,7 +60,7 @@ public static Map<String, Path> findModulesIn(Path path) {
6060
.of(path)
6161
.findAll()
6262
.stream()
63-
.collect(toMap(nameExtractor(), pathExtractor()));
63+
.collect(toUnmodifiableMap(nameExtractor(), pathExtractor()));
6464
} catch (FindException ex) {
6565
LOGGER.debug("Failed to find modules in {}, will ignore this error", path, ex);
6666
return Map.of();

0 commit comments

Comments
 (0)