Skip to content

Commit 5c70abc

Browse files
MultiReleaseLaunchTests has problems on Windows (eclipse-jdt#844)
Search parent of java.home of currently running JVM Fixes eclipse-jdt#843
1 parent cfef281 commit 5c70abc

1 file changed

Lines changed: 26 additions & 15 deletions

File tree

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/MultiReleaseLaunchTests.java

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,39 @@ protected void setUp() throws Exception {
6767
removeExistingJavaVersions(requiredJavaVersions, existingLocations);
6868
if (!requiredJavaVersions.isEmpty()) {
6969
final File rootDir = new File(System.getProperty(JVM_SEARCH_BASE, "/opt/tools/java/openjdk/"));
70-
final List<File> locations = new ArrayList<>();
71-
final List<IVMInstallType> types = new ArrayList<>();
72-
DetectVMInstallationsJob.search(rootDir, locations, types, existingLocations, new NullProgressMonitor());
73-
for (int i = 0; i < locations.size(); i++) {
74-
File location = locations.get(i);
75-
IVMInstallType type = types.get(i);
76-
String id = "MultiReleaseLaunchTests-" + UUID.randomUUID() + "-" + i;
77-
VMStandin workingCopy = new VMStandin(type, id);
78-
workingCopy.setInstallLocation(location);
79-
workingCopy.setName(id);
80-
IVMInstall install = workingCopy.convertToRealVM();
81-
if (removeIfMatch(requiredJavaVersions, install)) {
82-
disposeVms.add(() -> type.disposeVMInstall(id));
83-
} else {
84-
type.disposeVMInstall(id);
70+
matchInstallationsFrom(rootDir, requiredJavaVersions, existingLocations);
71+
if (!requiredJavaVersions.isEmpty()) {
72+
// another fallback: search the parent dir of java.home of the running JVM:
73+
File parentDir = new File(System.getProperty("java.home")).getParentFile();
74+
if (!parentDir.equals(rootDir)) {
75+
matchInstallationsFrom(parentDir, requiredJavaVersions, existingLocations);
8576
}
8677
}
8778
}
8879
assertTrue("The following java versions are required by this test but can not be found: "
8980
+ requiredJavaVersions, requiredJavaVersions.isEmpty());
9081
}
9182

83+
private void matchInstallationsFrom(final File rootDir, List<RequiredJavaVersion> requiredJavaVersions, final Set<File> existingLocations) {
84+
final List<File> locations = new ArrayList<>();
85+
final List<IVMInstallType> types = new ArrayList<>();
86+
DetectVMInstallationsJob.search(rootDir, locations, types, existingLocations, new NullProgressMonitor());
87+
for (int i = 0; i < locations.size(); i++) {
88+
File location = locations.get(i);
89+
IVMInstallType type = types.get(i);
90+
String id = "MultiReleaseLaunchTests-" + UUID.randomUUID() + "-" + i;
91+
VMStandin workingCopy = new VMStandin(type, id);
92+
workingCopy.setInstallLocation(location);
93+
workingCopy.setName(id);
94+
IVMInstall install = workingCopy.convertToRealVM();
95+
if (removeIfMatch(requiredJavaVersions, install)) {
96+
disposeVms.add(() -> type.disposeVMInstall(id));
97+
} else {
98+
type.disposeVMInstall(id);
99+
}
100+
}
101+
}
102+
92103
@Override
93104
protected void tearDown() throws Exception {
94105
super.tearDown();

0 commit comments

Comments
 (0)