<AWT Dev> RFR: 8256465: [macos11] Java frame and dialog presented full screen freeze application [v3]

Kevin Rushforth kcr at openjdk.java.net
Thu May 13 21:41:37 UTC 2021

On Thu, 13 May 2021 20:46:28 GMT, Phil Race <prr at openjdk.org> wrote:

>> Tejpal Rebari has updated the pull request incrementally with one additional commit since the last revision:
>>   code cleanup
> src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m line 1106:
>> 1104: {
>> 1105:     JNI_COCOA_ENTER(env);
>> 1106:     if (@available(macOS 10.12, *)) {
> @kevinrushforth said that since we set MIN_SDK (not sure of the exact variable name) to 10.12, that this is compiled down to a no-op .. which means it is useless and doesn't protect you from making the call on 10.11
> So you might as well remove it. It won't prevent the crash that will happen on 10.11.
> @mrserb also pointed out people might then copy this pattern not realising it does not work, and there's a better way ... apparently ...

Right. @johanvos discovered this fun fact about `@available` when he got a crash report from a user. He filed [JDK-8266743](https://bugs.openjdk.java.net/browse/JDK-8266743), which describes this problem.

The setting of minimum version of macOS is controlled by the `-mmacosx-version-min` compile and link flag. The minimum version is defined in [make/autoconf/flags.m4](https://github.com/openjdk/jdk/blob/master/make/autoconf/flags.m4#L136) and used in [make/autoconf/flags-cflags.m4](https://github.com/openjdk/jdk/blob/master/make/autoconf/flags-cflags.m4#L555).

One thing I don't know (and can't try, since I don't have access to a macOS system that old) is whether the JDK will fail somewhere else anyway (e.g., if they check for a minimum OS at start up). So this might be a moot point, but as it stands, I think @mrserb is right that we should avoid this pattern. I would probably just remove it, but you could decide to use something like `respondsToSelector` (which is what I think Sergey was suggesting).


PR: https://git.openjdk.java.net/jdk/pull/3407

More information about the awt-dev mailing list