This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Problem
Amit M wrote:
> Hello
> Here is My problem,
>
> I am doing My Last year academic project named "j4cpp wrapper" .In
> this project, I am generating wrapper to call java .class files from
> c++ so that c++ user can just add that wrapper (which will be just a
> header file(.h) ) to invoke methods of that java class file. Here I am
> using Invocation API's (kind of Reverse JNI ).
>
> Now my current status is as follows :
> code for Wrapper generation for basic datatypes (such as
> int,char,float ) and arrays are done.
> But now i got problem when a java class( having any java class library
> object such as Frames etc..in it. ) i dont know how to deal with
> it....how to load them so that c++ user can access to those methods ?
>
> here is the structure of wrapper which my application generates :
>
> *wrapper name is same as class file name with .h extension.
> (name of file abc.h)
> #include "jvm.cpp" // this file does all JVM loading related work.
> class abc // same name as java class name(retrieved
> using reflection api's )
> {
> private :
> invocation_api invoke; //object used to invoke and load JVM.
> public :
> abc() {invoke.create_vm();}
>
> void method1(int,int);
> }
>
>
> void abc::method1(int arg1, int arg2)
> {
>
> jvalue returnValue;
> Invoke.invoke_class("abc", "method1", "(II)V", &returnValue, arg1, arg2);
> /* This function resides in jvm.cpp file which is included @top.
> This function takes class name, method name, method signature, jvalue
> reference variable and arguments if any. Users are not allowed to
> change this line. */
>
> // add user code here if he wants...
>
> }
> //****************************** MAIN PROBLEM
> *****************************************
>
> Now consider a class file in which some method x takes arguments as
> Frames object....
> then how i shuold call that methods which resides in that class ?
> do i have to wrap that library class ? if yes how ?what will be the
> structure of that wrapper ?
>
> Any Links , s/w , pdf which can help me to solve problem are most welcome.
I don't actually understand the problem. The invocation API is quite
well-defined and allows you to call any Java method. If you need to
pass a Java object to a Java method you'll have to call AllocObject
to create one, and if that's to be available as a C++ class you'll
have to generate a C++ wrapper.
Andrew.