RFR: 8344078: Remove security manager dependency in java.nio [v2]

Roger Riggs rriggs at openjdk.org
Fri Nov 15 17:33:53 UTC 2024


On Fri, 15 Nov 2024 16:38:09 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Expunge the use of the `SecurityManager`, `AccessController`, and the like from the `java.nio` and `sun.nio` package hierarchies.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8344078: Update overlooked CopyMoveHelper and CompletedFuture

src/java.base/share/classes/java/nio/charset/Charset.java line 368:

> 366:                             next = i.next();
> 367:                         } catch (ServiceConfigurationError sce) {
> 368:                             if (sce.getCause() instanceof SecurityException) {

No need for catch (since rethrown)

src/java.base/share/classes/java/nio/file/Files.java line 1528:

> 1526:                 list.add(detector);
> 1527:             }
> 1528:             return list;

Possible refactor to use stream API:  (may be a bit too aggressive)
Suggestion:

             return ServiceLoader
                    .load(FileTypeDetector.class, ClassLoader.getSystemClassLoader())
                    .stream()
                    .map(p -> (FileTypeDetector)p).toList();

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22132#discussion_r1844166492
PR Review Comment: https://git.openjdk.org/jdk/pull/22132#discussion_r1844185396


More information about the nio-dev mailing list