From f7d6d7a04faa704155ee8df33e7d344bb962566f Mon Sep 17 00:00:00 2001 From: Alexander Zuev Date: Fri, 13 Oct 2023 22:53:21 +0000 Subject: [PATCH] 8266242: java/awt/GraphicsDevice/CheckDisplayModes.java failing on macOS 11 ARM Reviewed-by: prr, azvegint, aivanov --- .../native/libawt_lwawt/awt/CGraphicsDevice.m | 15 +++++++++++++-- test/jdk/ProblemList.txt | 1 - 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m index a93bfcb58c4..468c5f6dae0 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ #define DEFAULT_DEVICE_HEIGHT 768 #define DEFAULT_DEVICE_DPI 72 +static NSInteger architecture = -1; /* * Convert the mode string to the more convenient bits per pixel value */ @@ -58,7 +59,17 @@ static int getBPPFromModeString(CFStringRef mode) return 0; } -static BOOL isValidDisplayMode(CGDisplayModeRef mode){ +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)); } diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 6639684fead..c01f52d3056 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -462,7 +462,6 @@ java/awt/KeyboardFocusmanager/TypeAhead/MenuItemActivatedTest/MenuItemActivatedT java/awt/Window/GetScreenLocation/GetScreenLocationTest.java 8225787 linux-x64 java/awt/Dialog/MakeWindowAlwaysOnTop/MakeWindowAlwaysOnTop.java 8266243 macosx-aarch64 java/awt/dnd/BadSerializationTest/BadSerializationTest.java 8277817 linux-x64,windows-x64 -java/awt/GraphicsDevice/CheckDisplayModes.java 8266242 macosx-aarch64 java/awt/GraphicsDevice/DisplayModes/UnknownRefrshRateTest.java 8286436 macosx-aarch64 java/awt/image/multiresolution/MultiresolutionIconTest.java 8291979 linux-x64,windows-all java/awt/event/SequencedEvent/MultipleContextsFunctionalTest.java 8305061 macosx-x64