[3153] in java-interest
Re: native c mthds calling java mthds
daemon@ATHENA.MIT.EDU (Thomas Ball)
Wed Nov 1 19:27:35 1995
Date: Wed, 1 Nov 1995 12:25:58 -0800
From: Thomas.Ball@Eng.Sun.COM (Thomas Ball)
To: dgourley@cs.berkeley.edu
Cc: java-interest@java.Eng.Sun.COM
> This might be a naive question, but how would one go about having a native
> method invoke a java class method. I have a c library that I would like to
> have callback a java method I have written. Any help in how to go about
> doing this would be appreciated.
>
> -david
No questions regarding native methods are naive -- the 1.0 JDK is focused
on applet development, and native method writers have to wing it a bit
until we ship that first chunk. Here are the necessary calls:
Constructors:
/* Create a String object from an array of chars (val) */
execute_java_constructor(EE(), JAVAPKG "String", 0, "([C)", val);
Static methods:
/* This run's a loaded class' "void main(String argv[])" method */
execute_java_static_method(0, unhand(c), "main",
"([Ljava/lang/String;)V", argv);
Other methods:
/* This gets the number of elements in the pItems array */
short ctItems = execute_java_dynamic_method(EE(),
(HObject*) pItems,
"size", "()I");
Each of these are vararg functions, where the number of arguments is
determined by the signature string parameter. signature.h is the
rosetta stone for signature building and parsing.
Tom Ball
Java Products Group
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com