RFR: 8269967: JavaFX should fail fast on macOS below minimum version

Johan Vos jvos at openjdk.java.net
Fri Jul 9 13:00:55 UTC 2021


On Tue, 6 Jul 2021 23:54:12 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

> This PR implements a version check in the JavaFX runtime initialization code on macOS to ensure that the platform is running a version of macOS that is at or above the minimum version. If the platform is below the specified minimum, the JavaFX initialization code throws an exception.
> 
> The minimum version is passed from the `mac.gradle` file to the Mac glass code as a pair of build time constants, which are compared at runtime to the platform version.
> 
> Notes to reviewers:
> 
> * In case anyone is interested, the first commit has some debug logging which will print the minimum version and the detected platform version. I removed them with the second commit.

Marked as reviewed by jvos (Reviewer).

> Thanks for the suggestion. I tried it and found that it leads to a less clear exception message. `JNI_OnLoad` is called from `System.loadLibrary`, which turns any exception into an `UnsatisfiedLinkError` without using the message of the caught exception. So instead of a runtime exception with the message `Unsupported macOS version`, we would get something like this:
> 
> ```
> Caused by: java.lang.UnsatisfiedLinkError: no glass in java.library.path:
>     /Users/kcr/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:
>     /System/Library/Java/Extensions:/usr/lib/java:.
> ```
> 
> So I'd prefer to leave it in `initIDs` (although it seems best to move the check up so it's the first thing done in that method).

You are right, the UnsatisfiedLinkError is a bit misleading in this case.

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

PR: https://git.openjdk.java.net/jfx/pull/567


More information about the openjfx-dev mailing list