< prev index next >
src/java.base/windows/classes/java/io/WinNTFileSystem.java
Print this page
@@ -41,11 +41,12 @@
class WinNTFileSystem extends FileSystem {
private final char slash;
private final char altSlash;
private final char semicolon;
- private final String userDir;
+ private String userDir;
+ private volatile boolean isUserDirNormal;
public WinNTFileSystem() {
Properties props = GetPropertyAction.privilegedGetProperties();
slash = props.getProperty("file.separator").charAt(0);
semicolon = props.getProperty("path.separator").charAt(0);
@@ -351,11 +352,21 @@
we must look this up every time */
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertyAccess("user.dir");
}
- return normalize(userDir);
+ boolean normalize = !isUserDirNormal;
+ if (normalize) {
+ synchronized(userDir) {
+ normalize = !isUserDirNormal;
+ if (normalize) {
+ userDir = normalize(userDir);
+ isUserDirNormal = true;
+ }
+ }
+ }
+ return userDir;
}
private String getDrive(String path) {
int pl = prefixLength(path);
return (pl == 3) ? path.substring(0, 2) : null;
< prev index next >