Reputation: 20050
According to this link, in order to invoke Java methods from native (C++) code using JNI, the GetMethodID function is used to:
"return the method ID for an instance (nonstatic) method of a class or interface."
Consider, as an example, the following constructor of the File class:
public File(Uri uri)
A JNI method signature for this constructor would be:
"Ljava/io/File;.(Landroid.net.Uri;)V"
But, since Uri is an abstract class, is it possible to retrieve the method ID for this constructor using a signature that contains types that are derived from Uri ?
*I am asking this, since I'm using an environment where the actual signature is being automatically created based on the runtime object type, but that seems to fail, but i am not sure if its a limitation of JNI or a bug in the signature creation code, or something else entirely.
Upvotes: 1
Views: 708
Reputation: 310980
The signature of a method is determined by its own source code, not by what you want to call it with. If all you have is the actual argument list rather than the formal parmaeter types, you don't have enough information to generate it at runtime.
But I cannot understand why you would want or need to generate it at runtime in the first place, or why you would want or need to do this via JNI. Maybe you should be looking at java.beans.Statement
and friends.
I'm using an environment where the actual signature is being automatically created based on the runtime object type
No you aren't, because it isn't possible. You have misunderstood, or you are attempting the impossible.
Upvotes: 2