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



Barbara,

Thanks for clarifing my questions and comments.  In one of my posts
I mentioned how there seemed to be no impact in combining VARYING
with OPTIONS(*VARSIZE).  Is this a valid observation?  Given your
feedback, does it make sense, as a best practice, to combine the 2?

Regards,

Michael Rooney
Citigroup International



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Barbara Morris
Sent: Friday, June 04, 2004 8:15 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Prototyping a constructor of java String class


"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.)

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