4242import java .util .concurrent .ThreadFactory ;
4343import java .util .concurrent .ThreadPoolExecutor ;
4444import java .util .concurrent .TimeUnit ;
45- import java .util .stream .Stream ;
4645
4746import sun .awt .OSInfo ;
4847import sun .awt .util .ThreadGroupUtils ;
@@ -167,9 +166,6 @@ static Win32ShellFolder2 getDesktop() {
167166 if (desktop == null ) {
168167 try {
169168 desktop = new Win32ShellFolder2 (DESKTOP );
170- } catch (final SecurityException ignored ) {
171- // Ignore, the message may have sensitive information, not
172- // accessible other ways
173169 } catch (IOException | InterruptedException e ) {
174170 if (log .isLoggable (PlatformLogger .Level .WARNING )) {
175171 log .warning ("Cannot access 'Desktop'" , e );
@@ -183,9 +179,6 @@ static Win32ShellFolder2 getDrives() {
183179 if (drives == null ) {
184180 try {
185181 drives = new Win32ShellFolder2 (DRIVES );
186- } catch (final SecurityException ignored ) {
187- // Ignore, the message may have sensitive information, not
188- // accessible other ways
189182 } catch (IOException | InterruptedException e ) {
190183 if (log .isLoggable (PlatformLogger .Level .WARNING )) {
191184 log .warning ("Cannot access 'Drives'" , e );
@@ -202,9 +195,6 @@ static Win32ShellFolder2 getRecent() {
202195 if (path != null ) {
203196 recent = createShellFolder (getDesktop (), new File (path ));
204197 }
205- } catch (final SecurityException ignored ) {
206- // Ignore, the message may have sensitive information, not
207- // accessible other ways
208198 } catch (InterruptedException | IOException e ) {
209199 if (log .isLoggable (PlatformLogger .Level .WARNING )) {
210200 log .warning ("Cannot access 'Recent'" , e );
@@ -218,9 +208,6 @@ static Win32ShellFolder2 getNetwork() {
218208 if (network == null ) {
219209 try {
220210 network = new Win32ShellFolder2 (NETWORK );
221- } catch (final SecurityException ignored ) {
222- // Ignore, the message may have sensitive information, not
223- // accessible other ways
224211 } catch (IOException | InterruptedException e ) {
225212 if (log .isLoggable (PlatformLogger .Level .WARNING )) {
226213 log .warning ("Cannot access 'Network'" , e );
@@ -244,9 +231,6 @@ static Win32ShellFolder2 getPersonal() {
244231 personal .setIsPersonal ();
245232 }
246233 }
247- } catch (final SecurityException ignored ) {
248- // Ignore, the message may have sensitive information, not
249- // accessible other ways
250234 } catch (InterruptedException | IOException e ) {
251235 if (log .isLoggable (PlatformLogger .Level .WARNING )) {
252236 log .warning ("Cannot access 'Personal'" , e );
@@ -287,7 +271,7 @@ public Object get(String key) {
287271 if (file == null ) {
288272 file = getDesktop ();
289273 }
290- return checkFile ( file ) ;
274+ return file ;
291275 } else if (key .equals ("roots" )) {
292276 // Should be "History" and "Desktop" ?
293277 if (roots == null ) {
@@ -298,11 +282,11 @@ public Object get(String key) {
298282 roots = (File [])super .get (key );
299283 }
300284 }
301- return checkFiles ( roots ) ;
285+ return roots ;
302286 } else if (key .equals ("fileChooserComboBoxFolders" )) {
303287 Win32ShellFolder2 desktop = getDesktop ();
304288
305- if (desktop != null && checkFile ( desktop ) != null ) {
289+ if (desktop != null ) {
306290 ArrayList <File > folders = new ArrayList <File >();
307291 Win32ShellFolder2 drives = getDrives ();
308292
@@ -313,15 +297,15 @@ public Object get(String key) {
313297
314298 folders .add (desktop );
315299 // Add all second level folders
316- File [] secondLevelFolders = checkFiles ( desktop .listFiles () );
300+ File [] secondLevelFolders = desktop .listFiles ();
317301 Arrays .sort (secondLevelFolders );
318302 for (File secondLevelFolder : secondLevelFolders ) {
319303 Win32ShellFolder2 folder = (Win32ShellFolder2 ) secondLevelFolder ;
320304 if (!folder .isFileSystem () || (folder .isDirectory () && !folder .isLink ())) {
321305 folders .add (folder );
322306 // Add third level for "My Computer"
323307 if (folder .equals (drives )) {
324- File [] thirdLevelFolders = checkFiles ( folder .listFiles () );
308+ File [] thirdLevelFolders = folder .listFiles ();
325309 if (thirdLevelFolders != null && thirdLevelFolders .length > 0 ) {
326310 List <File > thirdLevelFoldersList = Arrays .asList (thirdLevelFolders );
327311
@@ -331,7 +315,7 @@ public Object get(String key) {
331315 }
332316 }
333317 }
334- return checkFiles ( folders );
318+ return folders . toArray ( new File [ folders . size ()] );
335319 } else {
336320 return super .get (key );
337321 }
@@ -374,7 +358,7 @@ public Object get(String key) {
374358 }
375359 }
376360 }
377- return checkFiles ( folders );
361+ return folders . toArray ( new File [ folders . size ()] );
378362 } else if (key .startsWith ("fileChooserIcon " )) {
379363 String name = key .substring (key .indexOf (" " ) + 1 );
380364
@@ -421,53 +405,6 @@ public Object get(String key) {
421405 return null ;
422406 }
423407
424- private static File checkFile (File file ) {
425- @ SuppressWarnings ("removal" )
426- SecurityManager sm = System .getSecurityManager ();
427- return (sm == null || file == null ) ? file : checkFile (file , sm );
428- }
429-
430- private static File checkFile (File file , @ SuppressWarnings ("removal" ) SecurityManager sm ) {
431- try {
432- sm .checkRead (file .getPath ());
433-
434- if (file instanceof Win32ShellFolder2 ) {
435- Win32ShellFolder2 f = (Win32ShellFolder2 )file ;
436- if (f .isLink ()) {
437- Win32ShellFolder2 link = (Win32ShellFolder2 )f .getLinkLocation ();
438- if (link != null )
439- sm .checkRead (link .getPath ());
440- }
441- }
442- return file ;
443- } catch (SecurityException se ) {
444- return null ;
445- }
446- }
447-
448- static File [] checkFiles (File [] files ) {
449- @ SuppressWarnings ("removal" )
450- SecurityManager sm = System .getSecurityManager ();
451- if (sm == null || files == null || files .length == 0 ) {
452- return files ;
453- }
454- return checkFiles (Arrays .stream (files ), sm );
455- }
456-
457- private static File [] checkFiles (List <File > files ) {
458- @ SuppressWarnings ("removal" )
459- SecurityManager sm = System .getSecurityManager ();
460- if (sm == null || files .isEmpty ()) {
461- return files .toArray (new File [files .size ()]);
462- }
463- return checkFiles (files .stream (), sm );
464- }
465-
466- private static File [] checkFiles (Stream <File > filesStream , @ SuppressWarnings ("removal" ) SecurityManager sm ) {
467- return filesStream .filter ((file ) -> checkFile (file , sm ) != null )
468- .toArray (File []::new );
469- }
470-
471408 /**
472409 * Does {@code dir} represent a "computer" such as a node on the network, or
473410 * "My Computer" on the desktop.
0 commit comments