On Wed, 5 May 2021 18:42:20 GMT, Yumin Qi <mi...@openjdk.org> wrote: >> src/java.base/share/classes/jdk/internal/misc/CDS.java line 284: >> >>> 282: >>> 283: String tempFileName = getArchiveFileName(archiveFileName); >>> 284: File tempArchiveFile = new File(tempFileName); >> >> I think the logic is too complicated. We can always write the archive to a >> temp file, and then rename it to the actual file. Also, to be consistent >> with the other variables, it should be `tempArchiveFileName` >> >> >> String tempArchiveFileName = archiveFileName + ".tmp"; > > getArchiveFileName also operates on create/delete temp file, so if that > fails, throw exception back to caller. Do you think the logic should be kept?
How about: File tempArchiveFile = new File(tempArchiveFileName); tempArchiveFile.createNewFile(); // will throw exception if we cannot write to the directory. tempArchiveFile.delete(); ------------- PR: https://git.openjdk.java.net/jdk/pull/3886