C++ and Java CNI: Check Java references
Per Bothner
per@bothner.com
Mon Apr 23 12:25:00 GMT 2001
Andrew Haley <aph@cambridge.redhat.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++.
I'm not sure this is a good idea. The goal is CNI is to write C++
code that works with Java objects and make it convenient to write
Java native methods; the goal is not to write Java with C++ syntax.
We've put in various hacks in cc1plus to make it convenient to
access Java objects from C++, so to some extent the actual generated
code is different from the source. However, explicit null-pointer
checking seems to stretch the boundary of appropriate magic re-writes.
If null-pointer checking in C++ code makes sense, what makes this
feature Java-specific? (Except that it calls libjava routine.)
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/
More information about the Gcc-patches
mailing list