A Java reference type is treated as a class in C++. Classes and
interfaces are handled this way. A Java reference is translated to a
C++ pointer, so for instance a Java java.lang.String becomes,
in C++, java::lang::String *.
CNI provides a few built-in typedefs for the most common classes:
| Java type | C++ typename | Description
|
java.lang.Object | jobject | Object type
|
java.lang.String | jstring | String type
|
java.lang.Class | jclass | Class type
|
Class
instance. These can be accessed in CNI via the static class$
field of a class. The class$ field is of type Class
(and not Class *), so you will typically take the address of
it.
Here is how you can refer to the class of String, which in
Java would be written String.class:
using namespace java::lang;
doSomething (&String::class$);