Skip to content

Commit

Permalink
8274122: java/io/File/createTempFile/SpecialTempFile.java fails in Wi…
Browse files Browse the repository at this point in the history
…ndows 11

Backport-of: 4a142c3b0831d60b3d5540f58973e8ad3d1304bf
  • Loading branch information
Amos Shi authored and shipilev committed Jan 30, 2024
1 parent 14f62ac commit dead333
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ java/lang/instrument/RetransformBigClass.sh 8065756 generic-
# jdk_io

java/io/pathNames/GeneralWin32.java 8180264 windows-all
java/io/File/createTempFile/SpecialTempFile.java 8274122 windows11

############################################################################

Expand Down
17 changes: 11 additions & 6 deletions test/jdk/java/io/File/createTempFile/SpecialTempFile.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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 All @@ -24,6 +24,7 @@
/*
* @test
* @bug 8013827 8011950 8017212 8025128
* @modules java.base/jdk.internal.util
* @summary Check whether File.createTempFile can handle special parameters
* @author Dan Xu
*/
Expand All @@ -32,10 +33,11 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class SpecialTempFile {
import jdk.internal.util.OperatingSystem;
import jdk.internal.util.OSVersion;

public class SpecialTempFile {
private static void test(String name, String[] prefix, String[] suffix,
boolean exceptionExpected) throws IOException
{
Expand All @@ -48,7 +50,7 @@ private static void test(String name, String[] prefix, String[] suffix,
final String exceptionMsg = "Unable to create temporary file";
String[] dirs = { null, "." };

Path testPath = Paths.get(System.getProperty("test.dir", "."));
Path testPath = Path.of(System.getProperty("test.dir", "."));
for (int i = 0; i < prefix.length; i++) {
boolean exceptionThrown = false;
File f = null;
Expand Down Expand Up @@ -99,12 +101,15 @@ public static void main(String[] args) throws Exception {
test("SlashedName", slashPre, slashSuf, true);

// Windows tests
if (!System.getProperty("os.name").startsWith("Windows"))
if (!OperatingSystem.isWindows())
return;

// Test JDK-8013827
String[] resvPre = { "LPT1.package.zip", "com7.4.package.zip" };
String[] resvSuf = { ".temp", ".temp" };
test("ReservedName", resvPre, resvSuf, true);
boolean exceptionExpected =
!(System.getProperty("os.name").endsWith("11") ||
new OSVersion(10, 0).compareTo(OSVersion.current()) > 0);
test("ReservedName", resvPre, resvSuf, exceptionExpected);
}
}

1 comment on commit dead333

@openjdk-notifier
Copy link

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.