"instanceof" in CNI?
Bryce McKinlay
bryce@albatross.co.nz
Thu Dec 16 18:51:00 GMT 1999
Is there a way to do an efficient "obj instanceof <class>" check from CNI?
Currently in some java.net code we're doing a Class.forName() for every
instanceof check to get a reference to the class we want to test against - very
inefficent.
One solution is to declare an 'extern' reference to the class symbol for the
class we want to test against, ie:
extern java::lang::Class _CL_Q34java4lang7Integer;
and then use "_Jv_InstanceOf(obj, &_CL_Q34java4lang7Integer)"
... but this is a bit ugly. It might be nice if gcjh declared this
automatically, so that this could be changed to:
"_Jv_InstanceOf(obj, java::lang::Integer::_jv_class)" or something similar.
Or is there something else that I'm missing?
regards
[ bryce ]
More information about the Java
mailing list