Hi.

I'm playing around with layers and I needed the following:
Create a new layer where it doesn't have access to the boot layer using the
ModuleLayer.empty().
However, I'm getting the exception that java.base is not found. So I used
something like this:

ModuleLayer.boot().defineModules(conf, moduleName ->
myNewLayer.find(moduleName).isPresent() ? myClassLoader :
ModuleFinder.ofSystem().find(moduleName).isPresent() ?
ClassLoader.getPlatformClassLoader() : null).

Then I get the following exception: java.lang.LayerInstantiationException:
loader can't be 'null' or the platform class loader.

Why is there this restriction? How is the correct way of only enabling the
base modules to be found to the next layer and not the unnamed module.

Thanks!

Reply via email to