A mapping, which essentially also applies to BS2000, has been defined between the primitive Java data types and the native C representation. The following table provides a summary of the data types and any special features:
Java type | C type | Compatible C type | Remarks |
boolean | jboolean | unsigned char | JNI_FALSE, JNI_TRUE |
byte | jbyte | signed char | |
char | jchar | unsigned short | Unicode |
short | jshort | signed short | |
int | jint | signed int | |
long | jlong | signed longlong | from C/C++ V3.0B |
float | jfloat | float | IEEE |
double | jdouble | double | IEEE |
void | void | void |
Table 7: Java data types in C
For complex data types, JNI defines corresponding access and conversion functions which can be used in BS2000 analogously to other operating systems. A special role is played here by strings as the UTF-8 encoding of Unicode strings which is used by Java, although closely related to ASCII, is quite unlike EBCDIC encoding. A C programmer in an ASCII environment (Unix systems, Windows systems) will therefore easily succumb to the temptation to use this similarity, with a result that it will not be possible to use such C programs in BS2000 (i.e. in the EBCDIC environment) without taking some further measures.
When C code and Java are linked up via the JNI, there will inevitably be instances in BS2000 where different forms of data encoding coincide. Users must decide for themselves where they want to make corresponding conversion points between the data representations. The essential and critical conversion points are shown in the following table:
Data | Representation | Normal | Alternative |
Whole numbers | 32 and 64 bit | 32 bit | 32 and 64 bit |
Floating point numbers | IEEE format | /390 format | IEEE format |
Strings, characters | Unicode, UTF-8, ASCII | EBCDIC | ASCII |
Table 8: C code in Java and BS2000
In order that the user can make a free choice of conversion point, appropriate help on the various topics is provided through the compiler and runtime systems.
Typically, a JNI interface user will implement this conversion point either directly at the JNI interface and have all his C code run in the normal BS2000 environment or else he will have parts of his C code (or even all of it) run in the alternative representation which is more closely oriented to Java (and Unix systems) and, for example, only carry out the relevant conversions in the context of legacy applications (use of well-tried software).
The sections below describe the support available for the various data types.