C++ and Java CNI: Check Java references

Jason Merrill jason_merrill@redhat.com
Wed Apr 25 11:02:00 GMT 2001


>>>>> "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.
> 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


More information about the Java mailing list

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