Inconsistency with service loading by layer or by class loader
Ron Pressler
ron.pressler at oracle.com
Sun Dec 15 14:55:12 UTC 2024
> On 14 Dec 2024, at 17:10, David Lloyd <david.lloyd at redhat.com> wrote:
>
>
> For modules, we face the same issue. I can, for example, create a single application layer with a thousand modules in it. Before the application can start, every JAR has to be opened and every module has to be loaded, which entails parsing or dynamically creating descriptors (generally a combination of these things), each with dozens of support objects for things like dependencies, exports, and services, and then their internal graphs have to be resolved and wired and checked for consistency. So there is a significant performance cost there. But, that is not the only problem. A user application is often a combination of many modules in addition to our own basic modules, plus a significant amount of generated code. The resultant module graph might even have internal consistency problems (for example, having multiple versions of a module, or cyclical dependencies) that can't realistically be resolved socially because many of these modules are going to be from third parties that we may or may not have any control over, and might even be dependencies brought in by the user which we know nothing about. These graphs could be the result of very complex resolution of Maven artifacts for example.
I’m having a hard time understanding the scenario described here, especially when it comes to who loads what and how, and what goes into named or unnamed modules (as it’s not an all-or-nothing proposition).
Is it the case that by “application” you mean JBoss, hereinafter called “the container”, and by “user application” you mean some web application deployed intto the container?
Does the container load the user application as a service provider?
Does the user application also use its own ServiceLoader with classloader isolation in addition to that employed by the container itself?
If a user application is a single unit constructed by Maven, how can there be version conflicts *within that unit*, and if there are any, how is the author of that unit — the user application — expected to deal with them?
In the (common) case where the user application isn’t itself modular (and possibly contains circular dependencies within its JARs), can’t the container load the user application into the unnamed module of some module layer that the container creates? Why would the user application itself need to be broken up into layers?
— Ron
More information about the jigsaw-dev
mailing list