Skip to content

Commit 16e6e2a

Browse files
committed
8350456: Test javax/crypto/CryptoPermissions/InconsistentEntries.java crashed: EXCEPTION_ACCESS_VIOLATION
Backport-of: 825ab20ba99b1f1127dd94b87ae56020d1831529
1 parent caec079 commit 16e6e2a

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

test/jdk/javax/crypto/CryptoPermissions/InconsistentEntries.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
import java.util.List;
3333
import jdk.test.lib.Utils;
34-
import jdk.test.lib.cds.CDSTestUtils;
3534
import jdk.test.lib.process.ProcessTools;
35+
import jdk.test.lib.util.FileUtils;
3636
import org.testng.Assert;
3737
import org.testng.annotations.BeforeTest;
3838
import org.testng.annotations.Test;
@@ -59,7 +59,7 @@ public class InconsistentEntries {
5959
@BeforeTest
6060
public void setUp() throws Exception {
6161
// Clone the tested JDK to the scratch directory
62-
CDSTestUtils.clone(new File(JDK_HOME), new File(TEMP_JDK_HOME.toString()));
62+
FileUtils.copyDirectory(Path.of(JDK_HOME), TEMP_JDK_HOME);
6363

6464
// create policy directory in the cloned JDK
6565
if (!POLICY_DIR.toFile().exists()) {

test/lib/jdk/test/lib/util/FileUtils.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.nio.file.NoSuchFileException;
3737
import java.nio.file.Path;
3838
import java.nio.file.SimpleFileVisitor;
39+
import java.nio.file.StandardCopyOption;
3940
import java.nio.file.attribute.BasicFileAttributes;
4041
import java.time.Instant;
4142
import java.util.ArrayList;
@@ -48,6 +49,8 @@
4849
import java.util.concurrent.atomic.AtomicBoolean;
4950
import java.util.concurrent.atomic.AtomicReference;
5051
import java.util.stream.Collectors;
52+
import java.util.stream.Stream;
53+
5154
import jdk.test.lib.Platform;
5255

5356
import com.sun.management.UnixOperatingSystemMXBean;
@@ -364,6 +367,30 @@ public static void listFileDescriptors(PrintStream ps) {
364367
});
365368
}
366369

370+
/**
371+
* Copies a directory and all entries in the directory to a destination path.
372+
* Makes the access permission of the destination entries writable.
373+
*
374+
* @param src the path of the source directory
375+
* @param dst the path of the destination directory
376+
* @throws IOException if an I/O error occurs while walking the file tree
377+
* @throws RuntimeException if an I/O error occurs during the copy operation
378+
* or if the source or destination paths are invalid
379+
*/
380+
public static void copyDirectory(Path src, Path dst) throws IOException {
381+
try (Stream<Path> stream = Files.walk(src)) {
382+
stream.forEach(sourcePath -> {
383+
try {
384+
Path destPath = dst.resolve(src.relativize(sourcePath));
385+
Files.copy(sourcePath, destPath, StandardCopyOption.REPLACE_EXISTING);
386+
destPath.toFile().setWritable(true);
387+
} catch (IOException e) {
388+
throw new RuntimeException(e);
389+
}
390+
});
391+
}
392+
}
393+
367394
// Return the current process handle count
368395
@SuppressWarnings("restricted")
369396
public static long getProcessHandleCount() {

0 commit comments

Comments
 (0)