Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

JNI String Manipulation in RPG

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • JNI String Manipulation in RPG

    itsjustme wrote:
    I am looking for an example of how to retrieve a JNI Member Variable of type *string and how to set its value using JNI. I have tried to retrieve the string by using the GetObjectField, GetByteField and GetCharField methods of java.lang.string. I would also like to know how to test the return value for null. Lastly, I have written the code to update the field using the setByteField method. Not sure if this is correct as I am unable to retrieve the string.
    GetObjectField is correct. You don't need to define your own prototype to return a jstring. The GetObjectField prototype in QSYSINC/QRPGLESRC(JNI) will work fine. It returns a jobject; a jstring is also a jobject. But I don't think defining your own prototype is causing the problem here. What did you use as the signature for the String object? You have to use slash not dot as the separator for hand-coded JNI, so you should use "Ljava/lang/String;". (The RPG compiler allows class names like java.lang.String because it's more natural to specify that, but for actually calling the JNI functions, it changes the dots to slashes.)

  • #2
    JNI String Manipulation in RPG

    I am looking for an example of how to retrieve a JNI Member Variable of type *string and how to set its value using JNI. I have tried to retrieve the string by using the GetObjectField, GetByteField and GetCharField methods of java.lang.string. I would also like to know how to test the return value for null. Lastly, I have written the code to update the field using the setByteField method. Not sure if this is correct as I am unable to retrieve the string. Thanks in advance for your help!! I have included a snippet of the code below. The code for boolean, short and double is working, just not the string section.
    Code

    Comment

    Working...
    X