This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: C++ and Java CNI: Check Java references
- To: jason_merrill at redhat dot com (Jason Merrill)
- Subject: Re: C++ and Java CNI: Check Java references
- From: Mike Harrold <mharrold at cas dot org>
- Date: Wed, 25 Apr 2001 14:53:05 -0400 (EDT)
- Cc: tromey at redhat dot com, aph at redhat dot com (Andrew Haley), rth at redhat dot com (Richard Henderson), mark at codesourcery dot com (Mark Mitchell), per at bothner dot com, java at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
>
> >>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
>
> > Last night I was thinking that maybe if we turned every pointer in CNI
> > into a reference then we could have gcjh add `operator *' to every
> > class automatically. But of course this doesn't work because we would
> > actually need `operator .', which C++ doesn't provide :-(.
>
> > What if we opted to use references everywhere but kept the source
> > using `->' to reference fields and such?
>
> How would you do that? -> only works with pointers.
Can you not define operator->() ?
/Mike
>
> > Two things with this approach that I don't yet understand:
>
> > * Is there a performance impact for using references instead of
> > pointers as arguments to methods? It's hard to believe there would
> > be one, but I don't know for certain.
>
> There certainly shouldn't be. There should be a slight performance gain
> because we can assume that references are non-NULL.
>
> I would be strongly in favor of such a change; it would make CNI code more
> Java-like. It's harder to do dangerous things with pointers if you're only
> dealing with references.
>
> > * How are objects returned from methods handled?
>
> They can be returned by value or by reference. Which do you mean?
>
> Jason
>