RFR: 8290561: Coalesce incubator-module warnings for single-file source-code programs

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Sep 5 08:50:46 UTC 2022

On Fri, 22 Jul 2022 06:58:03 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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.

Looks good!


Marked as reviewed by mcimadamore (Reviewer).

PR: https://git.openjdk.org/jdk/pull/9607

More information about the compiler-dev mailing list