× 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.



Hello again,

at last I broke through all the obstacles on the way and have got a JNI
solution for a java array that is not restricted to n elements in DIM(n)
keyword.
Thank you very much for the tips & hints!

In the end of the programming I realized an issue that concerns freeing
unused java objects. Here are a couple of my code snippets:
....
D getOudesc...                                            
d                 PR                  like(jstring)       
d                                     extproc(*JAVA:      
d                                        Dapi_RSrow01_ifc:
d                                       'getOudesc')      
D getBytes        PR            50A   varying               
d                                     extproc(*JAVA:        
d                                       'java.lang.String': 
d                                       'getBytes')         
....
    if not %error;                                             
      RSRows = CallObjectMethodA ( JNIEnv_P                    
                                 : DapiGetCustomerAccountsImpl 
                                 : jmethodID                   
                                 : jargs );                    
                                                               
      nRSRows = GetArrayLength ( JNIEnv_P                      
                               : RSRows );                     
    else;                                                      
      nRSRows = 0;                                             
    endif;                                                     
                                                               
    if nRSRows > 0;                                            
   // fill in the subfile:                          
      for iRSRows = 0 to nRSRows - 1;                 
        jobject = GetObjectArrayElement ( JNIEnv_P    
                                        : RSRows      
                                        : iRSRows );  
        OUDESC = getBytes(getOudesc(jobject)) ; //  <<<< the issue concerns
this line
.....
OUDESC is an output CHAR field declared in a display DDS source. 
What I am affraid of is if java or something else frees a temporary String
object that getOudesc method creates and passes to getBytes method.
Actually, it is not a problem in this testing programme, the snippets come
from, but I am going to use these methods and the attested solutions in
batch programmes in which they (and others) will be called on really large
scale. I want  to avoid some memory problems in advance.

Best regards
OS

PS: the provider of the java classes has promissed to deliver additional
methods for java arrays so that using JNI methods would not be neccesary any
more (as Barbara suggested earlier); the issue I have described exists
regardless of the approach I finally will use (JNI or the application
methods).


-----Original Message-----
From: Barbara Morris [mailto:bmorris@xxxxxxxxxx]
Sent: Tuesday, April 13, 2004 8:30 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Java array in ILE RPG


"Steffan, Otto (GE Consumer Finance)" wrote:
> 
> 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
> 

It looks to me like you are on the right track.  Dealing with the
parameters to the method is even more fun ...

I know you've already said your reasons for doing it this way, but I
have to repeat that a very slight modification to the Java class would
make this problem go away.  Since a Java array of anything is also an
Object, they would just have to define another method that returns the
array as a single object.  Then you could use the array JNI functions on
the returned array object without having to mess around with the call
functions.

   Object[] meth2(String x, int i)  // this is the real method
   {                                    
      return whatever;
   }                                    

   Object meth2(String x, int i)  // code the same parameters as the
"real" method
   {                                    
      return meth(x, i);          // call through to the real method
   }

_______________________________________________
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-Ups:

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.