CNI (Compiled Native Interface)
The CNI (Compiled Native Interface, previously Cygnus Native Interface), a software framework for the gcj, 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++.
CNI closely resembles 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.) | ” |
CNI depends on Java classes appearing as C++ classes. For example, given a Java class,
public class Int { public int i; public Int(int i) { this.i = i; } public static Int zero = new Int(0); }one can use the class thus:
#includeRead more about this topic: GNU Compiler For Java
Famous quotes containing the word native:
“The grief of the keen is no personal complaint for the death of one woman over eighty years, but seems to contain the whole passionate rage that lurks somewhere in every native of the island. In this cry of pain the inner consciousness of the people seems to lay itself bare for an instant, and to reveal the mood of beings who feel their isolation in the face of a universe that wars on them with winds and seas.”
—J.M. (John Millington)