I need to call some Java methods using C/C++ and then I need to use DPI in UVM or system verilog to call C methods. I dont have access for JAVA files or JAVA classes. I have a .jar file in which my class is present of which methods I need to access.
I am using path of that .jar file in
options.optionString = "-Djava.class.path= path of .jar file
I am able to find class using
clsH = env->FindClass("com/act/testdev/pa5/PA5");
But I am not able to get method ID. I know only method's name in java class which is a boolean method with boolean arguments
com.act.testdev.pa5.PA5.aes_encrypt(key_data, pt_data);
This method is used in some other language and here is the code of that:
boolean[] aes_encrypt(boolean key_data[], boolean pt_data[])
{
return com.act.testdev.pa5.PA5.aes_encrypt(key_data, pt_data);
}
Here is the code which I am trying to use to get the methodID:
if (clsH != NULL)
{
midMain = env->GetMethodID(clsH, "aes_encrypt", "([Z[Z)[Z");
printf("\n FOUND able to find the requested class midMain ==%x ==%x\n",midMain,clsH);
}
else
{
printf("\nUnable to find the requested class\n");
}
if (midMain != NULL)
{
printf("\nable to find the requested Method\n");
jbooleanArray BoolArg1 = env->NewBooleanArray(128);
jbooleanArray BoolArg2 = env->NewBooleanArray(128);
env->CallBooleanMethod(clsH,midMain,BoolArg1,BoolArg2);
}
Please help me on this how can I access this method in c/c++. there are some more methods also I need to call in same way once I am able to call this will try those later. I dont have any Idea of JAVA I got this code online as a example of how to call java methods from c/c++.
What I have tried:
I have created a CTest.cpp file in that I have just given path for .jar file which has java classes. and I am just using this command to execute the .cpp file
g++ -I/soft/uo/jdk1.8.0_11/include -I/soft/uo/jdk1.8.0_11/include/linux -L/soft/uo/jdk1.8.0_11/jre/lib/amd64/server -ljvm CTest.cpp