Please find below the mappings table for most commonly used data types along with some comments.
Native Type (C/C++) | JNIWrapper Type | Comments |
Boolean Types | ||
bool | Bool(1 byte), IntBool(4 bytes) | |
Character Types | ||
char | ||
wchar_t | ||
uchar * | ||
Integer Types | ||
short | The unsigned types are represented by prepending U to the type name, e.g. unsigned int (or unsigned) type is UInt. There are also types for predefined-width integers: Int8, Int16, Int32 and Int64, they also have the unsigned variants. | |
int | ||
long | ||
Floating-point Types | ||
float | ||
double | ||
long double | Long double is the same as double (8-byte floating-point value) on win32 platform. | |
Pointer Types (not arrays) | ||
void * | ||
const | Use Pointer.Const if the referenced object is not to be modified by the calling function. | |
type * | To create a pointer to the value (variable) of a known type, use the Pointer class. | |
type * | Use Pointer.OutOnly if the referenced value is not read by the calling function. | |
char * | ||
wchar_t * | ||
Arrays | ||
<c primitive type>[n] | PrimitiveArray(<corresponding JNIWrapper type>.class, n); | For example: |
Structures and Unions | ||
struct | ||
union | ||
Function Pointers | ||
To create an object callable from the native code use the Callback class. To call a function returned from the native code use the method asFunction of the Pointer.Void class. | ||
Windows API includes many data types that are not listed here (for example, DWORD, HANDLE). If you need to use one of such types, read Windows-specific documentation such as MSDN to find out the actual C type that corresponds to it (for example, LPSTR corresponds to char*) and use the relevant JNIWrapper type for the argument. You can also check the Windows Data Types table that we have created for your reference.
There are no comments on this document