Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8269967: JavaFX should fail fast on macOS below minimum version
Reviewed-by: jvos, arapte
  • Loading branch information
kevinrushforth committed Jul 13, 2021
1 parent 0c98d96 commit 00b353e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
8 changes: 7 additions & 1 deletion buildSrc/mac.gradle
Expand Up @@ -59,6 +59,10 @@ def isAarch64 = TARGET_ARCH == "aarch64" || TARGET_ARCH == "arm64";
def macOSMinVersion = isAarch64 ? "11.0" : "10.10";
defineProperty("MACOSX_MIN_VERSION", macOSMinVersion);

def macOSMinVersionArr = macOSMinVersion.split("\\.")
def macOSMinVersionMajor = macOSMinVersionArr[0]
def macOSMinVersionMinor = macOSMinVersionArr[1]

// Create $buildDir/mac_tools.properties file and load props from it
setupTools("mac_tools",
{ propFile ->
Expand Down Expand Up @@ -178,7 +182,9 @@ MAC.glass.javahInclude = [
"com/sun/glass/ui/mac/*"]
MAC.glass.nativeSource = file("${project("graphics").projectDir}/src/main/native-glass/mac")
MAC.glass.compiler = compiler
MAC.glass.ccFlags = [ccFlags].flatten()
MAC.glass.ccFlags = [ccFlags,
"-DMACOS_MIN_VERSION_MAJOR=$macOSMinVersionMajor",
"-DMACOS_MIN_VERSION_MINOR=$macOSMinVersionMinor"].flatten()
MAC.glass.linker = linker
MAC.glass.linkFlags = [linkFlags].flatten()
MAC.glass.lib = "glass"
Expand Down
Expand Up @@ -793,6 +793,34 @@ + (BOOL)syncRenderingDisabled {
{
LOG("Java_com_sun_glass_ui_mac_MacApplication__1initIDs");

// Check minimum OS version
NSOperatingSystemVersion osVer;
osVer = [[NSProcessInfo processInfo] operatingSystemVersion];
NSInteger osVerMajor = osVer.majorVersion;
NSInteger osVerMinor = osVer.minorVersion;

// Map 10.16 to 11.0, since macOS will return 10.16 by default (for compatibility)
if (osVerMajor == 10 && osVerMinor >= 16) {
// FIXME: if we ever need to know which minor version of macOS 11.x we
// are running on, we will need to look it up using a similar technique
// to what the JDK does.
osVerMajor = 11;
osVerMinor = 0;
}

if (osVerMajor < MACOS_MIN_VERSION_MAJOR ||
(osVerMajor == MACOS_MIN_VERSION_MAJOR &&
osVerMinor < MACOS_MIN_VERSION_MINOR))
{
NSLog(@"ERROR: macOS version is %d.%d, which is below the minimum of %d.%d",
(int)osVerMajor, (int)osVerMinor, MACOS_MIN_VERSION_MAJOR, MACOS_MIN_VERSION_MINOR);
jclass exceptionClass = (*env)->FindClass(env, "java/lang/RuntimeException");
if (exceptionClass != 0) {
(*env)->ThrowNew(env, exceptionClass, "Unsupported macOS version");
}
return;
}

disableSyncRendering = jDisableSyncRendering ? YES : NO;

jApplicationClass = (*env)->NewGlobalRef(env, jClass);
Expand Down

1 comment on commit 00b353e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.