Skip to content

[Cocoa] Remove code only relevant for macOS < 11.0#3195

Merged
HeikoKlare merged 1 commit intoeclipse-platform:masterfrom
HeikoKlare:cleanup/remove-pre-macos11-workarounds
Apr 10, 2026
Merged

[Cocoa] Remove code only relevant for macOS < 11.0#3195
HeikoKlare merged 1 commit intoeclipse-platform:masterfrom
HeikoKlare:cleanup/remove-pre-macos11-workarounds

Conversation

@HeikoKlare
Copy link
Copy Markdown
Contributor

Summary

This PR removes code from the macOS/Cocoa-specific SWT classes that was only needed for macOS versions older than 11.0 (Big Sur).

Important

This PR must not be merged before #3185, which bumps the minimum supported macOS version for SWT to 11.0 and is the prerequisite for this cleanup.

Motivation

Once the minimum supported macOS version is raised to 11.0, all conditional code paths guarded by version checks like OS.VERSION < OS.VERSION(10, x, 0) or OS.isBigSurOrLater() become either dead code (always-false branches) or unconditional code (always-true branches). This PR cleans up all such cases to simplify the codebase.

How the Changes Were Found

The cocoa-specific Java source directories were scanned for:

  • OS.VERSION comparisons (e.g., OS.VERSION < OS.VERSION(10, 13, 0), OS.VERSION >= OS.VERSION(10, 14, 0))
  • OS.isBigSurOrLater() calls

For each occurrence, the logic was evaluated assuming macOS >= 11.0 is always true:

  • Always-false branches (e.g., if (OS.VERSION < OS.VERSION(10, x, 0)) for any x ≤ 16) — the entire conditional block was removed.
  • Always-true branches (e.g., if (OS.VERSION >= OS.VERSION(10, x, 0)) for any x ≤ 16, or if (OS.isBigSurOrLater())) — the condition was removed and the body was kept unconditionally.
  • Ternary expressions — simplified to the always-true value.

Cascading removals were also applied: after simplifying call sites, methods and constants that became unused (e.g., OS.isBigSurOrLater(), kAlertNoteIcon, kAlertCautionIcon, SHADOWED_IBEAM_SOURCE) were deleted as well.

Changes per File

File Change
Control.java Removed macOS 10.13 (High Sierra) graphics context save/restore workaround in print(); kept only the modern rendering path
FileDialog.java overwrite field is now always true; removed 10.11 version check around setAccessoryViewDisclosed; simplified setOverwrite() to always set true
Spinner.java Removed findCursor() override that only existed to work around a nearly-invisible I-Beam cursor on dark backgrounds before macOS 10.14
Text.java Same I-Beam cursor workaround removed
Combo.java Same I-Beam cursor workaround removed
Cursor.java Removed SHADOWED_IBEAM_SOURCE pixel data constant and the pre-10.14 I-Beam cursor workaround; SWT.CURSOR_IBEAM now always uses NSCursor.IBeamCursor()
Tree.java Removed pre-10.11 header rect adjustment; removed >= 10.11 guards on header offset code (now always applied); removed >= 10.15 guard on scrollRowToVisible fix; removed isBigSurOrLater guards on setStyle and highlight rendering
Table.java Same pattern as Tree.java
Shell.java Removed >= 10.12 guard on automatic window tabbing disable; removed isBigSurOrLater guard on cancelRootMenuTracking; changed else if (>= 10.11) to unconditional else for child window z-order workaround
Display.java Updated minimum version check from 10.10 to 11.0; simplified shadow/background color getters (removed >= 10.14 conditionals); removed >= 10.14 early returns in setAppAppearance/setWindowsAppearance; removed !isBigSurOrLater guard on layer backing; simplified icon loading to always use modern NSImageName* APIs
OS.java Removed if (>= 10.14) guards in isAppDarkAppearance() and isSystemDarkAppearance(); removed now-unused isBigSurOrLater() method; removed unused kAlertNoteIcon and kAlertCautionIcon constants
TextLayout.java Removed >= 10.11 guard on sel_attachment method registration
MessageBox.java Removed isBigSurOrLater conditionals; always uses modern NSImageNameInfo/NSImageNameCaution
List.java Removed isBigSurOrLater guard on NSTableViewStylePlain style setting
TabItem.java Always uses selectedControlTextColor (was a ternary on isBigSurOrLater)
TreeItem.java Always adds TEXT_GAP for text width calculation (was guarded by isBigSurOrLater)

Notes

  • No behavior change is intended for any macOS version >= 11.0 — this is a pure cleanup.
  • The OS.VERSION field and OS.VERSION(major, minor, bugfix) helper remain, as they may still be useful for future version-specific code.

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

Test Results (macos)

   54 files  +   27     54 suites  +27   7m 7s ⏱️ + 4m 7s
4 531 tests ±    0  4 287 ✅ ±    0  244 💤 ± 0  0 ❌ ±0 
2 130 runs  +1 065  2 068 ✅ +1 034   62 💤 +31  0 ❌ ±0 

Results for commit 0925dc8. ± Comparison against base commit 596bef6.

♻️ This comment has been updated with latest results.

@vogella
Copy link
Copy Markdown
Contributor

vogella commented Apr 4, 2026

Nice one. Good to see that Claude is useful to you and our Eclipse project to improve the code base.

Copy link
Copy Markdown
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

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

That's a nice clean-up.
After a quick-search it seems like the removal affects all version checks and now API introduced in macOS 11 or later is used.

@HannesWell HannesWell force-pushed the cleanup/remove-pre-macos11-workarounds branch from 5dad2fa to da34902 Compare April 8, 2026 16:11
@HannesWell HannesWell marked this pull request as ready for review April 8, 2026 16:37
Following the bump of the minimum supported macOS version to 11.0
(see eclipse-platform#3185),
this removes all code paths that were only needed for older macOS
versions.

The search was performed by scanning all Java files in the
cocoa-specific
directories for OS.VERSION comparisons and isBigSurOrLater() calls, then
removing branches that are now always-false (< some version < 11.0) or
inlining branches that are now always-true (>= some version <= 11.0).
@HeikoKlare HeikoKlare force-pushed the cleanup/remove-pre-macos11-workarounds branch from da34902 to 0925dc8 Compare April 9, 2026 15:48
@HeikoKlare HeikoKlare merged commit c83ed3c into eclipse-platform:master Apr 10, 2026
23 of 25 checks passed
@HeikoKlare HeikoKlare deleted the cleanup/remove-pre-macos11-workarounds branch April 10, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants