Skip to content

Commit 3d2c3cd

Browse files
Daniel Gredlermrserb
authored andcommitted
8352970: Remove unnecessary Windows version check in Win32ShellFolderManager2
Reviewed-by: prr, serb
1 parent c70ad6a commit 3d2c3cd

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,6 @@
4343
import java.util.concurrent.ThreadPoolExecutor;
4444
import java.util.concurrent.TimeUnit;
4545

46-
import sun.awt.OSInfo;
4746
import sun.awt.util.ThreadGroupUtils;
4847
import sun.util.logging.PlatformLogger;
4948

@@ -291,7 +290,7 @@ public Object get(String key) {
291290
Win32ShellFolder2 drives = getDrives();
292291

293292
Win32ShellFolder2 recentFolder = getRecent();
294-
if (recentFolder != null && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_2000) >= 0) {
293+
if (recentFolder != null) {
295294
folders.add(recentFolder);
296295
}
297296

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/* @test
25+
@bug 8352970
26+
@requires (os.family == "windows")
27+
@summary Basic sanity test for FileSystemView.getChooserComboBoxFiles().
28+
*/
29+
30+
import java.io.File;
31+
import java.util.Arrays;
32+
import javax.swing.filechooser.FileSystemView;
33+
34+
public class FileSystemViewFilesTest {
35+
36+
public static void main(String[] args) throws Exception {
37+
38+
FileSystemView fsv = FileSystemView.getFileSystemView();
39+
File[] roots = fsv.getRoots();
40+
File desktop = Arrays.asList(roots).stream()
41+
.filter(f -> f.getName().equals("Desktop"))
42+
.findFirst()
43+
.orElse(null);
44+
if (desktop == null) {
45+
System.out.println("No desktop available in " + roots.length + " roots");
46+
return;
47+
}
48+
49+
File[] chooserFiles = fsv.getChooserComboBoxFiles();
50+
boolean found = Arrays.asList(chooserFiles).stream()
51+
.anyMatch(f -> f.equals(desktop));
52+
if (!found) {
53+
throw new RuntimeException("Desktop not included in chooser combo box files.");
54+
}
55+
}
56+
57+
}

0 commit comments

Comments
 (0)