Skip to content

Commit 05cc02b

Browse files
author
Brian Burkhalter
committed
8202110: (fs) Remove FileSystem support for resolving against a default directory (chdir configuration)
Reviewed-by: alanb
1 parent d2df36b commit 05cc02b

File tree

15 files changed

+44
-104
lines changed

15 files changed

+44
-104
lines changed

src/java.base/aix/classes/sun/nio/fs/AixFileSystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2013 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -38,8 +38,8 @@
3838

3939
class AixFileSystem extends UnixFileSystem {
4040

41-
AixFileSystem(UnixFileSystemProvider provider, String dir) {
42-
super(provider, dir);
41+
AixFileSystem(UnixFileSystemProvider provider) {
42+
super(provider);
4343
}
4444

4545
@Override

src/java.base/aix/classes/sun/nio/fs/AixFileSystemProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2013 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -38,8 +38,8 @@ public AixFileSystemProvider() {
3838
}
3939

4040
@Override
41-
AixFileSystem newFileSystem(String dir) {
42-
return new AixFileSystem(this, dir);
41+
AixFileSystem newFileSystem() {
42+
return new AixFileSystem(this);
4343
}
4444

4545
/**

src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, 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
@@ -41,8 +41,8 @@
4141
*/
4242

4343
class LinuxFileSystem extends UnixFileSystem {
44-
LinuxFileSystem(UnixFileSystemProvider provider, String dir) {
45-
super(provider, dir);
44+
LinuxFileSystem(UnixFileSystemProvider provider) {
45+
super(provider);
4646
}
4747

4848
@Override

src/java.base/linux/classes/sun/nio/fs/LinuxFileSystemProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, 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
@@ -42,8 +42,8 @@ public LinuxFileSystemProvider() {
4242
}
4343

4444
@Override
45-
LinuxFileSystem newFileSystem(String dir) {
46-
return new LinuxFileSystem(this, dir);
45+
LinuxFileSystem newFileSystem() {
46+
return new LinuxFileSystem(this);
4747
}
4848

4949
@Override

src/java.base/macosx/classes/sun/nio/fs/BsdFileSystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, 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
@@ -46,8 +46,8 @@
4646

4747
class BsdFileSystem extends UnixFileSystem {
4848

49-
BsdFileSystem(UnixFileSystemProvider provider, String dir) {
50-
super(provider, dir);
49+
BsdFileSystem(UnixFileSystemProvider provider) {
50+
super(provider);
5151
}
5252

5353
@Override

src/java.base/macosx/classes/sun/nio/fs/BsdFileSystemProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, 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
@@ -39,8 +39,8 @@ public BsdFileSystemProvider() {
3939
}
4040

4141
@Override
42-
BsdFileSystem newFileSystem(String dir) {
43-
return new BsdFileSystem(this, dir);
42+
BsdFileSystem newFileSystem() {
43+
return new BsdFileSystem(this);
4444
}
4545

4646
@Override

src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, 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
@@ -48,8 +48,8 @@ class MacOSXFileSystem extends BsdFileSystem {
4848
&& ("".equals(value) || Boolean.parseBoolean(value));
4949
}
5050

51-
MacOSXFileSystem(UnixFileSystemProvider provider, String dir) {
52-
super(provider, dir);
51+
MacOSXFileSystem(UnixFileSystemProvider provider) {
52+
super(provider);
5353
}
5454

5555
boolean isCaseInsensitiveAndPreserving() {

src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, 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
@@ -40,8 +40,8 @@ public MacOSXFileSystemProvider() {
4040
}
4141

4242
@Override
43-
MacOSXFileSystem newFileSystem(String dir) {
44-
return new MacOSXFileSystem(this, dir);
43+
MacOSXFileSystem newFileSystem() {
44+
return new MacOSXFileSystem(this);
4545
}
4646

4747
@Override

src/java.base/unix/classes/sun/nio/fs/UnixFileSystem.java

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.util.concurrent.TimeUnit;
5353
import java.util.regex.Pattern;
5454
import jdk.internal.misc.Blocker;
55+
import jdk.internal.util.StaticProperty;
5556
import sun.nio.ch.DirectBuffer;
5657
import sun.nio.ch.IOStatus;
5758
import sun.security.action.GetPropertyAction;
@@ -73,39 +74,17 @@ abstract class UnixFileSystem
7374

7475
private final UnixFileSystemProvider provider;
7576
private final byte[] defaultDirectory;
76-
private final boolean needToResolveAgainstDefaultDirectory;
7777
private final UnixPath rootDirectory;
7878

7979
// package-private
80-
UnixFileSystem(UnixFileSystemProvider provider, String dir) {
80+
UnixFileSystem(UnixFileSystemProvider provider) {
81+
String dir = StaticProperty.userDir();
8182
this.provider = provider;
8283
this.defaultDirectory = Util.toBytes(UnixPath.normalizeAndCheck(dir));
8384
if (this.defaultDirectory[0] != '/') {
8485
throw new RuntimeException("default directory must be absolute");
8586
}
8687

87-
// if process-wide chdir is allowed or default directory is not the
88-
// process working directory then paths must be resolved against the
89-
// default directory.
90-
String propValue = GetPropertyAction
91-
.privilegedGetProperty("sun.nio.fs.chdirAllowed", "false");
92-
boolean chdirAllowed = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue);
93-
if (chdirAllowed) {
94-
this.needToResolveAgainstDefaultDirectory = true;
95-
} else {
96-
byte[] cwd = UnixNativeDispatcher.getcwd();
97-
boolean defaultIsCwd = (cwd.length == defaultDirectory.length);
98-
if (defaultIsCwd) {
99-
for (int i=0; i<cwd.length; i++) {
100-
if (cwd[i] != defaultDirectory[i]) {
101-
defaultIsCwd = false;
102-
break;
103-
}
104-
}
105-
}
106-
this.needToResolveAgainstDefaultDirectory = !defaultIsCwd;
107-
}
108-
10988
// the root directory
11089
this.rootDirectory = new UnixPath(this, "/");
11190
}
@@ -115,10 +94,6 @@ byte[] defaultDirectory() {
11594
return defaultDirectory;
11695
}
11796

118-
boolean needToResolveAgainstDefaultDirectory() {
119-
return needToResolveAgainstDefaultDirectory;
120-
}
121-
12297
boolean isCaseInsensitiveAndPreserving() {
12398
return false;
12499
}

src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2023, 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
@@ -75,17 +75,17 @@ public abstract class UnixFileSystemProvider
7575
private final UnixFileSystem theFileSystem;
7676

7777
public UnixFileSystemProvider() {
78-
theFileSystem = newFileSystem(StaticProperty.userDir());
78+
theFileSystem = newFileSystem();
7979
}
8080

8181
UnixFileSystem theFileSystem() {
8282
return theFileSystem;
8383
}
8484

8585
/**
86-
* Constructs a new file system using the given default directory.
86+
* Constructs a new file system.
8787
*/
88-
abstract UnixFileSystem newFileSystem(String dir);
88+
abstract UnixFileSystem newFileSystem();
8989

9090
@Override
9191
public final String getScheme() {

0 commit comments

Comments
 (0)