Enable native access for modules not in the boot layer

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Jun 6 21:03:48 UTC 2022


Hi Johannes,
I think this is a direction we wanted to explore, but we didn't have 
time to (but it's something we will have to look into before the API is 
finalized).

The approach you propose is similar to some ideas I've exchanged with 
Chris and others few months ago, and I agree that it would be useful to 
support something like that, for dynamic loading of modules.

One note: I believe your code will have better chances in 19, since now 
lack of --enable-native-access will only result in a warning, not an 
error. That should give some of the currently unsupported use cases some 
way to get up and running, while we add support for 
--enable-native-access to all the corresponding areas.

Thanks
Maurizio

On 06/06/2022 12:53, Johannes Kuhn wrote:
> In a short discussion with Jorn Vernee I asked how to enable native 
> access for modules not present in the boot layer, and got this answer:
>
> > I don't think we have an API for doing that at the moment. But, I 
> didn't really work on this part. If you have a small reproducer, 
> please send it into panama-dev at openjdk.java.net
>
> Reproducer: https://github.com/DasBrain/PanamaRuntimeModule
>
> I sincerely believe that this is not an unreasonable requirement.
> But we can argue over that :)
>
> ----
>
> After looking a bit deeper into how native access is implemented, I 
> also came up with a prototype:
>
> https://github.com/openjdk/jdk/pull/9040/files
>
> It adds a `Module.enableNativeAccess()` method. That method is itself 
> restricted - and can be used to "delegate" a module's own native 
> access to an other module, similar to how `Module.addOpens` works.
>
> I also added `boolean Module.isNativeAccessEnabled()` - which was 
> previously only visible through the shared secrets - but when exposing 
> the enable part, then exposing the check part also makes sense IMHO.
>
> ----
>
> I would be happy to hear your opinions and suggestions on that topic.
> Things doesn't have to be implemented that way. It's just a suggestion 
> (where I am sure that it does at least work _technically_).
>
> - Johannes


More information about the panama-dev mailing list