C++ and Java CNI: Check Java references

Andrew Haley aph@cambridge.redhat.com
Tue Apr 24 02:00:00 GMT 2001


Tom Tromey writes:
 > >>>>> "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.

Well, I to some extent sympathize with that view and have even at
times expressed it myself, but having to trawl through CNI code to
find pointers that should be checked is not my idea of a good time.
Also, as most developers will still have automatic pointer checking
via signals we'll have terrible problems enforcing the rule.

Andrew.



More information about the Java mailing list