8350456: Test javax/crypto/CryptoPermissions/InconsistentEntries.java crashed: EXCEPTION_ACCESS_VIOLATION

Backport-of: 825ab20ba9
This commit is contained in:
Goetz Lindenmaier
2025-08-13 09:01:35 +00:00
committed by Vitaly Provodin
parent 203c49d209
commit ebdefa9a9a
2 changed files with 29 additions and 2 deletions

View File

@@ -31,8 +31,8 @@
import java.util.List;
import jdk.test.lib.Utils;
import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.util.FileUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@@ -59,7 +59,7 @@ public class InconsistentEntries {
@BeforeTest
public void setUp() throws Exception {
// Clone the tested JDK to the scratch directory
CDSTestUtils.clone(new File(JDK_HOME), new File(TEMP_JDK_HOME.toString()));
FileUtils.copyDirectory(Path.of(JDK_HOME), TEMP_JDK_HOME);
// create policy directory in the cloned JDK
if (!POLICY_DIR.toFile().exists()) {

View File

@@ -36,6 +36,7 @@ import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.Instant;
import java.util.ArrayList;
@@ -48,6 +49,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jdk.test.lib.Platform;
import com.sun.management.UnixOperatingSystemMXBean;
@@ -364,6 +367,30 @@ public final class FileUtils {
});
}
/**
* Copies a directory and all entries in the directory to a destination path.
* Makes the access permission of the destination entries writable.
*
* @param src the path of the source directory
* @param dst the path of the destination directory
* @throws IOException if an I/O error occurs while walking the file tree
* @throws RuntimeException if an I/O error occurs during the copy operation
* or if the source or destination paths are invalid
*/
public static void copyDirectory(Path src, Path dst) throws IOException {
try (Stream<Path> stream = Files.walk(src)) {
stream.forEach(sourcePath -> {
try {
Path destPath = dst.resolve(src.relativize(sourcePath));
Files.copy(sourcePath, destPath, StandardCopyOption.REPLACE_EXISTING);
destPath.toFile().setWritable(true);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
}
// Return the current process handle count
@SuppressWarnings("restricted")
public static long getProcessHandleCount() {