Reputation: 568
I have a java class calling a native function through jni.The java class consists of the following method.
public void indexToEs(ArrayList<LinkedHashMap <String , Object>> list) throws IOException
{
IndexingLogDataToES indexingobj = new IndexingLogDataToES();
indexingobj.indexLogData(list , logName, client);
}
Now how should i specify the method signature in order to get the method Id of this method in my native function. i tried the following but it didnt work.i get method id as null.
jmethodID indexMethod = env->GetMethodID(callingClass , "indexToEs" , "(Ljava/util/ArrayList(Ljava/util/LinkedHashMap;);)V");
if( indexMethod == NULL )
{
cout << "index method not found" << endl ;
return ;
}
else cout << "index method found" << endl ;
Where calling class is the reference to the class calling.How should i do this.Thanks in advance.
Upvotes: 0
Views: 914
Reputation: 10127
Because of type erasure the type parameters don't get compiled into the class file.
Therefore, the method void indexToEs(ArrayList<LinkedHashMap<String,Object>>)
has the same signature as the method void indexToEs(ArrayList)
would have.
That means, the method signature is just (Ljava/util/ArrayList;)V
and you should call
env->GetMethodID(callingClass , "indexToEs" , "(Ljava/util/ArrayList)V");
Upvotes: 1