C++ and Java CNI: Check Java references

Tom Tromey tromey@redhat.com
Tue Apr 24 10:18:00 GMT 2001

>>>>> "Andrew" == Andrew Haley <aph@cambridge.redhat.com> writes:

Andrew> I guess we could do something like
Andrew> #ifdef CHECK
Andrew> #pragma check-java-pointers
Andrew> #endif

Andrew> And the use -DCHECK on the compiler command line.  But I don't
Andrew> know if this is better.

Right now the CNI headers are platform independent.  When you compile
your CNI code you don't (or at least shouldn't!) need to have any kind
of configury -- you just include the headers and go.

I think this will probably change with the introduction of hash
synchronization.  At that point the layout of Object will change
depending on the platform (actually depending on how libjava was
configured, since you might choose not to use hash synchronization for
some reason).

When that happens we'll need to introduce some way for CNI users to
find the right flags to use.  Maybe we'll use something like the
`pkg-config' tool pioneered by Gnome.

Anyway, when this happens we could have a `gcj-config.h' with (or
without) the #pragma in it as appropriate.  That might be convenient.
Then the pkg-config would simply have to have a `-I' pointing to

OTOH, once we're forcing the user to use a special -I, we might as
well go all the way and have pkg-config add `-fcheck
-fhash-synchronization' or whatever.

This assumes that -I and -f are handled similarly by pkg-config.
Havoc, is that the case?

One thing I don't know: if g++ is installed as part of the system,
will it automatically find the hypothetical gcj-config.h?  If so, then
that is an argument for adding the #pragma: on that machine casual
users will probably not use pkg-config, and we would want CNI code to
automatically do the right thing without user intervention.  This is
analogous to how we insert the right flags into libgcj.spec so that
gcj users don't have to know about platform-specific flags.


More information about the Java mailing list