I have a public method defined as the following code,
public int getSerial()
{
return this.serial;
}
Then I am using java reflection to get the method with the following code,
Class c = type.getClass();
try {
Method m = c.getClass().getMethod("getSerial",null);
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
However, I keep getting the following error.
java.lang.NoSuchMethodException: java.lang.Class.getSerial()
I am confused as to why this error is happening, I have seen it happen before when a method was private when using the getMethod() method. However, mine is a public method and takes the right parameters, which is null. So I am not too sure why this error keeps happening. Does anyone have any input on to why this error keeps happening when I use the getMethod() method?
Aucun commentaire:
Enregistrer un commentaire