8282397: createTempFile method of java.io.File is failing when called with suffix of spaces character
Reviewed-by: mbaesken
Backport-of: d48181536fa9b99f01fc80f8adb73777ec6ffa58
diff --git a/src/java.base/windows/classes/java/io/WinNTFileSystem.java b/src/java.base/windows/classes/java/io/WinNTFileSystem.java
index f912fa0..a45fd3e 100644
--- a/src/java.base/windows/classes/java/io/WinNTFileSystem.java
+++ b/src/java.base/windows/classes/java/io/WinNTFileSystem.java
@@ -331,9 +331,12 @@
// is a ":" at position 1 and the first character is not a letter
String pathname = f.getPath();
int lastColon = pathname.lastIndexOf(":");
- if (lastColon > 1 ||
- (lastColon == 1 && !isLetter(pathname.charAt(0))))
- return true;
+
+ // Valid if there is no ":" present or if the last ":" present is
+ // at index 1 and the first character is a latter
+ if (lastColon < 0 ||
+ (lastColon == 1 && isLetter(pathname.charAt(0))))
+ return false;
// Invalid if path creation fails
Path path = null;