How to export a package from a module in a boot layer to module in a child layer.

Ron Pressler ron.pressler at oracle.com
Fri Jan 31 17:54:52 UTC 2025



> On 31 Jan 2025, at 17:33, Code Ranger <coderanger2025 at outlook.com> wrote:
> 
> 
> 
> On 1/31/25 19:23, Ron Pressler wrote:
>> 
>> 
>>> On 31 Jan 2025, at 16:49, Code Ranger <coderanger2025 at outlook.com> wrote:
>>> 
>>> 
>>> 1. we don't have access to the boot layer controller and we received a categorical refusal to grant access to it.
>>> 
>> That is incorrect. The API for controlling modules in the boot layer has been available since JDK 9, using the very mechanism that has been used for precisely this kind of super-powered manipulation for 20 years:
>> 
>> https://docs.oracle.com/en/java/javase/23/docs/api/java.instrument/java/lang/instrument/Instrumentation.html#redefineModule(java.lang.Module,java.util.Set,java.util.Map,java.util.Map,java.util.Set,java.util.Map)
>> 
> Unfortunately, this is correct. 
> 
> I am sure, that if it is necessary to use agent and java instrumentation to make this the simplest configuration work, then it simply means, that something is wrong here. Maybe two many constrains?

Manipulating a module’s access checks at runtime allows you, for example, to redefine the value of 5 in Java to be 6, and that is precisely the job agents are, and have always been, for. Changing the internal rules by which the runtime operates — and modules’ access are at the core of these rules — is the very definition of low-level instrumentation.

Have you encontered a difficulty using this standard approach?


More information about the jigsaw-dev mailing list