Skip to content

Commit

Permalink
Installed JREs / Search... : also accept the jdk directory
Browse files Browse the repository at this point in the history
And not only subdirectories as it not intuitive that a jdk can not be
found when its exact location is specified by the user.
  • Loading branch information
jukzi committed Jan 9, 2025
1 parent 78045e3 commit 700a32e
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1041,21 +1041,24 @@ protected void search(File directory, List<File> found, List<IVMInstallType> typ
return;
}

String[] names = directory.list();
if (names == null) {
return;
String[] fileNames = directory.list();
if (fileNames == null) {
return; // not a directory
}
List<String> names = new ArrayList<>();
names.add(null); // self
names.addAll(List.of(fileNames));
List<File> subDirs = new ArrayList<>();
for (int i = 0; i < names.length; i++) {
for (String name : names) {
if (monitor.isCanceled()) {
return;
}
File file = new File(directory, names[i]);
File file = name == null ? directory : new File(directory, name);
monitor.subTask(NLS.bind(JREMessages.InstalledJREsBlock_14, new String[] { Integer.toString(found.size()),
file.toPath().normalize().toAbsolutePath().toString().replaceAll("&", "&&") })); // @see bug 29855 //$NON-NLS-1$ //$NON-NLS-2$
IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
if (file.isDirectory()) {
if (!ignore.contains(file)) {
if (ignore.add(file)) {
boolean validLocation = false;

// Take the first VM install type that claims the location as a
Expand Down

0 comments on commit 700a32e

Please sign in to comment.