C++ and Java CNI: Check Java references

Fergus Henderson fjh@cs.mu.oz.au
Mon Apr 23 21:57:00 GMT 2001


On 23-Apr-2001, Tom Tromey <tromey@redhat.com> wrote:
> >>>>> "Per" == Per Bothner <per@bothner.com> writes:
> 
> >> The semantics of Java require dereferencing a null pointer to an
> >> object to throw a NullPointerException.  We already generate code to
> >> do this in the Java compiler; this patch is for CNI code that is
> >> written in C++.
> 
> Per> I'm not sure this is a good idea.  The goal is CNI is to write
> Per> C++ code that works with Java objects and make it convenient to
> Per> write Java native methods; the goal is not to write Java with C++
> Per> syntax.  We've put in various hacks in cc1plus to make it
> Per> convenient to access Java objects from C++, so to some extent the
> Per> actual generated code is different from the source.  However,
> Per> explicit null-pointer checking seems to stretch the boundary of
> Per> appropriate magic re-writes.
> 
> What are the alternatives?

This could be a dumb question -- I've barely glanced at the libjava code --
but what's the rationale for writing large chunks of it in C++ rather than
Java?

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: < http://www.cs.mu.oz.au/~fjh >  |     -- the last words of T. S. Garp.



More information about the Java mailing list