Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NavServices via JNI from 1.4.1?



I want to be able to use the Carbon NavServices API via JNI from Java 1.4.1. Is this likely to work?

I have had two related experiences, one positive, one negative.

1) In a Java-based app, I have been able to use NavServices via JNI with Java 1.3.1 to display custom Open or Save dialogs and thus make full use of all the options that are available through the Carbon API. The key to success in this case seemed to be to use CarbonLock and to use an event loop timer procedure to make sure that the dialog was running on the correct thread [See archives]. (Getting this working also allowed me to debug my use of the NavServices API itself; the API is fairly ugly by modern standards.)

2) I've been converting my app to be Cocoa-Java based. Unfortunately, the Cocoa classes NSOpenPanel and NSSavePanel do not provide all the hooks I need. So here again I needed to use the Carbon API, but this time my attempt failed. The archives suggest overriding NSApplication.sendEvent, and posting an ApplicationDefined event to make sure that the UI work is done on the correct thread. (This is the equivalent of the event loop timer trick for Carbon, right?) I did this. As a test case, I made a simple call to StandardAlert() in my JNI code, and that works fine. But when I replace the alert call with my NavServices code, it fails. (The NavServices dialog runs OK; after it is dismissed, it flashes on again in a strange brief reappearance when NavDialogDispose is called, and then the app crashes with the "application has unexpectedly quit" alert.) I'm using OS X 10.2.3, so in theory there should be no problem with having a Carbon window in a Cocoa app. I've spent a couple of days trying to debug this; it still happens even when I've stripped out a lot of code that could potentially contain a bug (for example, I tried commenting out all the code that frees up memory structures after the dialog is dismissed, in case I made a mistake there).

If anyone has successfully used the NavServices API via JNI in either Java 1.4.1 or Cocoa-Java, I'd love to hear about it.

My Cocoa-Java app uses Java 1.3.1, so if anyone has a theoretical justification for why this might be bad to use with NavServices & JNI, I'd like to learn that, too.

Thanks,
Michael

_____________________________
Quadrivio Corporation
1563 Solano Avenue PMB 360
Berkeley, CA 94707
http://www.quadrivio.com
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.