- 18.11 (released) ...
- Interface classes
The Java interface allows you to call Java routines or attributes from your Eiffel code. It uses the Java Native Interface (JNI) provided by the Java Development Kit (JDK). You can get more information about the JNI at:
- JDK 1.1.8 or newer should be correctly set up (download it at http://java.sun.com/javase/downloads/index.jsp )
- The environment variable CLASSPATH should defined (check with the JDK documentation on how to do so) and that it contains the Java classes you want to access.
- The environment variables should be setup correctly. See $ISE_EIFFEL\library\Eiffel2Java\README.txt for information how to do this.
- In this version, you can only use one JNI environment.
- Only one thread can interact with the Java Virtual Machine (JVM).
- It is not possible to call Eiffel features from Java program.
- The Eiffel feature
JAVA_VMcalls a C function of the Java NativeInterface that is not fully implemented in jdk 1.1.8. This function, called DestroyJavaVM, always returns -1 in jdk 1.1.8. For further information, go on the JNI pages at the address above.
Holds information about JNI environment. Potentially many JNI environments can exists at once, but more than one was never tested. This class provide the facilities to interact with the JVM:
- creation of instances of Java Classes
- exceptions mechanism
- destruction of the JVM
Shared JNI environment. Since one JNI is needed per thread we limit Eiffel to having one thread that deals with Java. The class that calls Java routines or attributes must inherit from this class.
This class is used to initially load the JVM into the running program. This is the Eiffel representation of the JVM.
Access to Java classes. Static methods and attributes are accessed via this class.This is the Eiffel representation of a Java Class.
This class gives Eiffel access to Java objects. You can use it directly or inherit from to and create a more convenient Eiffel class that makes the Java object look like an Eiffel object. The Eiffel representation of a Java Object.
JNI external declarations. Don't use this class directly.
Access to Java array of "***". "***" can be all the usual types of Java (byte, short, int, float, double, char, boolean) or object if it is an array of Java Object (a String is considered as an object)
Class representing the arguments that can be passed to a Java method. See below about the signature of the methods
This class provides a mapping between Java and Eiffel objects
Mapping the Eiffel classes and the Java types: The following table describes the mapping of Java primitive types and classes to Eiffel classes.
|Java type/class||Eiffel class|
The interface does the mapping automatically. For example, if you call a Java method that returns a 'float', by using float_method you will get a REAL.
The signature of Java methods and attributes:
When you want to call a Java method or access a field, you need to specify its signature.The Eiffel to Java interface follows the JNI specifications. The table below summarizes the encoding for the Java type signatures:
The signature for a Java class has the following form:
For example, class String:
The signature for a method has the following form:
For example, the signature of a method that takes as arguments an integer and a string and return void is: