PDA

View Full Version : RPG data type mappings for the JNI GetFieldID( ) function.



Guest.Visitor
01-01-1995, 02:00 AM
When using the JNI function GetFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig) The last parameter should be a ?field descriptor in a 0-terminated UTF-8 string? The example in the ?Java Native Interface? by Sheng Liang gives ?C? examples of what the string should look like e.g. ?I? for int, ?F? for float, ?D? for Double, ?Z? for Boolean, ?? for an array, and ?L? followed by the class descriptor for an object, Ljava/lang/String; for a java.lang.String. Where is the documentation for each RPG data type that should be used as a ?field descriptor in a 0-terminated UTF-8 string?? Doing a search in the online library on ?JNI? does not help.

Guest.Visitor
09-08-2000, 03:20 PM
Paul, the sig is related to Java types, not C or RPG types. You would code the sig exactly the same as the C examples. An easy way to get the sig for a field or method is to do a javap -s on the java class. For this class <pre> class MyClass { int i; float f; double d; String s; byte meth (char c, int arr) {return null;} } </pre> here's the output of javap -s <pre> { int i; /* I */ float f; /* F */ double d; /* D */ java.lang.String s; /* Ljava/lang/String; */ byte meth(char,int); /* (CI)B */ MyClass(); /* ()V */ } </pre> I hope I understood your question. Good luck. Doing JNI with RPG is ... um ... really, really hard. Really, really, really hard. Not that it's particularly easy with C ... Barbara Morris

Guest.Visitor
09-09-2000, 08:43 AM
After re-reading the JNI book about this parm. I see where I got mixed-up. The author of the book describes the string as a 'specially encoded' 'C' string. So I assumed (wrongly) that since the native language in the book is 'C' the encoding was different for each native language. But now with your input and a more carfull reading of the section in the book I understand that the 'specially encoded' string is to help the JNI function find the field in the Java Class and has nothing to do with what native language JNI is interfacing with. Thank you very much!