× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Otto,

The following are some links that I've found helpful when
building RPG/JNI apps.  Some actually have "C" examples that
mirror some of what you are attempting to accomplish.  Search
the pages looking for your respective JNI function.

As for your code, at first glance it looks OK.  Obvioulsy
the truth will manifest itself at compile and run time.

BTW: Verses calling another application/component to handle
literal conversion, I chose to construct RPG copy source that
contains the respective ASCII representations, method, fields
and java signatures. This, in my environment at least, has become
an effective repository for reuse.

The following is a code snippet from source member "signatures"
in source file JavaIO (for java.io...):

 ************************************************************     
 * Define ASCII strings used by JNI.                              
 ************************************************************     
 * 'Ljava/io/PrintStream;' signature                              
DJINPS            C                   x'4c6a6176612f696f2f-       
D                                     5072696e7453747265616d3b'   
 * 'java/io/PrintStream'                                          
DJavaIOPS         C                   x'6a6176612f696f2f-         
D                                     5072696e7453747265616d'     
 * 'java/io/Writer'                                               
DJavaIOWtr        C                   x'6a6176612f696f2f-         
D                                     577269746572'               
 * 'Ljava/io/Writer;' signature                                   
DJIOWtr           C                   x'4c6a6176612f696f2f-       
D                                     5772697465723b'             
 * 'java/io/PrintWriter'                                          
DJavaIOPW         C                   x'6a6176612f696f2f-         
D                                     5072696e74577269746572'
 * 'Ljava/io/PrintWriter;' signature                              
DJINPW            C                   x'4c6a6176612f696f2f-       
D                                     5072696e745772697465723b'   
 * 'out'                                                          
Dout              C                   x'6f7574'                   
 * 'println'                                                      
Dprtln            C                   x'7072696e746c6e'                

   

Good luck,

Michael Rooney
Citigroup International

This link demonstrates JNI calls for FindClass, GetObjectClass,
newStringUTF and GetStringUTFChars:


http://java.sun.com/docs/books/jni/html/fldmeth.html

This link demonstrates JNI calls for CallObjectMethod, GetMethodId,
newStringUTF and GetStringUTFChars:


http://forum.java.sun.com/thread.jsp?forum=52&thread=491990&tstart=120&trange=15

This link dicusses pasing string and array data between java and other
programming languages:

http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jnistring.html
  



-----Original Message-----
From: rpg400-l-bounces+michael.p.rooney=citigroup.com@xxxxxxxxxxxx
[mailto:rpg400-l-bounces+michael.p.rooney=citigroup.com@xxxxxxxxxxxx]On
Behalf Of Steffan, Otto (GE Consumer Finance)
Sent: Tuesday, April 13, 2004 9:51 AM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: Java array in ILE RPG


Hello,

I have to agree that really the JNI solution "is not the easiest soluton" as
Michael stated in his prior mail. 

I am going to call a CallObjectMethodA JNI method and finding that the job
is much more complex than I anticipated before :-(.
Please can someone check my following lines to assure me that I am on the
right track? we have V5R2

My sequence of logical deductions (=>):
1.
JNI member contains the prototype for CallObjectMethodA JNI method:
D CallObjectMethodA...                                       
D                 PR                  LIKE(jobject)          
D                                     EXTPROC(*CWIDEN        
D                                     : JNINativeInterface.  
D                                       CallObjectMethodA_P) 
D env                                 LIKE(JNIEnv_P) VALUE   
D obj                                 LIKE(jobject) VALUE    
D methodID                            LIKE(jmethodID) VALUE  
D args                                LIKE(jvalue) DIM(1)    

=> I have to pass methodID of the java-array method.

2. I get methodID using another JNI method GetMethodID that is prototyped
like this:
D GetMethodID     PR                  LIKE(jmethodID)       
D                                     EXTPROC(*CWIDEN       
D                                     : JNINativeInterface. 
D                                       GetMethodID_P)      
D env                                 LIKE(JNIEnv_P) VALUE  
D clazz                               LIKE(jclass) VALUE    
D name                            *   OPTIONS(*STRING) VALUE
D sig                             *   OPTIONS(*STRING) VALUE

=> I have to pass also: 
jclass object,
name of java-array method,
signature of java-array method.
name & signature must be in UTF-8 according to GetMethodID spec at
http://java.sun.com/j2se/1.3/docs/guide/jni/spec/functions.doc.html#16660
=> I must know how to get a class object from a class.
=> I must know how to convert EBCDIC to UTF-8.

3. I get the class object using GetObjectClass JNI method.

4. I can convert RPG literals for java-array method name & signature using
ldap_xlate_local_to_utf8() API.
(I found an example from Scott Klement at iseriesnetwork RPG forum.)

Thanks for reading up to this point.

Otto Steffan


-----Original Message-----
From: Rooney, Michael P [mailto:michael.p.rooney@xxxxxxxxxxxxx]
Sent: Monday, April 12, 2004 4:37 PM
To: RPG programming on the AS400 / iSeries
Subject: RE: Java array in ILE RPG


Jon,

You haven't missed a thing.

As I stated in one of my previous posts, using the JNI via RPG
to process a Java Array Object involves more code than Barbara's
solution.

Clearly there are (always) serveral ways to accomplish an objective.
Thus, sometimes the more significant challenge for us technologists is
using the solution best suited for the problem at hand (verses the one
that stimulates the techie in each of us).

While I have contributed to this post, I can not definitively say
which of these options I would use as each of the 3 have merit. Without
hesitation, though, a JNI solution presents the most complexity.        It
may be "cool" but it is not the easiest soluton.

Regards,

Michael Rooney
Citigroup International
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.