This is the mail archive of the java-discuss@sources.redhat.com 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]

Re: CNI vs interfaces


Tom Tromey wrote:

> Bryce> One way might be to make a dummy "JInterface" C++ class and
> Bryce> have gcjh make interfaces inherit from this in addition to
> Bryce> java.lang.Object. Would this work? Or is there a better option?
>
> One option would be to treat interfaces via real multiple inheritance,
> and change g++ to generate the appropriate call for Java objects whose
> class uses MI.  This might be hairy.
>
> Another choice would be an attribute on the class.  This is probably
> more straightforward, but also more hacky.

I'm thinking an __attribute__ (also suggested by Glenn Chambers) would
work nicely. The C++ compiler already recognises a "com_interface"
attribute, so a "java_interface" would be keeping consistent with that.

We'll still need to use multiple inheritance, as interfaces can have
multiple superinterfaces (currently gcjh doesn't "see" these). Also need
to make sure that the compiler allows assignment from a class field to a
compatible interface field.

Is the vtable lookup emitted by C++ for a java.lang.Object method call
going to work if the compiler sees multiple inheritance (I have no idea
how MI dispatch works)?

regards

  [ bryce ]



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