RFR: 8373097: Save command should create missing parent directories

Christian Stein cstein at openjdk.org
Mon Dec 8 07:14:06 UTC 2025


Please review this change enhancing the `/save <file>` command in JShell to create missing parent directories.

Prior to this change, when the <file> argument of a `/save` command starts with a list of directory names, of which at least one does not exist, the command fails with an exception reading:

| File 'some/path/Snippet.java' for '/save' threw exception: java.nio.file.NoSuchFileException: some\path\Snippet.java


Any exception happening during the creation of missing parent directories (using `Files.createDirectories` API) is caught and transformed into file-related error message.

-------------

Commit messages:
 - Clean up
 - Add file with parent directories to `/save` test
 - 8373097: Save command should create missing parent directories

Changes: https://git.openjdk.org/jdk/pull/28662/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28662&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8373097
  Stats: 17 lines in 2 files changed: 15 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/28662.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28662/head:pull/28662

PR: https://git.openjdk.org/jdk/pull/28662


More information about the compiler-dev mailing list