"instanceof" in CNI?

Tom Tromey tromey@cygnus.com
Thu Dec 16 21:18:00 GMT 1999


Bryce> One solution is to declare an 'extern' reference to the class
Bryce> symbol for the class we want to test against

This is currently what we do in this and similar circumstances.  It
sure is ugly!

Bryce> It might be nice if gcjh declared this automatically, so that
Bryce> this could be changed to:

Bryce> "_Jv_InstanceOf(obj, java::lang::Integer::_jv_class)" or something similar.

This has been on the to-do list for a long time (the same !#$@# to-do
list that we still haven't cleaned up and entered into Gnats, sigh).
I don't remember exactly why this isn't really easy to do, but there
is some reason.  Maybe it is just that picking a name for the class is
hard (eg in your example, _jv_class is a perfectly valid Java method
or field name; there is a vague plan to fix some of these naming
problems but as far as I know nobody is really looking at implementing
it).


Maybe another choice would be to declare macros on a per-header basis:

    extern java::lang::Class _CL_Q34java4lang7Integer;
    #define JAVA_LANG_INTEGER_CLASS (&_CL_Q34java4lang7Integer)

This is ugly too, though less so, since it at least isolates the
name-mangling knowledge in gcjh and not in every program that uses
instanceof.

Anyway, I agree this is a problem, but I don't have an immediate fix :-(

Tom


More information about the Java mailing list