I hope to know if an invoked method has a Java method body at runtime in an Android app/Java application.
For example, in the following code, a method f
is invoked
obj.f();
To know whether f
has a method body, I use reflection to get its modifiers and then check if the method is a native method:
int modifiers = obj.getClass().getMethod("f", new Class[] {}).getModifiers();
if(Modifier.isNative(modifiers)) {
// No method body
} else {
// has method body
}
My question is: except native methods, are there any other possible cases in which an invoked method does not have a Java method body? Abstract or interface methods are not possible since at runtime, what have been invoked must be concrete methods that implement them.
Aucun commentaire:
Enregistrer un commentaire