On Thu, 29 Aug 2024 23:01:08 GMT, Kevin Rushforth <k...@openjdk.org> wrote:
>> Do we want to use cached version for this case? >> `[NSApp isMemberOfClass:[NSApplication class]] && overrideDelegate` > > Hmm. Probably not. We don't really expect that anyone will ever set the > (undocumented) env variable that will set the `overrideDelegate` flag, but it > might be safest to only use the cached env if `[NSApp > isKindOfClass:[NSApplicationAWT class]]`. > > If so, one way to do this would be to change line 129 to: > > > [ThreadUtilities setApplicationOwner:[NSApp > isKindOfClass:[NSApplicationAWT class]]]; > > > Or keep track of a second flag, something like this: > > > BOOL isApplicationOwner = NO; > if (NSApp != nil) { > if ([NSApp isMemberOfClass:[NSApplication class]] && > overrideDelegate) shouldInstall = YES; > if ([NSApp isKindOfClass:[NSApplicationAWT class]]) { > shouldInstall = YES; > isApplicationOwner = YES; > } > } > [ThreadUtilities setApplicationOwner:isApplicationOwner]; Updated PR to cache JNIEnv only for NSApplicationAWT instance ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20688#discussion_r1738101573