8249586: Test runtime/cds/appcds/DirClasspathTest.java will fail if run twice

Add the StandardCopyOption.REPLACE_EXISTING option when calling Files.copy().

Reviewed-by: iklam
This commit is contained in:
Calvin Cheung 2020-08-04 19:17:31 +00:00
parent f4de95a97c
commit d7c7f70a6a

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -38,6 +38,7 @@ import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
public class DirClasspathTest {
@ -118,7 +119,7 @@ public class DirClasspathTest {
// Long path to non-empty dir in -cp: should report error if a class is loaded from it
File srcClass = new File(classDir.toFile(), "Super.class");
File destClass = new File(longDir, "Super.class");
Files.copy(srcClass.toPath(), destClass.toPath());
Files.copy(srcClass.toPath(), destClass.toPath(), StandardCopyOption.REPLACE_EXISTING);
output = doDump(longDir.getPath(), appClassList2, "-Xlog:class+path=info");
output.shouldNotHaveExitValue(0);
output.shouldContain("Cannot have non-empty directory in paths");