How to save reference to an native-object (c++)

Discussion in 'Java' started by Cengiz, Jul 25, 2003.

  1. Cengiz

    Cengiz Guest

    Hi,
    what i do in my program:
    I have a class in Java. Some Methods of this class call another global
    native-method written in c++ (in a DLL). This method in c++ instances
    a class. How can i do it, that at the next invocation i can use the
    same instance without instantiate it new ?
    Cengiz, Jul 25, 2003
    #1
    1. Advertising

  2. Cengiz

    pete kirkham Guest

    Cengiz wrote:
    > Hi,
    > what i do in my program:
    > I have a class in Java. Some Methods of this class call another global
    > native-method written in c++ (in a DLL). This method in c++ instances
    > a class. How can i do it, that at the next invocation i can use the
    > same instance without instantiate it new ?


    Have a field in the Java class which is wide enough to contain the
    address of the native object's pointer, which is passed as an argument
    to/accessed inside the native method.


    Pete
    pete kirkham, Jul 25, 2003
    #2
    1. Advertising

  3. On 25 Jul 2003 05:11:42 -0700, (Cengiz) wrote:

    > Hi,
    > what i do in my program:
    > I have a class in Java. Some Methods of this class call another global
    > native-method written in c++ (in a DLL). This method in c++ instances
    > a class. How can i do it, that at the next invocation i can use the
    > same instance without instantiate it new ?


    Including Pete's approach (which I have used myself on
    several ocassions), you can set a static field in the
    C++ class and just retrieve it on entry to get the
    instance pointer. Or set a DLL global variable.

    In all of these instances, be sure you take thread
    safety into consideration.

    --Joe
    Joseph Millar, Jul 26, 2003
    #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. Cengiz
    Replies:
    0
    Views:
    349
    Cengiz
    Jul 25, 2003
  2. Replies:
    1
    Views:
    475
    Mark Rae [MVP]
    Sep 20, 2007
  3. CD1
    Replies:
    2
    Views:
    1,350
    Gordon Beaton
    Jun 5, 2008
  4. Jamal Soueidan

    save object reference in db?

    Jamal Soueidan, Oct 27, 2008, in forum: Ruby
    Replies:
    3
    Views:
    120
    Robert Klemme
    Oct 27, 2008
  5. poldo

    Save an object Reference to DOM

    poldo, Feb 20, 2008, in forum: Javascript
    Replies:
    1
    Views:
    98
    Martin Honnen
    Feb 20, 2008
Loading...

Share This Page