Reputation: 591
jclass class= env->FindClass("java/util/ArrayList");
listClass = (jclass)env->NewGlobalRef(class);
listAddAllID = env->GetMethodID(listClass, "addAll", "(Ljava/lang/Object;)Z");
I got the following exception for the above code "java.lang.NoSuchMethodError: addAll".I used 'lang/object' for a parameter and 'z' for return type boolean.It seems to be right completely.What am I missing here?
public boolean addAll(Collection c)
Upvotes: 0
Views: 265
Reputation: 310980
It seems to be right completely.
Incomprehensible. It is completely wrong. The API says the parameter is a Collection
.
Don't guess at these things, and don't try to write JNI method sigmatures yourself. Use the output of javap -s
. It is never wrong.
Upvotes: 0
Reputation: 13385
You can always use javap
to get proper descriptor of method
> javap -s java.util.ArrayList | grep -A +1 addAll
public boolean addAll(java.util.Collection<? extends E>);
descriptor: (Ljava/util/Collection;)Z
--
public boolean addAll(int, java.util.Collection<? extends E>);
descriptor: (ILjava/util/Collection;)Z
So, you need to change it to one of these (depending on the call you want to make).
Have fun with JNI!
Upvotes: 1