Skip to content

Commit 6d6d23d

Browse files
laeubiakurtakov
authored andcommitted
Add support to detect prefixed JAVA_HOME_ env variables for installation
The setup-java github actions defines by default java installations in env variable starting with JAVA_HOME_ but this is currently not detected. This now additionally also supports this form of JVM installs and fixes an issue with relying on toSet returning a modifiable set (what is not guaranteed).
1 parent 82d17de commit 6d6d23d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/DetectVMInstallationsJob.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private Collection<File> computeCandidateVMs(StandardVMType standardType) {
156156
.map(dir -> dir.listFiles(File::isDirectory))
157157
.flatMap(Arrays::stream)
158158
.filter(Objects::nonNull)
159-
.collect(Collectors.toSet());
159+
.collect(Collectors.toCollection(HashSet::new));
160160

161161
// particular VM installations
162162
String javaHome = System.getenv("JAVA_HOME"); //$NON-NLS-1$
@@ -167,6 +167,11 @@ private Collection<File> computeCandidateVMs(StandardVMType standardType) {
167167
if (jdkHome != null) {
168168
directories.add(new File(jdkHome));
169169
}
170+
System.getenv().entrySet().forEach(entry -> {
171+
if (entry.getKey().startsWith("JAVA_HOME_")) { //$NON-NLS-1$
172+
directories.add(new File(entry.getValue()));
173+
}
174+
});
170175
// other common/standard lookup strategies can be added here
171176
return directories.stream()
172177
.filter(Objects::nonNull)

0 commit comments

Comments
 (0)