This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Java Object allocation from C++ and references?


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/

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]