[Info-vax] Is it possible to write a JNI to give Java the VMS calling standard?
Arne Vajhøj
arne at vajhoej.dk
Sat Aug 29 22:38:38 EDT 2015
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
More information about the Info-vax
mailing list