RFR: 8290561: Coalesce incubator-module warnings for single-file source-code programs
Jan Lahoda
jlahoda at openjdk.org
Fri Jul 22 07:04:08 UTC 2022
Consider a trivial code like:
public class Main {
public static void main(String... args) {}
}
And an execution like:
$ java --add-modules jdk.incubator.concurrent Main.java
WARNING: Using incubator modules: jdk.incubator.concurrent
warning: using incubating module(s): jdk.incubator.concurrent
1 warning
Having two warnings (one from runtime, one from javac) seems unnecessary. The patch proposed herein tries to avoid the javac warning, keeping only the runtime one. The conditions under which an incubator module is ignored w.r.t. this warning are:
* the boot Module layer has the module (hence, presumably, the runtime already provided the warning)
* the javac run is (likely) from the source launcher. This is being done using a custom javac option, `-XDsourceLauncher` (which can possibly be used in other cases).
This is to avoid cases where we would incorrectly suppress the incubator warning, e.g. when `-XDsourceLauncher` would be passed on the command line.
There are other ways to attempt to detect javac invocations from the source launcher - a distinct file manager is used by the source launcher (but detection of the specific file manager does not feel in line with general javac approach); or use of the `jdk.internal.javac.source` system property set by the native launcher (but this is only set when `--source` option is used, as far as I know, and javac also typically does not check system properties).
Note that there is JDK-8290563 to improve the text of the javac warning.
-------------
Commit messages:
- 8290561: Coalesce incubator-module warnings for single-file source-code programs
Changes: https://git.openjdk.org/jdk/pull/9607/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=9607&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8290561
Stats: 102 lines in 3 files changed: 100 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/9607.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/9607/head:pull/9607
PR: https://git.openjdk.org/jdk/pull/9607
More information about the compiler-dev
mailing list