diff --git a/jdk/src/java.base/share/classes/java/io/File.java b/jdk/src/java.base/share/classes/java/io/File.java index 1598694ef2f..0bbaf4d5d0b 100644 --- a/jdk/src/java.base/share/classes/java/io/File.java +++ b/jdk/src/java.base/share/classes/java/io/File.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2017, 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 @@ -1962,6 +1962,9 @@ public class File name = sb.toString(); } + // Normalize the path component + name = fs.normalize(name); + File f = new File(dir, name); if (!name.equals(f.getName()) || f.isInvalid()) { if (System.getSecurityManager() != null) diff --git a/jdk/test/java/io/File/createTempFile/Patterns.java b/jdk/test/java/io/File/createTempFile/Patterns.java index 0169a5e4b9c..2a899f65101 100644 --- a/jdk/test/java/io/File/createTempFile/Patterns.java +++ b/jdk/test/java/io/File/createTempFile/Patterns.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, 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 @@ -22,7 +22,7 @@ */ /* @test - @bug 4152178 + @bug 4152178 8152272 @summary Check various temp-file prefix/suffix cases */ import java.io.File; @@ -66,6 +66,7 @@ public class Patterns { cky("xxx", ""); cky("xxx", "y"); cky("xxx", ".y"); + cky("xyz", "Directory" + System.getProperty("file.separator")); } }