Intended usage of `java --dry-run`?

Andrew Guibert aguibert at us.ibm.com
Tue Apr 11 14:36:21 UTC 2017



I'm working with JDK build b162 and I see that the following option is
listed:

    --dry-run     create VM but do not execute main method.
                  This --dry-run option may be useful for validating the
                  command-line options such as the module system
configuration.

This looked like a convenient option for quickly verifying that I'm
specifying other command line options correctly, so I decided to try it
out.  I was surprised to see that --dry-run prints out full usage
information regardless of how it was used.  This confused me because it
lead me to believe that I was using the option incorrectly.

Based on the mailing list discussion where --dry-run was introduced [1] it
appears it is intended to be a more obvious substitute than using --version
for validating command-line options.  If that's the case, I find the
following use cases to be inconsistent:

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

$ java --version
java 9-ea
Java(TM) SE Runtime Environment (build 9-ea+162)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+162, mixed mode)

$ java --dry-run
Usage: java [options] class [args...]
   . . . full usage data

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

$ java --add-modules java.se.ee
Usage: java [options] class [args...]
   . . . full usage data

$ java --add-modules java.se.ee --dry-run
Usage: java [options] class [args...]
   . . . full usage data

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

$ java --help
Usage: java [options] class [args...]
   . . . full usage data

$ java --dry-run
Usage: java [options] class [args...]
   . . . full usage data

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

Based on these three use cases, either I'm using --dry-run incorrectly
(which isn't obvious if I am) or --dry-run is simply a placebo option.  My
main point of confusion comes from (what I believe to be) correct usage of
--dry-run printing out usage info.  For many command line utilities,
printing out usage info (unless explicitly requested via --help) is a
result of command line options being specified incorrectly.

Instead of printing usage info on successful invocation of --dry-run, I
think it would make more sense to give a short acknowledgement that a dry
run of the VM took place, for example:

$ java --dry-run
Java VM successfully launched for dry run.


[1] http://mail.openjdk.java.net/pipermail/jigsaw-dev/2016-July/008397.html


More information about the jigsaw-dev mailing list