4444import java .nio .file .*;
4545import java .nio .file .attribute .*;
4646import java .nio .file .spi .FileSystemProvider ;
47- import java .security .AccessController ;
48- import java .security .PrivilegedAction ;
49- import java .security .PrivilegedActionException ;
50- import java .security .PrivilegedExceptionAction ;
5147import java .util .*;
5248import java .util .concurrent .locks .ReadWriteLock ;
5349import java .util .concurrent .locks .ReentrantReadWriteLock ;
8278 */
8379class ZipFileSystem extends FileSystem {
8480 // statics
85- @ SuppressWarnings ("removal" )
86- private static final boolean isWindows = AccessController .doPrivileged (
87- (PrivilegedAction <Boolean >)()->System .getProperty ("os.name" )
88- .startsWith ("Windows" ));
81+ private static final boolean isWindows = System .getProperty ("os.name" )
82+ .startsWith ("Windows" );
8983 private static final byte [] ROOTPATH = new byte [] { '/' };
9084 private static final String PROPERTY_POSIX = "enablePosixFileAttributes" ;
9185 private static final String PROPERTY_DEFAULT_OWNER = "defaultOwner" ;
@@ -168,9 +162,7 @@ class ZipFileSystem extends FileSystem {
168162 }
169163 // sm and existence check
170164 zfpath .getFileSystem ().provider ().checkAccess (zfpath , AccessMode .READ );
171- @ SuppressWarnings ("removal" )
172- boolean writeable = AccessController .doPrivileged (
173- (PrivilegedAction <Boolean >)()->Files .isWritable (zfpath ));
165+ boolean writeable = Files .isWritable (zfpath );
174166 this .readOnly = !writeable ;
175167 this .zc = ZipCoder .get (nameEncoding );
176168 this .rootdir = new ZipPath (this , new byte []{'/' });
@@ -244,23 +236,14 @@ private static boolean isTrue(Map<String, ?> env, String name) {
244236 // If not specified in env, it is the owner of the archive. If no owner can
245237 // be determined, we try to go with system property "user.name". If that's not
246238 // accessible, we return "<zipfs_default>".
247- @ SuppressWarnings ("removal" )
248239 private UserPrincipal initOwner (Path zfpath , Map <String , ?> env ) throws IOException {
249240 Object o = env .get (PROPERTY_DEFAULT_OWNER );
250241 if (o == null ) {
251242 try {
252- PrivilegedExceptionAction <UserPrincipal > pa = ()->Files .getOwner (zfpath );
253- return AccessController .doPrivileged (pa );
254- } catch (UnsupportedOperationException | PrivilegedActionException e ) {
255- if (e instanceof UnsupportedOperationException ||
256- e .getCause () instanceof NoSuchFileException )
257- {
258- PrivilegedAction <String > pa = ()->System .getProperty ("user.name" );
259- String userName = AccessController .doPrivileged (pa );
260- return ()->userName ;
261- } else {
262- throw new IOException (e );
263- }
243+ return Files .getOwner (zfpath );
244+ } catch (UnsupportedOperationException | NoSuchFileException e ) {
245+ String userName = System .getProperty ("user.name" );
246+ return ()->userName ;
264247 }
265248 }
266249 if (o instanceof String ) {
@@ -282,7 +265,6 @@ private UserPrincipal initOwner(Path zfpath, Map<String, ?> env) throws IOExcept
282265 // If not specified in env, we try to determine the group of the zip archive itself.
283266 // If this is not possible/unsupported, we will return a group principal going by
284267 // the same name as the default owner.
285- @ SuppressWarnings ("removal" )
286268 private GroupPrincipal initGroup (Path zfpath , Map <String , ?> env ) throws IOException {
287269 Object o = env .get (PROPERTY_DEFAULT_GROUP );
288270 if (o == null ) {
@@ -291,16 +273,9 @@ private GroupPrincipal initGroup(Path zfpath, Map<String, ?> env) throws IOExcep
291273 if (zfpv == null ) {
292274 return defaultOwner ::getName ;
293275 }
294- PrivilegedExceptionAction <GroupPrincipal > pa = ()->zfpv .readAttributes ().group ();
295- return AccessController .doPrivileged (pa );
296- } catch (UnsupportedOperationException | PrivilegedActionException e ) {
297- if (e instanceof UnsupportedOperationException ||
298- e .getCause () instanceof NoSuchFileException )
299- {
300- return defaultOwner ::getName ;
301- } else {
302- throw new IOException (e );
303- }
276+ return zfpv .readAttributes ().group ();
277+ } catch (UnsupportedOperationException | NoSuchFileException e ) {
278+ return defaultOwner ::getName ;
304279 }
305280 }
306281 if (o instanceof String ) {
@@ -462,7 +437,6 @@ public PathMatcher getPathMatcher(String syntaxAndInput) {
462437 return (path )->pattern .matcher (path .toString ()).matches ();
463438 }
464439
465- @ SuppressWarnings ("removal" )
466440 @ Override
467441 public void close () throws IOException {
468442 beginWrite ();
@@ -480,13 +454,9 @@ public void close() throws IOException {
480454 }
481455 beginWrite (); // lock and sync
482456 try {
483- AccessController .doPrivileged ((PrivilegedExceptionAction <Void >)() -> {
484- sync (); return null ;
485- });
457+ sync ();
486458 ch .close (); // close the ch just in case no update
487459 // and sync didn't close the ch
488- } catch (PrivilegedActionException e ) {
489- throw (IOException )e .getException ();
490460 } finally {
491461 endWrite ();
492462 }
@@ -512,10 +482,8 @@ public void close() throws IOException {
512482 synchronized (tmppaths ) {
513483 for (Path p : tmppaths ) {
514484 try {
515- AccessController .doPrivileged (
516- (PrivilegedExceptionAction <Boolean >)() -> Files .deleteIfExists (p ));
517- } catch (PrivilegedActionException e ) {
518- IOException x = (IOException )e .getException ();
485+ Files .deleteIfExists (p );
486+ } catch (IOException x ) {
519487 if (ioe == null )
520488 ioe = x ;
521489 else
0 commit comments