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



Hi, Scott:

For the same years, I have found that when Java errors occur when
testing those functions ...the interactive job is virtually useless
to Java. Cannot start a new Java session, and cannot recover the old
one.

Hmmm.... that's not entirely true. If you get an error from Java in
RPG, you can typically run more Java without a problem.

However, if you do something like pass a *NULL object reference to a
Java function, you will cause the whole JVM to crash -- and _then_
you'll be in the state that you describe, where Java is useless until
you sign off or RRTJOB.

Yes, that was it (the *NULL object reference), and I had not picked up on
the fact that this (monitorable) condition is actually at the source of my
woes. Ultimately, if a java function fails - resulting in *NULL return, my
code tends to go on to the next thing since there's no trap capability
between Java and RPG. So the next statement (that uses the value that
resulted from the failure) is what crashes the JVM! Interesting! This, I
can deal with! I'll make my own "trap" at points where it makes sense.

After running RRTJOB you can restart the JVM. This is mildly less
bothersome than signing off and on again. (However, this RRTJOB trick
doesn't seem to be documented anywhere -- so I wouldn't use it in a
program.)

Nice trick. Thanks!

But the best thing to do is write your RPG so that when you get an
error
from Java, the program immediately aborts, and doesn't try to use the
bad object reference that might've just been created. I realize that
it's easy to have bugs that don't follow this recommendation -- but if
you make an effort to catch all of the *NULL object references before
they get used, the "must restart the JVM" situation doesn't come up as
often.

Yes, I see that now! Since most of the stuff I write either has a wrapper
or could have a wrapper, this will be pretty easy (everything is relative)
to overcome. Thanks again, Scott.

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"An optimist proclaims that we live in the best of all possible worlds - the
pessimist fears this is true."
-- James Branch Cabell




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.