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



Steve Richter wrote:

> What happens when the RPG procedure that instantiated the object returns?  
> Does the java object destruct and does the finalize member function get 
> called?  

No.  The underlying support is JNI; Java never frees objects created by
native programs because it has no idea of what the native program is
doing.  The RPG runtime can't keep track of object references, so it's
up to the RPG programmer to free the objects.  See here for a way to
handle this fairly painlessly:
http://faq.midrange.com/data/cache/282.html

(RPG has support for writing Java native methods in RPG too.  For native
methods that are called by Java, any objects created by the native
method are freed by default when the native method returns, so doing
Java->RPG is easier than doing RPG->Java in this respect unless you
actually want to save the object from being freed in which case it
becomes complex again.)

> What happens when the Java code throws and exception?  
> Can the RPG procedure catch it?   

Sort of, but the RPG procedure doesn't get an Exception object.  The RPG
runtime "catches" the Exception and turns it into an RNX0301 message,
with the replacement text containing the toString() value of the
Exception.  If you wanted your RPG procedure to get the Exception
object, you'd have to write a Java wrapper, or you could roll your own
JNI call using the RPG version of jni.h (QSYSINC/QRPGLESRC,JNI).

Actually, there's not much difference in the RPG<->Java function between
V5R1 and even V5R3.  (I don't know if V5R1 supports all the JDK versions
that V5R3 support, though).  The V5R3 RPG support adds a bit better
support for exceptions, since you can now see the exception trace if you
want.  But in general, it's really just the RPG manuals that have gotten
better.

A warning if you do start using RPG's Java support in V5R1: in V5R1, the
system allows the JVM to be destroyed and restarted.  This ability is
removed in V5R2, so don't build a dependency on it.  I'd recommend using
the V5R3 version of the ILE RPG Programmer's Guide even if you are on
V5R1.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.