Summary
-----
Permit the use of `--add-modules ALL-MODULE-PATH` when compiling in the context of an automatic module.
Problem
-----
The option `--patch-module` can be used to compile source code "as if" it is part of an explicit named module. For example, a test can be "injected" into an explicit named module by compiling in single-module mode: (assume the `path` directory contains `explicit.jar`, which has a `module-info.class`)
```
$ javac -d out
--module-path path
--patch-module explicit=test/explicit/src
test/explicit/src/explicit/ExplicitTest.java
```
Interestingly, `--patch-module` can also be used to compile source code "as if" it is part of an implicit named module, i.e., in the context of an automatic module. Tests can be "injected" into multiple modules at once -- both explicit and implicit -- by compiling in multi-module mode: (assume the `path` directory contains both `explicit.jar`, which has a `module-info.class`, and `automatic.jar`, which has no `module-info.class`)
```
$ javac -d out
--module-source-path dummy
--module-path path
--patch-module explicit=test/explicit/src
--patch-module automatic=test/automatic/src
test/explicit/src/explicit/ExplicitTest.java
test/automatic/src/automatic/AutomaticTest.java
```
Unfortunately, in this invocation of `javac`, the automatic module `automatic` does not read any other modules. This means that the test code "injected" into the module `automatic` cannot access the same APIs as the test code "injected" into the module `explicit`. The module `explicit` has `requires` directives that set up what `explicit` can read, but the module `automatic` has no `requires` directives.
Solution
-----
When compiling source code _in the unnamed module_, it is legal to say `--add-modules ALL-MODULE-PATH` to add all the modules on the module path to the module graph. This lets the unnamed module (which has no `requires` directives of its own) read a set of modules without adding them one by one, e.g., `--add-modules java.sql,java.desktop,java.xml`. In contrast, when compiling source code _in an explicit named module_, the module has `requires` directives that specify precisely which modules to read, so it is not useful (and indeed not legal) to say `--add-modules ALL-MODULE-PATH`.
Compiling source code _in the context of an automatic module_ is closer to the former scenario (unnamed module) than the latter (explicit named module). An automatic module has no `requires` directives of its own, so it would be useful to say `--add-modules ALL-MODULE-PATH` to let it read all the modules on the module path without adding them one by one.
More by accident than intent, it has not been legal to say `--add-modules ALL-MODULE-PATH` when compiling code in the context of an automatic module using --patch-module. This restriction should be removed.
Specification
-----
Permit `--add-modules ALL-MODULE-PATH` when compiling source code that is [associated](https://docs.oracle.com/javase/specs/jls/se12/html/jls-7.html#jls-7.3-310) with _either_ an unnamed module _or an automatic module (i.e., code being compiled in the context of an automatic module)._