From: Andrew Haley <aph@redhat.com>
To: Bryce McKinlay <bmckinlay@gmail.com>
Cc: Stephen Kell <srk31@srcf.ucam.org>, java@gcc.gnu.org
Subject: Re: CNI and interface methods
Date: Fri, 03 Apr 2009 10:44:00 -0000 [thread overview]
Message-ID: <49D5E868.50409@redhat.com> (raw)
In-Reply-To: <7230133d0904030328o55069f0do9147f879bcbd5e4f@mail.gmail.com>
Bryce McKinlay wrote:
> On Fri, Apr 3, 2009 at 9:37 AM, Andrew Haley <aph@redhat.com> wrote:
>
>> Stephen Kell wrote:
>>
>>> I'm using CNI for the first time and have hit a query. What exactly is
>>> and isn't supposed to work when invoking interface methods through
>>> *object* references (from C++, so I mean pointers), and passing these
>>> references around?
>>>
>>> The CNI chapter in the gcj manual says a lot about interface references,
>>> but not about the case of using object references where that object's
>>> class implements one or more interfaces. One thing that would appear to
>>> be worth mentioning is that clearly, passing them to methods wanting an
>>> interface reference won't compile without some sort of cast, since the
>>> gcjh-generated headers don't encode the subtyping relationship between
>>> interfaces and their implementing classes. I'm guessing a simple static
>>> cast isn't the right thing to do though, because I'm getting segfaults
>>> when I try.
>
>> Right. To put it simply, we have never got around to implementing Java
>> interface calls in CNI. It wouldn't be enormously difficult, but it
>> needs some way to tell the C++ compiler about interface calls. We could
>> have implemented Java interfaces via C++ multiple inheritance but we
>> didn't, so we would need to invent some sort of notation to express the
>> idea of an interface to the C++ compiler.
>
> Actually we did implement a rather limited form of interface calls in CNI.
> Interfaces types are described in CNI headers with __attribute__
> ((java_interface)), and the C++ compiler knows how to call a method on a
> type declared as such.
>
> What is missing in the C++ compiler (and the CNI headers) is knowledge of
> interface inheritance, so you have to manually cast interface references if
> the method you want to call was declared in a super-interface.
>
> This limitation is described here:
>
> http://gcc.gnu.org/onlinedocs/gcj/Interfaces.html
Ah yes, thanks for the clarification.
Andrew.
next prev parent reply other threads:[~2009-04-03 10:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-02 19:38 Stephen Kell
2009-04-03 8:37 ` Andrew Haley
2009-04-03 10:35 ` Bryce McKinlay
[not found] ` <7230133d0904030328o55069f0do9147f879bcbd5e4f@mail.gmail.com>
2009-04-03 10:44 ` Andrew Haley [this message]
2009-04-03 18:54 ` Stephen Kell
2009-04-03 19:06 ` David Daney
2009-04-04 9:12 ` Andrew Haley
2009-04-03 13:57 ` Stephen Kell
2009-04-03 14:13 ` Andrew Haley
2009-04-03 18:42 ` Stephen Kell
-- strict thread matches above, loose matches on Subject: below --
2000-04-01 0:00 Oskar Liljeblad
2000-04-01 0:00 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49D5E868.50409@redhat.com \
--to=aph@redhat.com \
--cc=bmckinlay@gmail.com \
--cc=java@gcc.gnu.org \
--cc=srk31@srcf.ucam.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).