diff --git a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java
index ca4c3301db4be167743e6c6dc1523c8b0b6f7f8e..adbc8472891dbc4b5ca35547656830a504e46f98 100644
--- a/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java
+++ b/test/jdk/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2024, 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
@@ -41,6 +41,7 @@ import java.io.FileWriter;
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.lang.management.ManagementFactory;
+import java.nio.file.Path;
 import java.util.Map;
 import jdk.test.lib.process.ProcessTools;
 import sun.tools.attach.HotSpotVirtualMachine;
@@ -53,7 +54,7 @@ public class CheckOrigin {
         if (args.length == 0) {
             // start a process that has options set in a number of different ways
 
-            File flagsFile = File.createTempFile("CheckOriginFlags", null);
+            File flagsFile = File.createTempFile("CheckOriginFlags", null, Path.of(".").toFile());
             try (PrintWriter pw =
                    new PrintWriter(new FileWriter(flagsFile))) {
                 pw.println("+PrintCodeCache");
diff --git a/test/jdk/java/io/File/CheckPermission.java b/test/jdk/java/io/File/CheckPermission.java
index f6126a088434f1bb9100d4e240153120fa19b70e..b1976c84b46d32fb3ae9a0c14d9e14a9477f0554 100644
--- a/test/jdk/java/io/File/CheckPermission.java
+++ b/test/jdk/java/io/File/CheckPermission.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2024, 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
@@ -362,13 +362,13 @@ public class CheckPermission {
                 "getFileSystemAttributes");
 
         prepare();
-        File tmpFile = File.createTempFile(CHECK_PERMISSION_TEST, null);
+        File tmpFile = File.createTempFile(CHECK_PERMISSION_TEST, null, new File("."));
         assertOnlyCheckOperation(tmpFile, EnumSet.of(FileOperation.WRITE));
         tmpFile.delete();
         assertCheckOperation(tmpFile, EnumSet.of(FileOperation.DELETE));
 
         prepare();
-        tmpFile = File.createTempFile(CHECK_PERMISSION_TEST, null, null);
+        tmpFile = File.createTempFile(CHECK_PERMISSION_TEST, null, new File("."));
         assertOnlyCheckOperation(tmpFile, EnumSet.of(FileOperation.WRITE));
         tmpFile.delete();
         assertCheckOperation(tmpFile, EnumSet.of(FileOperation.DELETE));
diff --git a/test/jdk/java/io/FileInputStream/NegativeAvailable.java b/test/jdk/java/io/FileInputStream/NegativeAvailable.java
index a0e0e9992310c31f2ab19e71b47374f28123c0ed..27e1309f4ee106c8a900e28fd668ebfd226e7a77 100644
--- a/test/jdk/java/io/FileInputStream/NegativeAvailable.java
+++ b/test/jdk/java/io/FileInputStream/NegativeAvailable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2024, 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
@@ -46,28 +46,31 @@ public class NegativeAvailable {
 
         // Create a temporary file with size of 10 bytes.
         Path tmp = Files.createTempFile(null, null);
-        try (BufferedWriter writer =
-            Files.newBufferedWriter(tmp, Charset.defaultCharset())) {
-            for (int i = 0; i < SIZE; i++) {
-                writer.write('1');
+        try {
+            try (BufferedWriter writer =
+                         Files.newBufferedWriter(tmp, Charset.defaultCharset())) {
+                for (int i = 0; i < SIZE; i++) {
+                    writer.write('1');
+                }
             }
-        }
 
-        File tempFile = tmp.toFile();
-        try (FileInputStream fis = new FileInputStream(tempFile)) {
-            if (tempFile.length() != SIZE) {
-                throw new RuntimeException("unexpected file size = "
-                                           + tempFile.length());
+            File tempFile = tmp.toFile();
+            try (FileInputStream fis = new FileInputStream(tempFile)) {
+                if (tempFile.length() != SIZE) {
+                    throw new RuntimeException("unexpected file size = "
+                            + tempFile.length());
+                }
+                long space = skipBytes(fis, SKIP, SIZE);
+                space = skipBytes(fis, NEGATIVE_SKIP, space);
+                space = skipBytes(fis, SKIP, space);
+                space = skipBytes(fis, SKIP, space);
+                space = skipBytes(fis, SKIP, space);
+                space = skipBytes(fis, NEGATIVE_SKIP, space);
+                space = skipBytes(fis, NEGATIVE_SKIP, space);
             }
-            long space = skipBytes(fis, SKIP, SIZE);
-            space = skipBytes(fis, NEGATIVE_SKIP, space);
-            space = skipBytes(fis, SKIP, space);
-            space = skipBytes(fis, SKIP, space);
-            space = skipBytes(fis, SKIP, space);
-            space = skipBytes(fis, NEGATIVE_SKIP, space);
-            space = skipBytes(fis, NEGATIVE_SKIP, space);
+        } finally {
+            Files.deleteIfExists(tmp);
         }
-        Files.deleteIfExists(tmp);
     }
 
     /**
diff --git a/test/jdk/java/nio/channels/unixdomain/Bind.java b/test/jdk/java/nio/channels/unixdomain/Bind.java
index 47fc24ae1afa235a2c222b5e7409a10b8bae36bc..4f4e146a94f9105d27cf22666b51f51f4253a6bc 100644
--- a/test/jdk/java/nio/channels/unixdomain/Bind.java
+++ b/test/jdk/java/nio/channels/unixdomain/Bind.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2024, 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
@@ -159,13 +159,17 @@ public class Bind {
         });
         // address with space should work
         checkNormal(() -> {
-            server = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
-            UnixDomainSocketAddress usa =  UnixDomainSocketAddress.of("with space"); // relative to CWD
+            UnixDomainSocketAddress usa = UnixDomainSocketAddress.of("with space");
             Files.deleteIfExists(usa.getPath());
-            server.bind(usa);
-            client = SocketChannel.open(usa);
-            Files.delete(usa.getPath());
-            assertAddress(client.getRemoteAddress(), usa, "address");
+            try {
+                server = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
+                // relative to CWD
+                server.bind(usa);
+                client = SocketChannel.open(usa);
+                assertAddress(client.getRemoteAddress(), usa, "address");
+            } finally {
+                Files.deleteIfExists(usa.getPath());
+            }
         });
         // client bind to null: allowed
         checkNormal(() -> {
@@ -185,12 +189,19 @@ public class Bind {
         });
         // server bind to null: should bind to a local address
         checkNormal(() -> {
-            server = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
-            server.bind(null);
-            UnixDomainSocketAddress usa = (UnixDomainSocketAddress)server.getLocalAddress();
-            if (usa.getPath().toString().isEmpty())
-                throw new RuntimeException("expected non zero address length");
-            System.out.println("Null server address: " + server.getLocalAddress());
+            UnixDomainSocketAddress usa = null;
+            try {
+                server = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
+                server.bind(null);
+                usa = (UnixDomainSocketAddress) server.getLocalAddress();
+                if (usa.getPath().toString().isEmpty())
+                    throw new RuntimeException("expected non zero address length");
+                System.out.println("Null server address: " + server.getLocalAddress());
+            } finally {
+                if (usa != null) {
+                    Files.deleteIfExists(usa.getPath());
+                }
+            }
         });
         // server no bind : not allowed
         checkException(
@@ -307,23 +318,32 @@ public class Bind {
             Arrays.fill(chars, 'x');
             String name = new String(chars);
             UnixDomainSocketAddress address = UnixDomainSocketAddress.of(name);
-            ServerSocketChannel server = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
-            server.bind(address);
-            SocketChannel client = SocketChannel.open(address);
-            assertAddress(server.getLocalAddress(), address, "server");
-            assertAddress(client.getRemoteAddress(), address, "client");
-            Files.delete(address.getPath());
+            try {
+                ServerSocketChannel server = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
+                server.bind(address);
+                SocketChannel client = SocketChannel.open(address);
+                assertAddress(server.getLocalAddress(), address, "server");
+                assertAddress(client.getRemoteAddress(), address, "client");
+            } finally {
+                Files.deleteIfExists(address.getPath());
+            }
         });
 
         // implicit server bind
         checkNormal(() -> {
-            server = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
-            server.bind(null);
-            UnixDomainSocketAddress usa = (UnixDomainSocketAddress)server.getLocalAddress();
-            client = SocketChannel.open(usa);
-            accept1 = server.accept();
-            assertAddress(client.getRemoteAddress(), usa, "server");
-            Files.delete(usa.getPath());
+            UnixDomainSocketAddress usa = null;
+            try {
+                server = ServerSocketChannel.open(StandardProtocolFamily.UNIX);
+                server.bind(null);
+                usa = (UnixDomainSocketAddress) server.getLocalAddress();
+                client = SocketChannel.open(usa);
+                accept1 = server.accept();
+                assertAddress(client.getRemoteAddress(), usa, "server");
+            } finally {
+                if (usa != null) {
+                    Files.deleteIfExists(usa.getPath());
+                }
+            }
         });
     }
 }
diff --git a/test/jdk/java/nio/channels/unixdomain/NonBlockingAccept.java b/test/jdk/java/nio/channels/unixdomain/NonBlockingAccept.java
index 62b21a98d603778dab0b8fa7e6c37d863f055940..f5cea54dbb85300e409b8d11e7142e6cf690a911 100644
--- a/test/jdk/java/nio/channels/unixdomain/NonBlockingAccept.java
+++ b/test/jdk/java/nio/channels/unixdomain/NonBlockingAccept.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2024, 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
@@ -29,8 +29,11 @@
  */
 
 import java.net.StandardProtocolFamily;
+import java.net.UnixDomainSocketAddress;
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
+import java.nio.file.Files;
+
 import jtreg.SkippedException;
 
 public class NonBlockingAccept {
@@ -48,17 +51,23 @@ public class NonBlockingAccept {
     public static void main(String[] args) throws Exception {
 
         checkSupported();
+        UnixDomainSocketAddress addr = null;
 
         try (ServerSocketChannel serverSocketChannel =
                                  ServerSocketChannel.open(StandardProtocolFamily.UNIX)) {
             //non blocking mode
             serverSocketChannel.configureBlocking(false);
             serverSocketChannel.bind(null);
+            addr = (UnixDomainSocketAddress) serverSocketChannel.getLocalAddress();
             SocketChannel socketChannel = serverSocketChannel.accept();
             System.out.println("The socketChannel is : expected Null " + socketChannel);
             if (socketChannel != null)
                 throw new RuntimeException("expected null");
             // or exception could be thrown otherwise
+        } finally {
+            if (addr != null) {
+                Files.deleteIfExists(addr.getPath());
+            }
         }
     }
 }
diff --git a/test/jdk/java/util/zip/ZipFile/ZeroDate.java b/test/jdk/java/util/zip/ZipFile/ZeroDate.java
index d0e7263fc19a9bd1368829e510372d7933e300a1..441ef88cd2a5803937362eae7e7779e7539bfcff 100644
--- a/test/jdk/java/util/zip/ZipFile/ZeroDate.java
+++ b/test/jdk/java/util/zip/ZipFile/ZeroDate.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2024, 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
@@ -40,41 +40,47 @@ import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 import java.util.zip.ZipOutputStream;
 
+import jdk.test.lib.Utils;
+
 /* @test
  * @bug 8184940 8188869
  * @summary JDK 9 rejects zip files where the modified day or month is 0
  *          or otherwise represent an invalid date, such as 1980-02-30 24:60:60
  * @author Liam Miller-Cushon
+ * @library /test/lib
  */
 public class ZeroDate {
 
     public static void main(String[] args) throws Exception {
         // create a zip file, and read it in as a byte array
-        Path path = Files.createTempFile("bad", ".zip");
-        try (OutputStream os = Files.newOutputStream(path);
-                ZipOutputStream zos = new ZipOutputStream(os)) {
-            ZipEntry e = new ZipEntry("x");
-            zos.putNextEntry(e);
-            zos.write((int) 'x');
-        }
-        int len = (int) Files.size(path);
-        byte[] data = new byte[len];
-        try (InputStream is = Files.newInputStream(path)) {
-            is.read(data);
-        }
-        Files.delete(path);
+        Path path = Utils.createTempFile("bad", ".zip");
+        try {
+            try (OutputStream os = Files.newOutputStream(path);
+                 ZipOutputStream zos = new ZipOutputStream(os)) {
+                ZipEntry e = new ZipEntry("x");
+                zos.putNextEntry(e);
+                zos.write((int) 'x');
+            }
+            int len = (int) Files.size(path);
+            byte[] data = new byte[len];
+            try (InputStream is = Files.newInputStream(path)) {
+                is.read(data);
+            }
 
-        // year, month, day are zero
-        testDate(data.clone(), 0, LocalDate.of(1979, 11, 30).atStartOfDay());
-        // only year is zero
-        testDate(data.clone(), 0 << 25 | 4 << 21 | 5 << 16, LocalDate.of(1980, 4, 5).atStartOfDay());
-        // month is greater than 12
-        testDate(data.clone(), 0 << 25 | 13 << 21 | 1 << 16, LocalDate.of(1981, 1, 1).atStartOfDay());
-        // 30th of February
-        testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16, LocalDate.of(1980, 3, 1).atStartOfDay());
-        // 30th of February, 24:60:60
-        testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16 | 24 << 11 | 60 << 5 | 60 >> 1,
-                LocalDateTime.of(1980, 3, 2, 1, 1, 0));
+            // year, month, day are zero
+            testDate(data.clone(), 0, LocalDate.of(1979, 11, 30).atStartOfDay());
+            // only year is zero
+            testDate(data.clone(), 0 << 25 | 4 << 21 | 5 << 16, LocalDate.of(1980, 4, 5).atStartOfDay());
+            // month is greater than 12
+            testDate(data.clone(), 0 << 25 | 13 << 21 | 1 << 16, LocalDate.of(1981, 1, 1).atStartOfDay());
+            // 30th of February
+            testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16, LocalDate.of(1980, 3, 1).atStartOfDay());
+            // 30th of February, 24:60:60
+            testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16 | 24 << 11 | 60 << 5 | 60 >> 1,
+                    LocalDateTime.of(1980, 3, 2, 1, 1, 0));
+        } finally {
+            Files.delete(path);
+        }
     }
 
     private static void testDate(byte[] data, int date, LocalDateTime expected) throws IOException {
@@ -86,7 +92,7 @@ public class ZeroDate {
         writeU32(data, locpos + LOCTIM, date);
 
         // ensure that the archive is still readable, and the date is 1979-11-30
-        Path path = Files.createTempFile("out", ".zip");
+        Path path = Utils.createTempFile("out", ".zip");
         try (OutputStream os = Files.newOutputStream(path)) {
             os.write(data);
         }
diff --git a/test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java b/test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java
index 8ddc5357b37f2610d7b24ca86098b61597cf5359..94383298ddcf8814af513dd150ddeb986fca48c2 100644
--- a/test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java
+++ b/test/jdk/jdk/jfr/api/consumer/filestream/TestOrdered.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2024, 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
@@ -23,7 +23,6 @@
 
 package jdk.jfr.api.consumer.filestream;
 
-import java.nio.file.Files;
 import java.nio.file.Path;
 import java.time.Instant;
 import java.util.ArrayList;
@@ -35,6 +34,7 @@ import java.util.concurrent.atomic.AtomicReference;
 import jdk.jfr.Event;
 import jdk.jfr.Recording;
 import jdk.jfr.consumer.EventStream;
+import jdk.test.lib.Utils;
 
 /**
  * @test
@@ -148,7 +148,7 @@ public class TestOrdered {
                 e.join();
             }
             r.stop();
-            Path p = Files.createTempFile("recording", ".jfr");
+            Path p = Utils.createTempFile("recording", ".jfr");
             r.dump(p);
             return p;
         }
diff --git a/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java b/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java
index 3d7d143f44cdcededb793a6ea7565575f3409205..651656272a599d4ebab261355e29b5e6d2a8b1e4 100644
--- a/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java
+++ b/test/jdk/jdk/jfr/api/consumer/filestream/TestReuse.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2024, 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
@@ -34,6 +34,7 @@ import jdk.jfr.Event;
 import jdk.jfr.Recording;
 import jdk.jfr.consumer.EventStream;
 import jdk.jfr.consumer.RecordedEvent;
+import jdk.test.lib.Utils;
 
 /**
  * @test
@@ -118,7 +119,7 @@ public class TestReuse {
             }
             r.stop();
             rotation.close();
-            Path p = Files.createTempFile("recording", ".jfr");
+            Path p = Utils.createTempFile("recording", ".jfr");
             r.dump(p);
             return p;
         }
diff --git a/test/jdk/jdk/nio/zipfs/ZeroDate.java b/test/jdk/jdk/nio/zipfs/ZeroDate.java
index 4f40f192f4305afde1237644f38c7f8445d8fdf3..ff702f63488417f8b25d57ef99f239cb413c462d 100644
--- a/test/jdk/jdk/nio/zipfs/ZeroDate.java
+++ b/test/jdk/jdk/nio/zipfs/ZeroDate.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2024, 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
@@ -44,42 +44,48 @@ import java.util.Collections;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
+import jdk.test.lib.Utils;
+
 /* @test
  * @bug 8184940 8186227 8188869
  * @summary JDK 9 rejects zip files where the modified day or month is 0
  *          or otherwise represent an invalid date, such as 1980-02-30 24:60:60
  * @author Liam Miller-Cushon
  * @modules jdk.zipfs
+ * @library /test/lib
  */
 public class ZeroDate {
 
     public static void main(String[] args) throws Exception {
         // create a zip file, and read it in as a byte array
-        Path path = Files.createTempFile("bad", ".zip");
-        try (OutputStream os = Files.newOutputStream(path);
-                ZipOutputStream zos = new ZipOutputStream(os)) {
-            ZipEntry e = new ZipEntry("x");
-            zos.putNextEntry(e);
-            zos.write((int) 'x');
-        }
-        int len = (int) Files.size(path);
-        byte[] data = new byte[len];
-        try (InputStream is = Files.newInputStream(path)) {
-            is.read(data);
-        }
-        Files.delete(path);
+        Path path = Utils.createTempFile("bad", ".zip");
+        try {
+            try (OutputStream os = Files.newOutputStream(path);
+                 ZipOutputStream zos = new ZipOutputStream(os)) {
+                ZipEntry e = new ZipEntry("x");
+                zos.putNextEntry(e);
+                zos.write((int) 'x');
+            }
+            int len = (int) Files.size(path);
+            byte[] data = new byte[len];
+            try (InputStream is = Files.newInputStream(path)) {
+                is.read(data);
+            }
 
-        // year, month, day are zero
-        testDate(data.clone(), 0, LocalDate.of(1979, 11, 30).atStartOfDay());
-        // only year is zero
-        testDate(data.clone(), 0 << 25 | 4 << 21 | 5 << 16, LocalDate.of(1980, 4, 5).atStartOfDay());
-        // month is greater than 12
-        testDate(data.clone(), 0 << 25 | 13 << 21 | 1 << 16, LocalDate.of(1981, 1, 1).atStartOfDay());
-        // 30th of February
-        testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16, LocalDate.of(1980, 3, 1).atStartOfDay());
-        // 30th of February, 24:60:60
-        testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16 | 24 << 11 | 60 << 5 | 60 >> 1,
-                LocalDateTime.of(1980, 3, 2, 1, 1, 0));
+            // year, month, day are zero
+            testDate(data.clone(), 0, LocalDate.of(1979, 11, 30).atStartOfDay());
+            // only year is zero
+            testDate(data.clone(), 0 << 25 | 4 << 21 | 5 << 16, LocalDate.of(1980, 4, 5).atStartOfDay());
+            // month is greater than 12
+            testDate(data.clone(), 0 << 25 | 13 << 21 | 1 << 16, LocalDate.of(1981, 1, 1).atStartOfDay());
+            // 30th of February
+            testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16, LocalDate.of(1980, 3, 1).atStartOfDay());
+            // 30th of February, 24:60:60
+            testDate(data.clone(), 0 << 25 | 2 << 21 | 30 << 16 | 24 << 11 | 60 << 5 | 60 >> 1,
+                    LocalDateTime.of(1980, 3, 2, 1, 1, 0));
+        } finally {
+            Files.delete(path);
+        }
     }
 
     private static void testDate(byte[] data, int date, LocalDateTime expected) throws IOException {
@@ -91,7 +97,7 @@ public class ZeroDate {
         writeU32(data, locpos + LOCTIM, date);
 
         // ensure that the archive is still readable, and the date is 1979-11-30
-        Path path = Files.createTempFile("out", ".zip");
+        Path path = Utils.createTempFile("out", ".zip");
         try (OutputStream os = Files.newOutputStream(path)) {
             os.write(data);
         }
diff --git a/test/jdk/sun/security/pkcs12/P12SecretKey.java b/test/jdk/sun/security/pkcs12/P12SecretKey.java
index 34c90d638c8522b887e6b18054838d5367aba774..ed599a5596201fbdfe88ead4b3b3c79f5dcae3ce 100644
--- a/test/jdk/sun/security/pkcs12/P12SecretKey.java
+++ b/test/jdk/sun/security/pkcs12/P12SecretKey.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2024, 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
@@ -33,6 +33,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.nio.file.Files;
 import java.security.KeyStore;
 import java.security.cert.CertificateException;
 import java.util.Arrays;
@@ -66,24 +67,29 @@ public class P12SecretKey {
         ks.setEntry(ALIAS, ske, kspp);
 
         File ksFile = File.createTempFile("test", ".test");
-        try (FileOutputStream fos = new FileOutputStream(ksFile)) {
-            ks.store(fos, pw);
-            fos.flush();
-        }
 
-        // now see if we can get it back
-        try (FileInputStream fis = new FileInputStream(ksFile)) {
-            KeyStore ks2 = KeyStore.getInstance(keystoreType);
-            ks2.load(fis, pw);
-            KeyStore.Entry entry = ks2.getEntry(ALIAS, kspp);
-            SecretKey keyIn = ((KeyStore.SecretKeyEntry)entry).getSecretKey();
-            if (Arrays.equals(key.getEncoded(), keyIn.getEncoded())) {
-                System.err.println("OK: worked just fine with " + keystoreType +
-                                   " keystore");
-            } else {
-                System.err.println("ERROR: keys are NOT equal after storing in "
-                                   + keystoreType + " keystore");
+        try {
+            try (FileOutputStream fos = new FileOutputStream(ksFile)) {
+                ks.store(fos, pw);
+                fos.flush();
+            }
+
+            // now see if we can get it back
+            try (FileInputStream fis = new FileInputStream(ksFile)) {
+                KeyStore ks2 = KeyStore.getInstance(keystoreType);
+                ks2.load(fis, pw);
+                KeyStore.Entry entry = ks2.getEntry(ALIAS, kspp);
+                SecretKey keyIn = ((KeyStore.SecretKeyEntry) entry).getSecretKey();
+                if (Arrays.equals(key.getEncoded(), keyIn.getEncoded())) {
+                    System.err.println("OK: worked just fine with " + keystoreType +
+                            " keystore");
+                } else {
+                    System.err.println("ERROR: keys are NOT equal after storing in "
+                            + keystoreType + " keystore");
+                }
             }
+        } finally {
+            Files.deleteIfExists(ksFile.toPath());
         }
     }
 }