• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Associating Objective-C objects with Java objects using JNI
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Thu, 07 May 2009 22:42:53 -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

References: 
 >Associating Objective-C objects with Java objects using JNI (From: Kelvin Chung <email@hidden>)

  • Prev by Date: Re: NSXMLParser frees itself on error?
  • Next by Date: Outrunning the Garbage Collector
  • Previous by thread: Associating Objective-C objects with Java objects using JNI
  • Next by thread: Re: Associating Objective-C objects with Java objects using JNI
  • Index(es):
    • Date
    • Thread