|
21 | 21 | import java.io.ByteArrayInputStream;
|
22 | 22 | import java.io.IOException;
|
23 | 23 | import java.nio.charset.StandardCharsets;
|
| 24 | +import java.nio.file.FileVisitOption; |
24 | 25 | import java.nio.file.Files;
|
25 | 26 | import java.nio.file.Path;
|
26 | 27 | import java.nio.file.Paths;
|
27 | 28 | import java.util.List;
|
28 | 29 | import java.util.Objects;
|
29 | 30 | import java.util.UUID;
|
30 | 31 | import java.util.jar.JarFile;
|
| 32 | +import java.util.stream.Stream; |
31 | 33 |
|
32 | 34 | import org.apache.commons.io.FileUtils;
|
33 | 35 |
|
@@ -70,7 +72,7 @@ public static AnalysisScope createScope(String projectPath, String applicationDe
|
70 | 72 | throw new RuntimeException("JAVA_HOME is not set.");
|
71 | 73 | }
|
72 | 74 |
|
73 |
| - String[] stdlibs = Files.walk(Paths.get(System.getenv("JAVA_HOME"), "jmods")) |
| 75 | + String[] stdlibs = Files.walk(getJmodsPath()) |
74 | 76 | .filter(path -> path.toString().endsWith(".jmod"))
|
75 | 77 | .map(path -> path.toAbsolutePath().toString())
|
76 | 78 | .toArray(String[]::new);
|
@@ -130,6 +132,19 @@ public static AnalysisScope createScope(String projectPath, String applicationDe
|
130 | 132 | return scope;
|
131 | 133 | }
|
132 | 134 |
|
| 135 | + private static Path getJmodsPath() { |
| 136 | + try { |
| 137 | + try (Stream<Path> paths = Files.walk(Path.of(System.getenv("JAVA_HOME")), Integer.MAX_VALUE, FileVisitOption.FOLLOW_LINKS)) { |
| 138 | + return paths |
| 139 | + .filter(path -> path.getFileName().toString().equals("jmods")) |
| 140 | + .findFirst() |
| 141 | + .orElseThrow(() -> new RuntimeException("jmods directory not found in " + System.getenv("JAVA_HOME"))); |
| 142 | + } |
| 143 | + } catch (IOException e) { |
| 144 | + throw new RuntimeException("Error searching for jmods directory", e); |
| 145 | + } |
| 146 | + } |
| 147 | + |
133 | 148 | private static AnalysisScope addDefaultExclusions(AnalysisScope scope)
|
134 | 149 | throws IOException {
|
135 | 150 | Log.info("Add exclusions to scope.");
|
|
0 commit comments