On Tue, 20 Oct 2026 21:45:14 GMT, Phil Race <[email protected]> wrote:
> The native code on macOS which initializes cached JNI refs is not thread safe. > The fix is to use the macOS dispatch_once mechanism as a lock. > The fix is essentially all in JNIUtilities.h. There's some refactoring of the > macros in there to make things a bit cleaner > and DECLARE_*_ONLY macros are added which the non-local clients now use to > declare variables. > > The problem can be demonstrated with multi-threaded initialisation, and using > -Xcheck:jni > A case which reproduces "fairly often" has been added as a test. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). This pull request has now been integrated. Changeset: ef2fb394 Author: Phil Race <[email protected]> URL: https://git.openjdk.org/jdk/commit/ef2fb394c25497ffc956880fe7fe8aa49ac2b8a0 Stats: 320 lines in 28 files changed: 160 ins; 37 del; 123 mod 8393035: [macOS] Calling java.awt.Graphics2D::getFontMetrics for the first time concurrently causes a data race Reviewed-by: psadhukhan, kizune ------------- PR: https://git.openjdk.org/jdk/pull/33481
