Skip to content

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

Draft
HeikoKlare wants to merge 1 commit intoeclipse-platform:masterfrom
HeikoKlare:cleanup/remove-pre-macos11-workarounds
Draft

[Cocoa] Remove code only relevant for macOS < 11.0#3195
HeikoKlare wants to merge 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

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).
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

Test Results (macos)

   54 files  ±0     54 suites  ±0   6m 25s ⏱️ - 2m 50s
4 531 tests ±0  4 287 ✅ ±0  244 💤 ±0  0 ❌ ±0 
2 130 runs  ±0  2 068 ✅ ±0   62 💤 ±0  0 ❌ ±0 

Results for commit 5dad2fa. ± Comparison against base commit d820f7e.

@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.

Comment on lines +946 to +947
if (OS.VERSION < OS.VERSION (11, 0, 0)) {
System.out.println ("***WARNING: SWT requires macOS version 11.0 or greater"); //$NON-NLS-1$
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be included into

since this change becomes strictly necessary with that change.
I've updated that PR already and slightly adjusted the error message to the nowadays typing of the os name.

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