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).

src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m line 49:

> 47: DECLARE_CLASS_ONLY(sjc_CPrinterDialog)
> 48: DECLARE_CLASS_ONLY(sjm_getNSPrintInfo)
> 49: DECLARE_CLASS_ONLY(sjm_printerJob)

Should it be DECLARE_CLASS_ONLY for sjm_getNSPrintInfo and sjm_printerJob?
Shouldn't it be DECLARE_METHOD_ONLY(sjm_getNSPrintInfo) and 
DECLARE_METHOD_ONLY(sjm_printerJob)?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33481#discussion_r4441170672

Reply via email to