RFR: 8281104: jar --create should create missing parent directories

Lance Andersen lancea at openjdk.java.net
Thu Feb 3 18:14:13 UTC 2022

On Wed, 2 Feb 2022 20:21:54 GMT, Christian Stein <cstein at openjdk.org> wrote:

> Calling `jar --create --file a/b/foo.jar INPUT-FILES` should create missing parent directories (here `a/b`) on the default file system before storing the JAR file (here `foo.jar`) in the destination directory.

Thank you for taking this on.  Overall looks good.

A few comments below.

Also, we should update jar.properties to indicate that the directory path will be created as needed in the help section for jar.


src/jdk.jartool/share/classes/sun/tools/jar/Main.java line 468:

> 466:                     if (parent != null) {
> 467:                         Files.createDirectories(parent);
> 468:                     }

Would be good to move the creation after validating the arguments as this would fail after creating the temp zip file.  Be good to do via another PR

test/jdk/tools/jar/CreateMissingParentDirectories.java line 38:

> 36: import java.util.stream.Stream;
> 37: 
> 38: public class CreateMissingParentDirectories {

Understand why you used went this route for the test given some of the older tests use this framework.  I might have gone the route of using TestNG as the newer tests (such as in MultiRelease) use it.

test/jdk/tools/jar/CreateMissingParentDirectories.java line 78:

> 76: 
> 77:     private static void doHappyPathTest(Path jar, Path entry) throws Throwable {
> 78:         String[] jarArgs = new String[]{"cf", jar.toString(), entry.toString()};

I might consider also using --create --file in addition to "cf" in a run for an extra sanity check


PR: https://git.openjdk.java.net/jdk/pull/7327

More information about the compiler-dev mailing list