[lworld] RFR: 8372515: [lworld] Plumb in javac flags for compiling with preview mode [v2]

Jan Lahoda jlahoda at openjdk.org
Wed Dec 10 10:18:18 UTC 2025


On Wed, 10 Dec 2025 10:11:20 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java line 819:
>> 
>>> 817: 
>>> 818:     MULTIRELEASE("--multi-release", "opt.arg.multi-release", "opt.multi-release", HIDDEN, FILEMANAGER),
>>> 819:     PREVIEWMODE("--preview-mode", "opt.arg.preview-mode", "opt.preview-mode", HIDDEN, FILEMANAGER),
>> 
>> I'm not 100% sure as to why we're adding a new preview option here -- javac already has `--enable-preview` -- what is the new option for? Seems to be only used by the file manager. Can't the file manager use `--enable-preview` ? @david-beaumont  or @lahodaj  please clarify
>
> OK, I see -- this is an "hidden" option, just used internally by javac to communicate to the file manager whether preview mode should be enabled or not. I now see the same pattern being used as that for multirelease jars.

Yes - we need a separate option, as (AFAIK) the current framework does not allow options to be used both for and outside of file managers.

We more or less need to send the preview mode using an option/`handleOption`, as the file manager may be a file manager provided by the user, and only delegate to `JavacFileManager`. That's the same reason why `--multi-release` is used for file managers.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1761#discussion_r2606029197


More information about the valhalla-dev mailing list