-
CSR
-
Resolution: Withdrawn
-
P4
-
None
-
behavioral
-
low
-
There is little evidence to suggest that this command line option is widely used. Developers can easily combine it with the `--dry-run` option to have the VM exit before the main class is executed.
-
add/remove/modify command line option
-
JDK
Summary
Change the java --validate-modules
command line option to only exit when there are errors detected.
Problem
The java --validate-modules
command line option was added in JDK 9 to check for conflicts and other errors with modules on the module path. The option was originally designed to exit when the validation completes (irrespective of whether it succeeds or fails). This approach turns out to be problematic when the command line option is used in conjunction with other command-line options such as --add-modules
and -m
that can cause failures when creating the boot layer. In addition, it is confusing to combine this command line option with other launcher options that also exit (--list-modules
for example).
The core of the issue is that validation needs the VM to be started, and at the same time, initializing the VM may fail due to errors encountered when creating the boot layer. To avoid this chicken 'n egg problem, --validate-modules
results in the VM starting up with a "minimal boot layer" that is just enough to support the validation. The minimal boot layer ignores options such as --add-modules
and -m
because those options require the module path.
Solution
Change the --validate-modules
option so that it only exits when there are errors detected. This allows the option to be implemented early in startup before options such as --add-modules
or -m
are processed when doing resolution for the boot layer.
The --validate-modules
option is also changed to not print the names of modules that do not have errors. This avoids confusing output when used with --list-modules
that also lists the module names.
The changes make it possible to use --validate-modules
with the --dry-run
option.
Specification
The java -help
output for this option changes from:
"validate all modules and exit"
to:
"validate all modules on the module path"