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]

Re: GCJ and C++ (calling Java from C++)


Lothar Werzinger wrote:

in the generated headers from gcjh i get this:

 class org::eclipse::emf::examples::extlibrary::Addressable
 : public ::java::lang::Object
 {
   ...

 class org::eclipse::emf::examples::extlibrary::Library
 : public ::java::lang::Object
 {
   ...

class org::eclipse::emf::examples::extlibrary::impl::LibraryImpl
: public ::org::eclipse::emf::ecore::impl::EObjectImpl
{
...



C++ doesn't directly support the idea of a Java interface - we'd need to make some enhancements to the C++ front end in order to support this.


As a workaround, you can cast your object reference to the interface type (using a C++ static_cast, for example), and then call the interface method on that. Just be careful that the object you are casting really does implement the interface!

bug 15411 is a different issue, as in that case it can actually generate a broken virtual call because C++'s idea of the vtable layout will be different from reality. 15411 shouldn't effect you in this case because there is no abstract class here.

Bryce


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