RFR: 8334137: Marlin: replace sun.misc.Unsafe memory access methods with FFM

Kevin Rushforth kcr at openjdk.org
Mon Jun 9 22:12:38 UTC 2025


On Mon, 9 Jun 2025 21:38:22 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

> > I'd looked at that but it was not obvious. And it definitely is not obvious that it will be the same thread that initialises the MaskMarlinAlphaConsumer.java class
> 
> Yes, I see what you are saying. The `ALPHA_MASK_XXX` arrays are static fields of `MaskMarlinAlphaConsumer`, and the renderer context class has an instance field of `MaskMarlinAlphaConsumer`. So it does seem possible that `MaskMarlinAlphaConsumer` could be initialized by a thread other than the prism renderer thread. Hmmm.

Fortunately, the presence of following field in RendererConext does not cause the MaskMarlinAlphaConsumer class to be initialized:


    public MaskMarlinAlphaConsumer consumer = null;


I instrumented the code, adding something that _did_ force initialization and was able to provoke a WrongThreadException. Without my modification, MaskMarlinAlphaConsumer doesn't get initialized until rendering.

This seems _very_ fragile, though. At best, presuming we can prove that initialization and access to MaskMarlinAlphaConsumer always happens on the Prism rendering thread, this is an accident waiting to happen.

@bourgesl Do you have any thoughts on this? Using the shared arena is definitely safer, but there might be a performance penalty.

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

PR Comment: https://git.openjdk.org/jfx/pull/1814#issuecomment-2957147725


More information about the openjfx-dev mailing list