|
"Steffan, Otto (GE Consumer Finance)" wrote: > > Hello community, > I want to have a prototype for the constructor method of String class that > allows passing any literal or character varying variable. I think it might > look like this: > ... > I am not sure whether the ultimate size 65535 of the character parameter has > some side or harmful effect or not. > ... I've just read this thread (I've been away for most of this week), and I think I can answer a few of the things that came up. If your Java method expects a byte array (as the String byte[] constructor does), you can specify VARYING and/or OPTIONS(*VARSIZE) on the prototype, and the byte array received by the Java method will have the value you coded in your passed parameter. If you pass 'abc', it will receive a 3-element byte array with the ascii value 'abc' no matter what you coded on your prototype, as long as you coded at least one of VARYING and OPTIONS(*VARSIZE). For return values matching Java byte arrays, you should always code VARYING unless the Java method always returns a fixed-length string. Regarding whether RPG calls NewString under the covers for the String constructor ... no. It doesn't notice that it's calling the constructor for java.lang.String, it just calls whatever it's asked to call. Regarding performance of return values, the issue with returning large values doesn't come up for Java method calls; if your Java method returns a byte array, the JNI function actually returns a 4-byte integer "object reference" to the Java array object. The RPG runtime fetches the array data and does the ASCII/EBCDIC conversion (on the actual length of data that was returned). But the storage for the return value is passed to the RPG runtime as a parameter from the RPG generated code. Regarding performance of parameters, for CONST parameters, usually no temporary is created if the format of the passed parameter matches the prototype. So if you will most often be passing varying length parameters, code VARYING, and if you will most often be passing fixed length parameters, code OPTIONS(*VARSIZE) without VARYING. (This parameter passing stuff applies to all calls with CONST, not just Java method calls.)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.