Re: Associating Objective-C objects with Java objects using JNI
Re: Associating Objective-C objects with Java objects using JNI
- Subject: Re: Associating Objective-C objects with Java objects using JNI
- From: Scott Ribe <email@hidden>
- Date: Fri, 08 May 2009 08:03:08 -0600
- Thread-topic: Associating Objective-C objects with Java objects using JNI
It can certainly be done; I did something exactly analogous ~7 years ago for
C++ & Carbon. Basically, you can use the JNI to instantiate a Java runtime
instance within your program, then use JNI to call through to Java object
instances. Backing out a bit, you can create your own proxy classes whose
instances hold a reference to a Java object, and have methods that mirror
those of the Java object, and just delegate to the Java object via the JNI.
Backing out one more step, you can use reflection to automatically generate
a wrapper class for any Java class. Backing out one more step, for a given
Javan class, you can generate wrapper classes for any Java class returned by
or taken as an argument by a method of that class, recursively. As for
memory management, your proxies would be reference-counted like normal
Objective-C instances, and on dealloc they would release their Java delegate
objects.
There's some work involved, that's for sure. But it's really not all that
complicated. One suggestion specific to your stated plan: forget any special
annotations for methods, just generate methods in the Objective-C proxy for
all methods in the Java class.
--
Scott Ribe
email@hidden
http://www.killerbytes.com/
(303) 722-0567 voice
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden