Hi Rick,
On 22.11.2023 16:09, Rick Troth wrote:
Are you saying that you can call Java from ooRexx?
Yes.
How does that happen?
There is a DLL/shared object that can be linked by both, ooRexx and Java. It allows for going either
direction: call Java from ooRexx, but also call ooRexx from Java or from any JVM language (you
mentioned Scala, Clojure, Groovy and friends, also the very first JVM language NetRexx).
Do you spin-up a JVM running in standby mode?
ooRexx allows for libraries of Rexx/ooRexx code (named "packages"). If that library gets called by
any Rexx/ooRexx program it will check whether a JVM is already running or not, if not, it will use
the DLL/shared object to demand load the JVM.
Do you run ooRexx in a JVM?
Yes, that is possible too.
I can call native code from Java, but always have to transit the JNI.
JNI gets used behind the curtain, but the Rexx or Java programmer will never
get to see JNI.
Never been able to go the other direction.
The ooRexx-Java bridge works in both directions.
The JVM is the single most difficult (for me, but I have lots to learn) barrier to inter-language
operation with Java (other than Scala, Clojure, Groovy and friends which already run "in" the JVM).
The way to go from Java is via the Java scripting framework in the Java package named javax.script
(while the JSR-223 group developed that framework I served as one of the experts). Here a Java
example of how to run a Rexx or ooRexx script, supplying arguments to Rexx and fetching and showing
the return Rexx result:
import javax.script.*;
public class TestCallRexx
{
public static void main (String args[])
{
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine se = manager.getEngineByName("rexx");
String rexxCode = "say '(Rexx) argument from Java:' arg(1)
\n" +
"do i=1 to arg() /* iterate over arguments */
\n" +
" say '(Rexx) arg #' i':' arg(i)
\n" +
"end
\n" +
"parse version v /* Rexx version */
\n" +
"say '(Rexx) parse version:' v
\n" +
"parse source s /* Rexx version */
\n" +
"say '(Rexx) parse source:' s
\n" +
"/* get the operating system and version via
Rexx\n" +
" and return it within the following string */
\n" +
"return 'from ooRexx:' sysVersion()
\n";
try
{
ScriptContext sc=se.getContext(); // get the default
ScriptContext
// add the fileName to the ENGINE_SCOPE bindings
sc.setAttribute(ScriptEngine.FILENAME, "TestCallRexx",
ScriptContext.ENGINE_SCOPE);
// add arguments for the script to the ENGINE_SCOPE bindings
Object args4script[]=new Object[] {"one", "zwei", "tre",
"quatre"};
sc.setAttribute(ScriptEngine.ARGV, args4script,
ScriptContext.ENGINE_SCOPE);
// the RexxScriptEngine always compiles the last script and
makes it available with the getCurrentScript() method
Object o=se.eval(rexxCode,sc); // now let us re-execute
the Rexx script
System.out.println("(Java) received from Rexx: "+o);
}
catch (Exception exc)
{
System.err.println(exc);
System.exit(-1);
}
System.exit(0);
}
}
Here the output running the above Java program:
G:\test\java\jsr223>java TestCallRexx
REXXout>(Rexx) argument from Java: one
REXXout>(Rexx) arg # 1: one
REXXout>(Rexx) arg # 2: zwei
REXXout>(Rexx) arg # 3: tre
REXXout>(Rexx) arg # 4: quatre
REXXout>(Rexx) arg # 5: a Slot.Argument
REXXout>(Rexx) parse version: REXX-ooRexx_5.1.0(MT)_64-bit 6.05 22 Oct 2023
REXXout>(Rexx) parse source: WindowsNT SUBROUTINE TestCallRexx
(Java) received from Rexx: from ooRexx: Windows 10.0.19045
Not sure whether the formatting is distorted (used preview style).
You can supply any type of argument to Rexx and fetch any type of return value
from Rexx.
As you can see it is very easy to use from Java.
---
Here a sample that would automatically load the JVM in order to use the Java
class java.awt.Dimension:
dim=.bsf~new("java.awt.Dimension", 100, 200) /* create a Java object */
say dim~toString /* will invoke the Java method toString */
::requires BSF.CLS /* ooRexx package (ooRexx-Java bridge) */
Here the output:
java.awt.Dimension[width=100,height=200]
As you can see, truly a Java object is being used from ooRexx, without a need to know any of the
Java syntax, just the documentation of those Java classes. In the case of java.awt.Dimension cf.
e.g. <https://docs.oracle.com/javase/8/docs/api/java/awt/Dimension.html>.
The above oRexx program could also be executed via the Java scripting framework as demonstrated
above without a need to change anything in the code.
---rony
On 11/17/23 10:00, Rony G. Flatscher wrote:
On 16.11.2023 22:54, David Crayford wrote:
I don't find ooRexx useful on the PC as it's basically on life support
where Python has millions of contributors. Take data validation as an
example. There is a first class library https://docs.pydantic.dev/latest/.
Python isn't my favorite language by a large margin. But it is useful so it
wins. Same same with Java. Personal preference is secondary to a pragmatic
choice.
The combination of ooRexx [1] with Java [2] - on all platforms - allows one to exploit all of
Java (the Java runtime environment) as a huge external class library for ooRexx. Unlike with
Python there would be no need to locate, choose and import specific modules with the needed
functionality, rather one can use the Rexx skills to immediately exploit all of the Java
functionality on all platforms.
It is hard to realize/assess the potential of this combination without a little bit of curiosity
and the will to learn new tricks.
---rony
[1] ooRexx download site:
<https://sourceforge.net/projects/oorexx/files/oorexx/>
[2] ooRexx-Java bridge (BSF4ooRexx850) download site:
<https://sourceforge.net/projects/bsf4oorexx/files/beta/20221004/>
On Fri, Nov 17, 2023 at 5:32 AM Seymour J Metz <sme...@gmu.edu> wrote:
I find REXX extremely useful on PCs, but TSO/E REXX is a backwater
compared to ooRexx, and I would be tempted to use Java or Python for
complicated TSO scripts. But on z/Linux ooRexx with BSF4REXX is a viable
option.
--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3
עַם יִשְׂרָאֵל חַי
________________________________________
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> on behalf
of David Crayford <dcrayf...@gmail.com>
Sent: Thursday, November 16, 2023 4:02 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: External Functions in C on z/OS
I choose a language on capabilities rather than personal preference. I’ve
been accused on this forum by my ex-colleague and pal Wayne Bickerdyke of
having a pathological dislike of REXX. That’s not true, but I do find it
less useful than other languages. Python has a useful library called ctypes
which includes classes for mapping data structures with Python classes. We
use BigEndianStructure for mapping control blocks
https://docs.python.org/3/library/ctypes.html#ctypes.BigEndianStructure.
It would be cool if the tooling that we worked on with Peter Relson to
create C header files could be reused to generate Python mappings. With the
recent zIIP offloading Python is strategic.
On 17 Nov 2023, at 12:38 am, Charles Mills <charl...@mcn.org> wrote:
Different strokes for different folks.
1. I was not aware of that pointer. This is the classic documentation
problem. The answer is right there in the manual, clear as day -- provided
you know where to look. A lot of these answers are easy to find, assuming
you already know the answer.
2. My code is running a complex Rexx environment that frankly I do not
fully understand. (I didn't write it and it isn't "mine.") I wanted to be
sure I had THE right environment block, not SOME environment block. An
11-instruction assembler module seemed like a great solution. I still
believe that it was.
Charles
On Thu, 16 Nov 2023 11:31:20 +0800, David Crayford <dcrayf...@gmail.com>
wrote:
There's a TSO/E vector table that has the address of the REXX routines.
// get the address of the TSO/e vector table
CVT * cvt = *(( CVT ** ) CVTPTR);
TSVT * tsvt = cvt->cvttvt;
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
--
--
__________________________________________________________________________________
Prof. Dr. Rony G. Flatscher
Department Wirtschaftsinformatik und Operations Management
Institut für Wirtschaftsinformatik und Gesellschaft
D2c 2.086
WU Wien
Welthandelsplatz 1
A-1020 Wien/Vienna, Austria/Europe
http://www.wu.ac.at
__________________________________________________________________________________
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN