What exactly are these jintjlong, etc. types?


One of the challenges of platform- and compiler-portable C++ development is unified treatment of the primitive types. Just for some background: types like int and longare notorious for having different sizes on different platforms or even different compilers within one platform.

Many C++ frameworks create their own preprocessor macros or typedefs that replace built-in primitive types like int and long. Typical type names include int32 for a 32 bit integer and int64 for a 64 bit integer. The Java Native Interface (JNI) already did all the work for us and defined platform- and compiler-portable primitive types. Codemesh now only had to face the choice of whether or not to use them. On the plus side, the JNI definitions are well thought out and consistent. On the minus side, some people hate to have their APIs cluttered with typenames that look "foreign."

Because portability is very important for us, we decided to use the JNI names for the primitive types. We have yet to encounter a platform or compiler where the built-in primitive types don't interoperate well with the JNI definitions. The following table provides the complete mapping:

JNI nameDescriptionComments
jbyte8bit signed integercan be used synonymously with char
jchar16bit signed integer 
jdouble64bit floating point numbercan be used synonymously with double on all supported platforms.
jfloat32bit floating point numbercan be used synonymously with float on all supported platforms.
jint32bit signed integercan be used synonymously with int on all supported 32bit platforms.
jlong64bit signed integer"built-in" corresponding type differs by platform and compiler.
jshort16bit signed integer 
jsize32bit signed integer