JNI wrapper for NSSavePanel
Mike Swingler
swingler at apple.com
Sat Oct 6 16:06:26 PDT 2012
On Oct 6, 2012, at 3:11 PM, Michael Hall <mik3hall at gmail.com> wrote:
> On Oct 6, 2012, at 4:08 PM, Steve Hannah wrote:
>
>> I have posted source for both versions of the method at
>> https://gist.github.com/3846116.
>
> How about throwing a retain on path and see if it makes a difference?
The "path" is not an Obj-C object, it's a JNI jstring pointer, you can't retain it.
I'd actually recommend using JNFNSToJavaString(), instead of manually fetching out the UTF8String and then using the raw JNI.
JNF_COCOA_ENTER/EXIT do more than just setup an autorelease pool - they also catch ObjC exceptions and re-throw them as Java runtime exceptions.
Do you have the backtrace of where you are crashing when using JNF_COCOA_ENTER/EXIT?
Also, are you doing anything special to run this JNI method on the main AppKit thread (or are you using SWT)? If not, you may want to use +[JNFRunLoop performOnMainThreadWaiting:withBlock:], which will block the current thread, run your block on the main thread (safe for AppKit), and then continue execution of your Java thread when the block returns.
Just a few thoughts,
Mike Swingler
Apple Inc.
More information about the macosx-port-dev
mailing list