Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/java.base/unix/classes/sun/nio/fs/UnixPath.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -57,8 +57,8 @@ class UnixPath implements Path {
// internal representation
private final byte[] path;

// String representation (created lazily)
private volatile String stringValue;
// String representation (created lazily, no need to be volatile)
private String stringValue;

// cached hashcode (created lazily, no need to be volatile)
private int hash;
Expand Down Expand Up @@ -761,8 +761,9 @@ public int hashCode() {
@Override
public String toString() {
// OK if two or more threads create a String
String stringValue = this.stringValue;
if (stringValue == null) {
stringValue = fs.normalizeJavaPath(Util.toString(path)); // platform encoding
this.stringValue = stringValue = fs.normalizeJavaPath(Util.toString(path)); // platform encoding
}
return stringValue;
}
Expand Down