JNI wrapper for NSSavePanel
Mike Swingler
swingler at apple.com
Sun Oct 7 23:26:31 PDT 2012
On Oct 7, 2012, at 10:44 PM, Steve Hannah <steve at weblite.ca> wrote:
> And one more long-shot: are you compiling your JNI library as ARC, or manual retain/release? I very much doubt that JNF will work correctly with compiler-generated ARC calls...but I could be surprised.
>
> Your long shot was the money shot! ARC was turned on. After disabling it, everything works as it should. Thank you so much for your help. It is quite likely that I would have had to spend a month of Sundays solving this problem if not for your help on this.
Awesome. Something about that raw objc_retain() straight out of the generated Java call was bugging me, and in retrospect I should have recognized it as the blatant preamble/postscript that gets generated around and in functions that are built with ARC.
Suffice it to say, this is fair warning against those who would try to mix JNI and ARC. For now, don't. Just stick with MRR.
Perhaps the JNF functions and macros could be sufficiently decorated with clang attributes to avoid this kind of problem, but I'd have to really think through the edge cases of how ARC interacts with the JNF autorelease pool management to be sure we got it right. If this is actually of any interest to anyone out there in the real world, please feel free to file a bug at <http://bugreporter.apple.com> - though, if using MRR is good enough, maybe it's just good enough.
Always happy to help,
Mike Swingler
Apple Inc.
More information about the macosx-port-dev
mailing list