JNI wrapper for NSSavePanel
Steve Hannah
steve at weblite.ca
Sat Oct 6 17:05:49 PDT 2012
On Sat, Oct 6, 2012 at 4:06 PM, Mike Swingler <swingler at apple.com> wrote:
> 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.
>
Thanks. I planned to make that change once I got JNF_COCOA_ENTER/EXIT
working.
>
> 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?
>
I do, but I'm having difficulty making heads or tails from it. I'm also
struggling with getting logging information out on the Java side as I'm
working on a Mountain Lion machine and I can't find where System.out and
System.err are logged by default... and the sandbox is making it difficult
for me to set a log location manually... (anything that runs or fails
before or during the setting of a custom log location is not logged).
>
> Also, are you doing anything special to run this JNI method on the main
> AppKit thread (or are you using SWT)?
Ah.. I hadn't thought of that, but yes. I'm overriding the
java.awt.FileDialog class's setVisible() method to display this as a modal
dialog.
> 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.
>
I'll give this a shot.
Thanks for the suggestions.
Best regards
Steve
>
> Just a few thoughts,
> Mike Swingler
> Apple Inc.
>
>
--
Steve Hannah
Web Lite Solutions Corp.
More information about the macosx-port-dev
mailing list