Skip to content
Permalink
Browse files
8290832: It is no longer possible to change "user.dir" in the JDK8
Reviewed-by: phh, andrew
  • Loading branch information
mrserb committed Jul 31, 2022
1 parent 244f98e commit 2dadc2bf312d5f947e0735d5ec13c285824db31d
Showing 3 changed files with 2 additions and 67 deletions.
@@ -34,7 +34,6 @@ class UnixFileSystem extends FileSystem {
private final char slash;
private final char colon;
private final String javaHome;
private final String userDir;

public UnixFileSystem() {
slash = AccessController.doPrivileged(
@@ -43,8 +42,6 @@ public UnixFileSystem() {
new GetPropertyAction("path.separator")).charAt(0);
javaHome = AccessController.doPrivileged(
new GetPropertyAction("java.home"));
userDir = AccessController.doPrivileged(
new GetPropertyAction("user.dir"));
}


@@ -138,11 +135,7 @@ public boolean isInvalid(File f) {

public String resolve(File f) {
if (isAbsolute(f)) return f.getPath();
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertyAccess("user.dir");
}
return resolve(userDir, f.getPath());
return resolve(System.getProperty("user.dir"), f.getPath());
}

// Caches for canonicalization results to improve startup performance.
@@ -53,7 +53,6 @@ class WinNTFileSystem extends FileSystem {
private final char slash;
private final char altSlash;
private final char semicolon;
private final String userDir;

// Whether to enable alternative data streams (ADS) by suppressing
// checking the path for invalid characters, in particular ":".
@@ -75,8 +74,6 @@ public WinNTFileSystem() {
semicolon = AccessController.doPrivileged(
new GetPropertyAction("path.separator")).charAt(0);
altSlash = (this.slash == '\\') ? '/' : '\\';
userDir = AccessController.doPrivileged(
new GetPropertyAction("user.dir"));
}

private boolean isSlash(char c) {
@@ -403,11 +400,7 @@ public String resolve(File f) {
private String getUserPath() {
/* For both compatibility and security,
we must look this up every time */
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertyAccess("user.dir");
}
return normalize(userDir);
return normalize(System.getProperty("user.dir"));
}

private String getDrive(String path) {

This file was deleted.

1 comment on commit 2dadc2b

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 2dadc2b Jul 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.