Java Object allocation from C++ and references?

Ben Martin monkeyiq@users.sourceforge.net
Tue Feb 3 14:35:00 GMT 2004


Hi,
 Pls CC me as I'm not currently on the list.
 From the limited info [1] that I found while searching around I
thought it best to ask here and maybe we can also update [1] to include
a more explicit description.
From the page
"New Java objects are allocated using a class instance creation
expression... The same syntax is used in C++. The main difference is
that C++ objects have to be explicitly deleted; in Java they are
automatically deleted by the garbage collector. Using CNI, you can
allocate a new Java object using standard C++ syntax and the C++
compiler will allocate memory from the garbage collector."
So, is it correct to assume that if one is to use C++ code and create an
object implemented in Java code, for example, java::lang::String, then
the C++ code creating the new String* does not call delete?
I have rolled rpms for jakarta-lucene using gcj from Fedora development
and using C++ smart pointers to manage java::lang::string objects seems
to work but when I use a C++ smart pointer on one of the Lucene java
objects the program crashes on the delete of that object.
I am happy to collect info & examples from replies for patching [1] in
the interests of making object lifetime clearer for new gcj coders.
Thanks.
[1] http://gcc.gnu.org/onlinedocs/gcj/Object-allocation.html#Object%20allocation
-- 
Blogtackular http://advogato.org/person/monkeyiq/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java/attachments/20040203/628ea2d3/attachment.sig>


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /