Can a parent layer use a child layer?

Kasper Nielsen kasperni at gmail.com
Sun Oct 27 09:24:42 UTC 2024


Kasper Nielsen

14:54 (0 minutes ago)
to PavelTurk
Hi Pavel,

Do you really need to use layers here. Can't you simply just export
the needed classes from engine to car?

module engine {
   exports com.engine.api to car;
   exports com.engine.internal to car;
}

module car { requires engine; }

/Kasper

On Sat, 26 Oct 2024 at 22:47, PavelTurk <pavelturk2000 at gmail.com> wrote:
>
> Hello.
>
> I'm developing a multi-layered JPMS application. Let's say that in the boot layer, I have a car component (composed of several jars)
> that includes an engine (also made up of several jars). All child layers will interact with the car, but they should not have any access
> to the engine or its jars (classes). To achieve this, I want to place all jars related to the engine in a child layer, thereby hiding these
> jars and their classes from other child layers.
>
> However, I’m concerned that this setup results in the boot layer depending on a child layer, which seems to go against JPMS principles,
> where typically child layers depend on or use parent layers.
>
> My question is: does placing the engine in a child layer violate JPMS principles, and what would be the best approach in this situation?
>
> Best regards, Pavel


More information about the jigsaw-dev mailing list