Java provides 8 primitives types which represent integers, floats, characters and booleans (and also the void type). C++ has its own very similar concrete types. Such types in C++ however are not always implemented in the same way (an int might be 16, 32 or 64 bits for example) so CNI provides a special C++ type for each primitive Java type:
Java type | C/C++ typename | Description
|
char | jchar | 16 bit Unicode character
|
boolean | jboolean | logical (true or false) values
|
byte | jbyte | 8-bit signed integer
|
short | jshort | 16 bit signed integer
|
int | jint | 32 bit signed integer
|
long | jlong | 64 bit signed integer
|
float | jfloat | 32 bit IEEE floating point number
|
double | jdouble | 64 bit IEEE floating point number
|
void | void | no value
|
When referring to a Java type You should always use these C++ typenames (e.g.: jint
)
to avoid disappointment.
In Java each primitive type has an associated reference type,
e.g.: boolean
has an associated java.lang.Boolean.TYPE
class.
In order to make working with such classes easier GCJ provides the macro
JvPrimClass
: