Jump to content

Compiled Native Interface

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Master Of Ninja (talk | contribs) at 10:03, 22 April 2005 (corrected C++ link). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Compiled Native Interface (CNI) is a software framework for the GNU GCJ compiler which allows Java code to call and be called by native applications (programs specific to a hardware and operating system platform) and libraries written in C++.

It is similar to the Java Native Interface (JNI) framework which comes as standard with various Java virtual machines. However the CNI authors claim various advantages over JNI:

" We use CNI because we think it is a better solution, especially for a Java implementation that is based on the idea that Java is just another programming language that can be implemented using standard compilation techniques. Given that, and the idea that languages implemented using Gcc should be compatible where it makes sense, it follows that the Java calling convention should be as similar as practical to that used for other languages, especially C++, since we can think of Java as a subset of C++. CNI is just a set of helper functions and conventions built on the idea that C++ and Java have the *same* calling convention and object layout; they are binary compatible. (This is a simplification, but close enough.) " Source: http://gcc.gnu.org/java/faq.html#2_3