[Info-vax] Is it possible to write a JNI to give Java the VMS calling standard?
Dirk Munk
munk at home.nl
Sun Aug 30 11:42:19 EDT 2015
Arne Vajhøj wrote:
> On 7/1/2015 7:52 AM, Dirk Munk wrote:
>> A Java Native Interface (JNI) is a piece of software that makes it
>> possible to call Java from another language, or another language from
>> Java.
>>
>> As we all know, VMS has a calling standard that makes it possible to
>> call routines written in another language. Java obviously doesn't have
>> that, however I imagine that a VMS specific Java Native Interface could
>> offer the standard calling interface?
>
> Let us assume that Java->native is the most interesting.
>
> For fun I tried creating a generic JNI solution that allows to
> call a routine in a shareable image from Java using VMS calling
> standard syntax.
>
> This is now working:
>
> private static void testDefaultAccessTraditionalStyle() {
> try {
> CharacterString buf = new CharacterString(255);
> Word retlen = new Word();
> int sts = call("LIBRTL", "LIB$GET_LOGICAL",
> byDescriptor(new CharacterString("DISK2")),
> byDescriptor(buf),
>
> byReference(retlen));
> String res = createString(buf, retlen);
> System.out.println(sts + " |" + res + "|");
> } catch(Exception ex) {
> ex.printStackTrace();
> }
> }
> private static void testExplicitAccessTraditionalStyle() {
> try {
> CharacterString buf = new CharacterString(255);
> Word retlen = new Word();
> int sts = call("LIBRTL", "LIB$GET_LOGICAL",
> readOnly(byDescriptor(new CharacterString("DISK2"))),
>
> writeOnly(byDescriptor(buf)),
>
> writeOnly(byReference(retlen)));
> String res = createString(buf, retlen);
> System.out.println(sts + " |" + res + "|");
> } catch(Exception ex) {
> ex.printStackTrace();
> }
> }
> private static void testDefaultAccessFluentStyle() {
> try {
> CharacterString buf = new CharacterString(255);
> Word retlen = new Word();
> int sts = call("LIBRTL", "LIB$GET_LOGICAL", pass(new
> CharacterString("DISK2")).byDescriptor(),
>
> pass(buf).byDescriptor(),
>
> pass(retlen).byReference());
> String res = createString(buf, retlen);
> System.out.println(sts + " |" + res + "|");
> } catch(Exception ex) {
> ex.printStackTrace();
> }
> }
> private static void testExplicitAccessFluentStyle() {
> try {
> CharacterString buf = new CharacterString(255);
> Word retlen = new Word();
> int sts = call("LIBRTL", "LIB$GET_LOGICAL", pass(new
> CharacterString("DISK2")).byDescriptor().readOnly(),
>
> pass(buf).byDescriptor().writeOnly(),
>
> pass(retlen).byReference().writeOnly());
> String res = createString(buf, retlen);
> System.out.println(sts + " |" + res + "|");
> } catch(Exception ex) {
> ex.printStackTrace();
> }
> }
>
> The syntax a a little bit cumbersome, but it is very
> VMS-calling-standard'ish.
>
> Drop me a note if someone want a copy.
>
> Arne
>
>
Thanks Arne.
I did some more reading on this subject. If I get this correct, JNI is a
piece of software that reads a Java source and produces the C code to
call the Java routine (Or Java can call a C routine).
JNI has nothing to do with the Java language itself. With that I mean
that you are not allowed to change anything on Java itself, as Microsoft
discovered. JNI does no such thing.
IBM has a similar utility, but it produces Cobol routines, so you can
call Java directly from Cobol.
Conclusion: You're free to write any utility that can produce the
calling standard you like, incl. the VMS calling standard.
More information about the Info-vax
mailing list