Usage of the JNI interface
Beyond the form of the JNI interface, you must consider how the JNI is used by native libraries on a 64-bit system.
There are a number of issues to consider:
- On some 64-bit systems, certain native objects that are passed across the JNI are 64 bit, whereas they are 31 bit on equivalent 31-bit systems. Examples of this type of object are Socket handles and File handles.
- Passing 64-bit objects across the JNI is not a problem. However, in many cases, these objects are stored in Java™ object fields. The implication is that the type of these object fields changes on a 64-bit system compared with existing 31-bit systems. You must change your Java code to achieve this.
- If the size of a Java object field is different on the 64-bit platform from the 31-bit platform, any native code that is working with that object field must be changed to reflect the difference in size when the code is ported from 31 bit to 64 bit. You can best deal with this by having a full description of each of the Java object types that is affected in this way. If your application code stores "native data" within Java objects, then you must modify your Java code to ensure that there is sufficient space within your Java objects to store all of the native data.