|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjni.JNIUtilities
EmbeddedCActor for a more recent implementation.
public class JNIUtilities
A collection of utilities for generating Java Native Interface (JNI) classes.
This code is old, hard to use and unmaintained. See
EmbeddedCActor for a more recent implementation.
For information about JNI, see
http://java.sun.com/docs/books/tutorial/native1.1/concepts/index.html
For information about how to create shared libraries under Windows using
Cygwin, see
http://cygwin.com/cygwin-ug-net/dll.html
For information about using JNI with Cygwin, see
http://www.inonit.com/cygwin/jni/helloWorld/c.html
The code uses gmake, the GNU make program. Under Windows, you must
install Cygwin and then you may need to make a symbolic link from gmake to make by
starting up Cygwin bash and doing:
cd c:/cygwin/usr/bin ln -s make.exe gmake.exeIf you don't have
gmake in your path, you might see a message like:
IOException: java.io.IOException: CreateProcess: gmake -C jni/testTrois -f JnijnitestTroisIfnTest.mk error=2This message occurs under Windows because the Windows, Java calls the Windows CreateProcess function, which returns 2, which means that the executable, in this case,
gmake cannot be found.
meaningOfLife()
that returns a double.
meaningOfLife.c that contains
// Return the answer to "the meaning of life, the universe, and everything"
double meaningOfLife() {
return 42.0;
}
meaningOfLife.h that contains
extern "C" double meaningOfLife();
.dll
gcc -shared -o meaningOfLife.dll meaningOfLife.c
CLASSPATH=. export CLASSPATH
$PTII/bin/vergil -jniNote that the
-jni option may go away in the future
if we merge the jni facility into the main tree
Name:
output
C or C++ type:
double
Kind:
return
libraryDirectory
""
nativeFunction:
"meaningOfLife"
nativeLibrary
"meaningOfLife"
cp meaningOfLife.dll $PTII/bin cp jni/jnimeaningOfLife/JnijnimeaningOfLife.dll $PTII/bin
/cygdrive/c/Program Files/j2sdk1.4.1_01/include/win32/jni_md.h:16: syntax error before `;'See http://java.sun.com/products/jdk/faq/jni-j2sdk-faq.html#compiler" and then follow these steps:
jdk_root>/include/win32/jni_md.h,
Where jdk_root is the installation root (eg.,
c:/Program Files/Java/jdk1.5.0_01
typedef __int64 jlong;with:
#ifdef __GNUC__ typedef long long jlong; #else typedef __int64 jlong; #endif
| Red (vincent.arnould) |
| Red (vincent.arnould) |
| Field Summary | |
|---|---|
private static ExecuteCommands |
_executeCommands
Deprecated. Non-graphical or graphical executor of commands. |
private static java.lang.String |
_indent1
Deprecated. String to use to indent 1 level. |
private static java.lang.String |
_indent2
Deprecated. String to use to indent 2 level. |
private static java.lang.String |
_indent3
Deprecated. String to use to indent 3 level/ |
| Constructor Summary | |
|---|---|
private |
JNIUtilities()
Deprecated. Instances of this class cannot be created. |
| Method Summary | |
|---|---|
protected static java.io.File |
_exportCInterfaceFile(GenericJNIActor actor,
java.lang.String destinationDirectory)
Deprecated. Create the JNI C file. |
protected static void |
_exportDSP(GenericJNIActor actor,
java.lang.String destinationDirectory)
Deprecated. Export the Visual Studio project. |
protected static java.io.File |
_exportJavaInterfaceFile(GenericJNIActor actor,
java.lang.String destinationDirectory)
Deprecated. Create the JNI Java file. |
protected static void |
_exportMakefile(GenericJNIActor actor,
java.lang.String destinationDirectory)
Deprecated. Export a makefile. |
protected static java.util.Vector |
_getArguments(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn)
Deprecated. Get the arguments belonging to a GenericJNIActor. |
protected static java.lang.String |
_getArguments(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
Deprecated. Get the args belonging to this entity. |
protected static java.util.Vector |
_getArgumentsIn(GenericJNIActor actor)
Deprecated. Get the args In belonging to this entity. |
protected static java.lang.String |
_getArgumentsIn(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the args In name belonging to this entity. |
protected static java.util.Vector |
_getArgumentsInOut(GenericJNIActor actor)
Deprecated. Get the args InOut belonging to this entity. |
protected static java.lang.String |
_getArgumentsInOut(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the args InOut belonging to this entity. |
protected static java.lang.String |
_getArgumentsInOutWithCType(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the args In belonging to a GenericJNIActor with their c type. |
protected static java.lang.String |
_getArgumentsInOutWithJNIType(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the InOut args belonging to a GenericJNIActor entity with their JNI type. |
protected static java.lang.String |
_getArgumentsInOutWithJType(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the InOut args belonging to a GenericJNIActor entity with their java type. |
protected static java.lang.String |
_getArgumentsInWithCType(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the In args belonging to a GenericJNIActor entity with their c type. |
protected static java.lang.String |
_getArgumentsInWithJNIType(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the In args belonging to a GenericJNIActor entity with their JNI type, excluding the out arguments. |
protected static java.lang.String |
_getArgumentsInWithJType(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the In args belonging to a GenericJNIActor entity with their java type. |
protected static java.util.Vector |
_getArgumentsOut(GenericJNIActor actor)
Deprecated. Get the Out args belonging a GenericJNIActor entity. |
protected static java.lang.String |
_getArgumentsOut(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the names of the out args name belonging to a GenericJNIActor. |
protected static java.lang.String |
_getArgumentsOutWithCType(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the Out args belonging to a GenericJNIActor entity with their c type. |
protected static java.lang.String |
_getArgumentsOutWithJNIType(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the args In belonging to this entity with their JNI type, excluding the out arguments. |
protected static java.lang.String |
_getArgumentsOutWithJType(GenericJNIActor actor,
java.lang.String separator)
Deprecated. Get the args Out belonging to this entity with their java type. |
protected static java.lang.String |
_getArgumentsWithCType(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
Deprecated. Get the args belonging to this entity with their c type. |
protected static java.lang.String |
_getArgumentsWithCTypeCast(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
Deprecated. Get the arguments belonging to this entity with their c type. |
protected static java.lang.String |
_getArgumentsWithJNIType(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
Deprecated. Get the arguments In belonging to this entity with their JNI type, excluding the out arguments. |
protected static java.lang.String |
_getArgumentsWithJType(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
Deprecated. Get the arguments belonging to this entity with their java type. |
private static java.lang.String |
_getInterNativeFunction(GenericJNIActor actor)
Deprecated. |
private static java.lang.String |
_getInterNativeLibrary(GenericJNIActor actor)
Deprecated. |
private static java.lang.String |
_getLibraryDirectory(GenericJNIActor actor)
Deprecated. Return the value of the libraryDirectory argument with the double quotes stripped off. |
private static java.lang.String |
_getNativeFunction(GenericJNIActor actor)
Deprecated. |
protected static java.lang.String |
_signature(java.lang.String typ)
Deprecated. Return the signature of the interface function. |
protected static java.lang.String |
_signatureSendResults(GenericJNIActor actor)
Deprecated. Return the signature of the interface function. |
private static java.lang.String |
_virgule(java.lang.String string)
Deprecated. Test the given string to know if a comma is needed |
private static java.lang.String |
_virgule(java.lang.String string1,
java.lang.String string2)
Deprecated. Test the given string to know if a comma is needed |
static boolean |
generateJNI(CompositeEntity model)
Deprecated. Given a model, generate JNI files for all GenericJNIActors. |
static void |
generateJNI(CompositeEntity model,
GenericJNIActor actor)
Deprecated. Generate JNI files for one actor in a model. |
static ExecuteCommands |
getExecuteCommands()
Deprecated. Get the command executor, which can be either non-graphical or graphical. |
static java.lang.String |
getNativeLibrary(GenericJNIActor actor)
Deprecated. Return the value of the nativeLibrary attribute with the double quotes stripped off. |
static void |
setExecuteCommands(ExecuteCommands executeCommands)
Deprecated. Set the command executor, which can be either non-graphical or graphical. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static java.lang.String _indent1
private static java.lang.String _indent2
private static java.lang.String _indent3
private static ExecuteCommands _executeCommands
| Constructor Detail |
|---|
private JNIUtilities()
| Method Detail |
|---|
public static boolean generateJNI(CompositeEntity model)
throws java.lang.Exception
model - The model to generate JNI files for any
contained GenericJNIActors.
java.lang.Exception - If there was a problem creating the JNI files.
public static void generateJNI(CompositeEntity model,
GenericJNIActor actor)
throws java.lang.Exception
model - The model that contains the actor.actor - The actor for which to generate JNI files.
java.lang.Exception - If an actor with the JNI name already
exists, if there is a problem creating or compiling the JNI files,
or if there is a problem creating the ports that correspond with
the native method parameters.
public static java.lang.String getNativeLibrary(GenericJNIActor actor)
throws IllegalActionException
actor - The actor that contains a nativeLibrary attribute.
IllegalActionException - If there is a problem getting
the nativeLibrary attribute.public static ExecuteCommands getExecuteCommands()
setExecuteCommands(ExecuteCommands)public static void setExecuteCommands(ExecuteCommands executeCommands)
executeCommands - The subprocess command executor.getExecuteCommands()
protected static java.io.File _exportCInterfaceFile(GenericJNIActor actor,
java.lang.String destinationDirectory)
throws IllegalActionException,
java.io.IOException
actor - Actor to generate a JNI C file for.destinationDirectory - Directory to create the file in.
IllegalActionException - If there is a problem accessing
parameters or ports.
java.io.IOException - If there is a problem writing the C files.
protected static void _exportDSP(GenericJNIActor actor,
java.lang.String destinationDirectory)
throws IllegalActionException,
java.io.IOException
actor - Actor to generate a JNI Java file for.destinationDirectory - Directory to create the file in.
IllegalActionException - If there is a problem accessing
parameters or ports.
java.io.IOException - If there is a problem writing the
Visual Studio files.
protected static java.io.File _exportJavaInterfaceFile(GenericJNIActor actor,
java.lang.String destinationDirectory)
throws IllegalActionException,
java.io.IOException
actor - Actor to generate a JNI Java file for.destinationDirectory - Directory to create the file in.
IllegalActionException - If there is a problem accessing
parameters or ports.
java.io.IOException - If there is a problem writing the Java file.
protected static void _exportMakefile(GenericJNIActor actor,
java.lang.String destinationDirectory)
throws IllegalActionException,
java.io.IOException
actor - Actor to generate a makefile for.destinationDirectory - Directory to create the file in.
IllegalActionException - If there is a problem accessing
parameters or ports.
java.io.IOException - If there is a problem writing the makefile.
protected static java.util.Vector _getArguments(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn)
actor - The GenericJNIActor objectisInput - True if we are searching for input arguments.isOutput - True if we are searching for output arguments.isReturn - True if we are searchin for return arguments.
protected static java.lang.String _getArguments(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
actor - The GenericJNIActor object.isInput - True if we are searching for input arguments.isOutput - True if we are searching for output arguments.isReturn - True if we are searchin for return arguments.separator - The separator used between multiple arguments.
protected static java.util.Vector _getArgumentsIn(GenericJNIActor actor)
actor - The GenericJNIActor object
protected static java.lang.String _getArgumentsIn(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor objectseparator - The separator used between multiple arguments.
protected static java.util.Vector _getArgumentsInOut(GenericJNIActor actor)
actor - The GenericJNIActor object
protected static java.lang.String _getArgumentsInOut(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor objectseparator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsInOutWithCType(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsInOutWithJNIType(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsInOutWithJType(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsInWithCType(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsInWithJNIType(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsInWithJType(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.util.Vector _getArgumentsOut(GenericJNIActor actor)
actor - The GenericJNIActor object.
protected static java.lang.String _getArgumentsOut(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsOutWithCType(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsOutWithJNIType(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsOutWithJType(GenericJNIActor actor,
java.lang.String separator)
actor - The GenericJNIActor object.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsWithCType(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
actor - The GenericJNIActor object.isInput - True if we are searching for input arguments.isOutput - True if we are searching for output arguments.isReturn - True if we are searchin for return arguments.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsWithCTypeCast(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
actor - The GenericJNIActor object.isInput - True if we are searching for input arguments.isOutput - True if we are searching for output arguments.isReturn - True if we are searchin for return arguments.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsWithJNIType(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
actor - The GenericJNIActor object.isInput - True if we are searching for input arguments.isOutput - True if we are searching for output arguments.isReturn - True if we are searchin for return arguments.separator - The separator used between multiple arguments.
protected static java.lang.String _getArgumentsWithJType(GenericJNIActor actor,
boolean isInput,
boolean isOutput,
boolean isReturn,
java.lang.String separator)
actor - The GenericJNIActor object.isInput - True if we are searching for input arguments.isOutput - True if we are searching for output arguments.isReturn - True if we are searchin for return arguments.separator - The separator used between multiple arguments.
protected static java.lang.String _signature(java.lang.String typ)
typ - The interface function declaration.
protected static java.lang.String _signatureSendResults(GenericJNIActor actor)
actor - The GenericJNIActor object.
private static java.lang.String _getInterNativeFunction(GenericJNIActor actor)
private static java.lang.String _getInterNativeLibrary(GenericJNIActor actor)
private static java.lang.String _getLibraryDirectory(GenericJNIActor actor)
throws IllegalActionException
IllegalActionException
private static java.lang.String _getNativeFunction(GenericJNIActor actor)
throws IllegalActionException
IllegalActionExceptionprivate static java.lang.String _virgule(java.lang.String string)
string - the string to test
private static java.lang.String _virgule(java.lang.String string1,
java.lang.String string2)
string1 - the first string to teststring2 - the second string to test
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||