On Mon, 9 Sep 2024 12:57:17 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

> The new test added by https://github.com/openjdk/jdk/pull/20854 fails 
> spuriously.
> While JNI lookup is now moved into the static initializer of the 
> `MappedMemoryUtils` class, this class might only get initialized while in the 
> middle of a scoped context.
> 
> To address this, I created a new proxy interface, namely 
> `MappedMemoryUtilsProxy`. This interface is used by `ScopedMemoryAccess` to 
> call the various `force`/`load`/`isLoaded`/`unload` methods, and a singleton 
> instance is provided inside `MappedMemoryUtils` itself, and then exposed via 
> the `SharedSecrets` mechanism.
> 
> Crucially, `MappedMemorySegmentImpl` will now _first_ obtain a 
> `MappedMemoryUtilsProxy` and _then_ call `ScopedMemoryAccess`. This should 
> move all class initializer side-effects out of the scoped method context.

src/java.base/share/classes/jdk/internal/access/foreign/MappedMemoryUtilsProxy.java
 line 9:

> 7:  * This allows to avoid pesky initialization issues in the middle of 
> memory mapped scoped methods.
> 8:  */
> 9: public interface MappedMemoryUtilsProxy {

We should probably try to consolidate this and `UmapperProxy` - I think it can 
be done, but it requires deeper surgery than I was willing to do in this PR.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20914#discussion_r1750215021

Reply via email to