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

Bryce McKinlay mckinlay@redhat.com
Thu Dec 1 00:49:00 GMT 2005


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


More information about the Java mailing list

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