Re: Can Pure Java and Cocoa Java get along???
Re: Can Pure Java and Cocoa Java get along???
- Subject: Re: Can Pure Java and Cocoa Java get along???
- From: Chris Backas <email@hidden>
- Date: Sun, 07 Sep 2003 19:31:49 -0400 (EDT)
- Priority: Normal
Hi James,
Yes, you can write Cocoa applications in Java alone, the amount of the API that's bridged is pretty huge. Sometimes you can run into trouble because functions in ObjC are bundled together and bunched into an
Object on the Java side that didn't exist on the ObjC side, but it's not too hard to track those things down. There are methods available in ObjC that aren't available in Java still though. Most tend to be on the
obscure side, but when they're not I write a helper class in ObjC and bridge it myself.
One huge gotcha that isn't real obvious though has to do with the garbage collector. Basically, you cannot let the ObjC side of things have a reference to any object that might be Garbage Collected; a reference on
the ObjC side of the bridge is *not* enough to prevent the GC from deleting the object, which will cause crashes if Cocoa tries to use it later.
So if you call an API and have to pass it some object, doing something like this:
CocoaObject.SomeMethod(new MyData());
Is bad in most cases. You need to assign the MyData instance to something that will exist for as long as the API is likely to need that object.
Hope this helps =)
Chris Backas
>
Hey all, I'm fairly new to the whole Cocoa Java thing, so I have a newbie
>
type question. Can I use Pure Java classes along side with Cocoa Java
>
classes? My main reason is this. I like Interface Builder. In fact,
>
coming from a Pure Java background and fighting to make nice looking
>
interfaces, I really really love Interface Builder. So can I create a
>
normal Cocoa-Java app, using the com.apple.cocoa.application and framework
>
packages, along with other ones? My guess is yes, but I'd like some
>
verification. If I could continue to work with Java (I'm still learning
>
C/C++/Objective-C because they are languages I should know), and kiss Swing
>
goodbye, that would be perfect. I know that going that route straps me to
>
Mac only applications, but I'm willing to deal with that, since I'm not a
>
fan of Windows anyway. Thanks for listening to my rant. Later...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.