Adding modules from a child layer

Simone Bordet simone.bordet at gmail.com
Fri Mar 14 12:10:02 UTC 2025


Hi Alan,

On Fri, Mar 14, 2025 at 12:23 PM Alan Bateman <alan.bateman at oracle.com> wrote:
> In this case, the initial module is a named module that doesn't transitively require java.instrument so that module is not in the boot layer. If they server was started with -javaagent then the java.instrument would be in the boot layer.  In JEP 261 the recommendation for container apps, like this one, is to run with --add-module ALL-DEFAULT and it will ensure that any module in the run-time that exports an API will be in the boot layer.

Thanks, trying ALL-DEFAULT, in conjunction with ALL-MODULE-PATH.

> A comment in passing is that it's surprising that there are modules in ee$N layers requiring java.instrument. The classes in this modules aren't normally used by libraries and applications, instead they work as the side channel for agents.

With some archeology, I found:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347110 :)

TLDR: Spring had (has?) a mechanism to instrument loaded class, I
assume for dependency injection.
The Spring agent requires custom class loaders to have an
`addTransformer(ClassFileTransformer)` method, hence the dependency of
Jetty's WebAppClassLoader to java.instrument.

Thanks!
-- 
Simone Bordet
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz


More information about the jigsaw-dev mailing list