Next: , Previous: , Up: About CNI   [Contents][Index]


11.3 Primitive types

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 typeC/C++ typenameDescription
charjchar16 bit Unicode character
booleanjbooleanlogical (true or false) values
bytejbyte8-bit signed integer
shortjshort16 bit signed integer
intjint32 bit signed integer
longjlong64 bit signed integer
floatjfloat32 bit IEEE floating point number
doublejdouble64 bit IEEE floating point number
voidvoidno value

When referring to a Java type You should always use these C++ typenames (e.g.: jint) to avoid disappointment.

11.3.1 Reference types associated with primitive types

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:

macro: JvPrimClass type

Return a pointer to the Class object corresponding to the type supplied.

JvPrimClass(void) ⇒ java.lang.Void.TYPE