Browse Prior Art Database

Source Code Transformations to Improve Performance of Applications using Java Native Interface (JNI)

IP.com Disclosure Number: IPCOM000013239D
Original Publication Date: 2001-Apr-20
Included in the Prior Art Database: 2003-Jun-18
Document File: 2 page(s) / 47K

Publishing Venue

IBM

Abstract

Source Code Transformations to Improve Performance of Applications using Java Native Interface (JNI)

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 56% of the total text.

Page 1 of 2

Source Code Transformations to Improve Performance of Applications using

Java Native Interface (JNI)

This disclosure describes inefficient Java* Native Interface (JNI) constructs and identifies source code transforms to more efficient constructs.

It has been observed from trace and performance measurement data that Java applications that use native methods via the JNI interface can suffer significant performance loss due to a poor use of the interface. This problem also occurs in the core Java 2* * classes, which also rely on JNI to communicate with native methods.

Before going into the details of the transformations, an a priori analysis must be done to identify inefficient JNI constructs. This is an iterative technique by which as new inefficient constructs are discovered, along with more efficient alternatives, they are added to the set of available transforms. For the work done leading to this disclosure, we considered the native methods socketWrite and socketRead defined in the java.net.SocketOutputStream and java.net.SocketOutputStream classes in the core Java class libraries. By analyzing method level instruction traces of these paths, we identified the following poor JNI constructs:

Excessive Java-native boundary crossings via the use of jni_getObjectField call:

This is a call from native (C) code where the native method reaches back into the Java layer to get a reference to an object. This is an expensive operation. In most cases, it is far more efficien...