A very basic jni question - are values copied?

Discussion in 'Java' started by aaronfude@gmail.com, Dec 25, 2004.

  1. Guest

    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
     
    , Dec 25, 2004
    #1
    1. Advertising

  2. 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
     
    Christian Ziech, Dec 25, 2004
    #2
    1. Advertising

  3. Ann Guest

    <> wrote in message
    news:...
    > 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.
     
    Ann, Dec 25, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    510
    Raymond Hettinger
    Jul 27, 2003
  2. aghazalp

    very very basic question

    aghazalp, Apr 2, 2006, in forum: Python
    Replies:
    6
    Views:
    354
    aghazalp
    Apr 2, 2006
  3. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,704
    Merrill & Michele
    Oct 19, 2004
  4. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    534
    Dave Thompson
    Feb 14, 2005
  5. mdh

    A very **very** basic question

    mdh, Sep 25, 2008, in forum: C Programming
    Replies:
    57
    Views:
    1,271
    August Karlstrom
    Sep 26, 2008
Loading...

Share This Page