JDK-8342071 : Build regression from fix JDK-8266242 on openjdk{17,21} on macOS < 11.00
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17,21
  • Priority: P3
  • Status: New
  • Resolution: Unresolved
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2024-10-08
  • Updated: 2024-10-14
Description
ADDITIONAL SYSTEM INFORMATION :
macOS 10.14.6 18G9323 x86_64
Xcode 11.3.1 11C505
openjdk17, openjdk21

A DESCRIPTION OF THE PROBLEM :
JDK-8266242 fix for openjdk22 support for macOS 11.00 and later introducing build failure regression on earlier openjdk versions that still support building on macOS 10.12 - 10.15.

New if {} clause added to src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m includes identifier not defined in the macOS SDKs prior to version 11.00.

...
static BOOL isValidDisplayMode(CGDisplayModeRef mode) {
    // Workaround for apple bug FB13261205, since it only affects arm based macs
    // and arm support started with macOS 11 ignore the workaround for previous versions
    if (@available(macOS 11, *)) {
        if (architecture == -1) {
            architecture = [[NSRunningApplication currentApplication] executableArchitecture];
        }
        if (architecture == NSBundleExecutableArchitectureARM64) {
            return (CGDisplayModeGetPixelWidth(mode) >= 800);
        }
    }
    return (1 < CGDisplayModeGetWidth(mode) && 1 < CGDisplayModeGetHeight(mode));
}
...

The @availability directive included does not prevent the compiler from checking the enclosed code symbols are defined. Some mechanism/directive is needed to prevent this code section from causing a fatal build error.

REGRESSION : Last worked in version 11.0.24

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
bash configure
make images

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful build
ACTUAL -
...
src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m:69:29: error: use of undeclared identifier 'NSBundleExecutableArchitectureARM64'; did you mean 'NSBundleExecutableArchitecturePPC64'?
        if (architecture == NSBundleExecutableArchitectureARM64) {
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            NSBundleExecutableArchitecturePPC64
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:123:5: note: 'NSBundleExecutableArchitecturePPC64' declared here
    NSBundleExecutableArchitecturePPC64     = 0x01000012
    ^
1 error generated.


CUSTOMER SUBMITTED WORKAROUND :
Can build successfully when #if guard is added to enclose the new code block, viz. (e.g. for openjdk17, almost identical patch applies to openjdk21):

--- src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m.orig	2024-10-08 18:09:38
+++ src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m	2024-10-08 18:09:16
@@ -60,6 +60,9 @@
 }
 
 static BOOL isValidDisplayMode(CGDisplayModeRef mode) {
+    // https://trac.macports.org/ticket/71049: temporary additional guard for undef'd NSBun..ARM64
+    // Should be reported/fixed upstream at openjdk.org.
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
     // Workaround for apple bug FB13261205, since it only affects arm based macs
     // and arm support started with macOS 11 ignore the workaround for previous versions
     if (@available(macOS 11, *)) {
@@ -70,6 +73,7 @@
             return (CGDisplayModeGetPixelWidth(mode) >= 800);
         }
     }
+#endif
     return (1 < CGDisplayModeGetWidth(mode) && 1 < CGDisplayModeGetHeight(mode));
 }
 



FREQUENCY : often



Comments
Needs older Mac version for testing verification.
14-10-2024