Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to save reference to an native-object (c++)

Reply
Thread Tools

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

 
 
Cengiz
Guest
Posts: n/a
 
      07-25-2003
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 ?
 
Reply With Quote
 
 
 
 
pete kirkham
Guest
Posts: n/a
 
      07-25-2003
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

 
Reply With Quote
 
 
 
 
Joseph Millar
Guest
Posts: n/a
 
      07-26-2003
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
 
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
SAVE AS: a warning message says it can't save teo ASP .Net 1 07-23-2006 01:34 PM
Save contents of iframe from parent's save button user ASP .Net 1 04-04-2005 07:44 PM
cannot save or save as in word Phil Edwards Computer Support 0 07-12-2004 07:01 AM
word will not save or save as Alex B Computer Support 5 07-10-2004 05:23 AM
Save, Save As, Paste Phil Edwards Computer Support 1 06-27-2004 03:32 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57