Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > A very basic jni question - are values copied?

Reply
Thread Tools

A very basic jni question - are values copied?

 
 
aaronfude@gmail.com
Guest
Posts: n/a
 
      12-25-2004
Hi,

When an array is created in the native code and returned to java is it
returned by reference or by copy?

Sorry for not being able to find the answer to this very basic question
in the standard places.


Aaron Fude

 
Reply With Quote
 
 
 
 
Christian Ziech
Guest
Posts: n/a
 
      12-25-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) schrieb:
> Hi,
>
> When an array is created in the native code and returned to java is it
> returned by reference or by copy?
>
> Sorry for not being able to find the answer to this very basic question
> in the standard places.
>
>
> Aaron Fude
>


Well I don't think that either is the correct answer. From your native
point of view you only have an "identifer" representing your
java-object. That's why you always act on the enviroment-variable. So
the situation is that you always only hold a reference in your
C(++)-Code to the real java-object. The bad thing about those
"identifers" is that they can be different each time a native method is
called for each object.
Hoped that this helped you a bit (further I hope that I didn't tell you
rubbish - all is afaik)

Christian
 
Reply With Quote
 
 
 
 
Ann
Guest
Posts: n/a
 
      12-25-2004

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi,
>
> When an array is created in the native code and returned to java is it
> returned by reference or by copy?
>
> Sorry for not being able to find the answer to this very basic question
> in the standard places.
>
>
> Aaron Fude
>


From my book learnin, all parameters and return values are passed
by copy, BUT WAIT THERE'S MORE. If the parameter/ret val is an
Object (array is an Object) then what is copied is the reference
to the object. So the array is itself not copied, you just get
a reference to it; it lives in the heap. Of course I have not tried it
myself, I use int and float.


 
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
I found some very odd behaviour in Python's very basic types Sunjay Varma Python 4 03-10-2011 05:05 PM
A very **very** basic question mdh C Programming 57 09-26-2008 03:25 PM
very very basic question aghazalp Python 6 04-02-2006 09:35 PM
Very very very basic question Peter C Programming 14 02-14-2005 09:46 AM
very Very VERY dumb Question About The new Set( ) 's Raymond Arthur St. Marie II of III Python 4 07-27-2003 12:09 AM



Advertisments