Replace JNA with JNI for macOS native bridge#375
Open
kdroidFilter wants to merge 1 commit intomasterfrom
Open
Conversation
Migrate all macOS JNA (Java Native Access) bindings to JNI (Java Native Interface) to reduce dependency surface on macOS. JNA remains for Windows/Linux. - Create MacTrayBridge.m: Objective-C JNI bridge (~420 lines) with callback trampolines, GlobalRef lifecycle management, and JAWT support - Create MacNativeBridge.kt: Kotlin JNI binding with auto library loading - Add 7 new Swift @_cdecl functions for dock, space, and mouse APIs - Rewrite MacTrayManager to use opaque Long handles instead of JNA Structures - Rewrite MacOsWindowManager to use native bridge instead of ObjC runtime - Simplify MacOutsideClickWatcher (remove ApplicationServices JNA binding) - Update build.sh to compile ObjC bridge with JNI headers - Delete MacTrayLoader.kt (no longer needed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MacTrayBridge.m) that wraps the existing Swift C API with proper callback trampolines, GlobalRef lifecycle management, and dynamic JAWT resolution.MacTrayManager,MacOsWindowManager,MacOutsideClickWatcher, and related files to use opaqueLonghandles instead of JNAStructureobjects.Changed files
maclib/MacTrayBridge.mMacNativeBridge.ktmaclib/tray.hmaclib/tray.swift@_cdeclfunctions (~80 lines)maclib/build.shMacTrayManager.ktMacOsWindowManager.ktMacOutsideClickWatcher.ktMacOSMenuBarThemeDetector.ktMacNativeBridgeMacTrayInitializer.ktgetNativeTrayStruct()→getNativeTrayHandle()TrayPosition.ktIntByReference→IntArray, usesMacNativeBridgeTrayApp.ktMacNativeBridge.nativeSetMoveToActiveSpace()MacTrayLoader.ktTest plan
cd maclib && sh build.sh— both architectures compilenm -g libMacTray.dylib | grep Java_— all 33 JNI symbols exported./gradlew compileKotlinJvm— no compilation errors