[code-reflection] RFR: Regression: compiler SPI does not work with exploded build

Paul Sandoz psandoz at openjdk.org
Thu Nov 21 23:21:32 UTC 2024


On Thu, 21 Nov 2024 21:55:58 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> The recent refactoring from compiler plugin to simple SPI introduced a regression.
> With compiler plugins, the code-reflection extension was effectively loaded in two steps:
> * if the code reflection module was not available in the boot layer, then an attempt was made to load it from a fresh layer created on the fly
> * otherwise, plugins were searched in the boot layer (like for any other regular plugin)
> 
> When running in exploded mode, incubating modules are part of the boot layer, so they are loaded normally (w/o the need of an extra layer).
> Unfortunately, the recent refactoring from plugin to SPI removed the second kind of lookup, meaning that now javac will no longer look for an extension in the boot layer.
> 
> The solution is simple: javac should look in the fresh layer if it has created one (meaning the incubating module is not part of the boot layer); otherwise, it should just look for the extension in the boot layer.

To be on the safe side should we do it like the following?

            if (ModuleLayer.boot().findModule("jdk.incubator.code").isPresent()) {
                CODE_LAYER = ModuleLayer.boot();
            } else if (java.lang.module.ModuleFinder.ofSystem().find("jdk.incubator.code").isPresent()) {
            ...
            } else {
                // if we run javac in bootstrap mode, there might be no jdk.incubator.code
                CODE_LAYER = null;
            }

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

PR Comment: https://git.openjdk.org/babylon/pull/278#issuecomment-2492548919


More information about the babylon-dev mailing list