Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JNI: arrays inside objects

Reply
Thread Tools

JNI: arrays inside objects

 
 
hash.q
Guest
Posts: n/a
 
      10-21-2008
Hello,

I am calling a native function from Java passing an object that
contains an array of strings.

In C , I would like to change this array and return it back to java,
how do i do this?
I have read sun's documentation, but they never talk about this. any
help would be appreciated.

thanks,
Hashim.
 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      10-22-2008
On Tue, 21 Oct 2008 15:10:14 -0700 (PDT), hash.q wrote:
> I am calling a native function from Java passing an object that
> contains an array of strings.
>
> In C , I would like to change this array and return it back to java,
> how do i do this? I have read sun's documentation, but they never
> talk about this. any help would be appreciated.


Of course the documentation does not describe every possible scenario,
but you just need to understand how to manipulate objects.

The general mechanism goes like this:

- get the class from the object passed to your method (GetObjectClass)
- get the field id of the String array from the class (GetFieldID)

If you mean you want to change the contents of the String array:

- with the field id and the object, get the array itself (GetObjectField)
- do what you want with the array elements using various array
functions (Get/SetObjectArrayElement, NewStringUTF, etc).

If you mean that you want to replace the array in the object:

- create the replacement array (NewObjectArray, NewStringUTF etc)
- assign the new array to the field in the object (SetObjectField)

/gordon

--
 
Reply With Quote
 
 
 
 
asiandollno1@gmail.com
Guest
Posts: n/a
 
      10-22-2008
On Oct 22, 6:10*am, "hash.q" <(E-Mail Removed)> wrote:
> Hello,
>
> I am calling a native function from Java passing an object that
> contains an array of strings.
>
> In C , I would like to change this array and return it back to java,
> how do i do this?
> I have read sun's documentation, but they never talk about this. any
> help would be appreciated.
>
> thanks,
> Hashim.


Hello!

I am not sure if this helps because I'm still studying java.
But normally if I have any problems I log in this website
http://java.sun.com/docs/books/tutorial/index.html
Why don't you give this website a try.
Hopefully this will help you.

Best of luck.

AsianDoll
 
Reply With Quote
 
hash.q
Guest
Posts: n/a
 
      10-22-2008
On Oct 22, 4:45*am, (E-Mail Removed) wrote:
> On Oct 22, 6:10*am, "hash.q" <(E-Mail Removed)> wrote:
>
> > Hello,

>
> > I am calling a native function from Java passing an object that
> > contains an array of strings.

>
> > In C , I would like to change this array and return it back to java,
> > how do i do this?
> > I have read sun's documentation, but they never talk about this. any
> > help would be appreciated.

>
> > thanks,
> > Hashim.

>
> Hello!
>
> I am not sure if this helps because I'm still studying java.
> But normally if I have any problems I log in this websitehttp://java.sun.com/docs/books/tutorial/index.html
> Why don't you give this website a try.
> Hopefully this will help you.
>
> Best of luck.
>
> AsianDoll



Thanks guys, it is working now.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
handling of regexp objects that aren't referenced by variables,arrays, tables or objects ThomasW Ruby 11 09-28-2009 01:52 AM
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
How to access parameter values located inside objects being held inside a Vector nobody Java 1 04-26-2006 04:41 AM
Arrays.asList() returning java.util.Arrays$ArrayList Alexandra Stehman Java 5 06-17-2004 06:04 PM



Advertisments