Mailing Lists: Apple Mailing Lists

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

Re: JNI types and usage newbie



that's what i was afraid of....

thanks,
ken;

On Apr 29, 2004, at 6:57 PM, Greg Guerin wrote:

Ken Hawkins <email@hidden> wrote:

can anyone point me toward a good sight that describes JNi types and
how to use them, in particular jobject. for example...

You can't cast or otherwise convert a jobject to or from anything. A
jobject is an opaque reference. You can't copy anything into or out of a
jobject except by making calls on it via the JNIEnv. That's the nature of
opaque references. The only things that aren't opaque in JNI are the
primitive types. Everything else, include arrays of primitive types, is
opaque.

I recommend the "JNI Programmer's Guide & Specification" (full book
available on-line in HTML and PDF):
<http://java.sun.com/docs/books/jni/>

It is the definitive reference. It could use some improvement in a few
examples, but is otherwise quite clear and concise.


i have an NSArray coming back from a native cocoa call and i am not
sure how i would cast that( er copy that) into a jobject. or is it a
jobjectArray? as well how to get items out of it once it is in a
relating jobject / jobjectArray...

As Dmitry showed, you have to manually munge all the references and values
to and fro. You can't cast a jobject to or from anything in ObjC (or in C,
for that matter), because it's opaque.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: JNI types and usage newbie (From: Greg Guerin <email@hidden>)



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.