mardi 2 juin 2015

Java Reflection: calling getDeclaredMethods() on a class from a jar returning null

I have a jar which has a class Foo that contains a public method test(), and I am writing an app that uses this jar and I am trying to call getDeclaredMethods() on Foo but it doesn't return me the public method. What could go wrong?

In the jar:

public final class Foo {
 public void test() {
     //do something
 }
}

In the app:

Class<?> clazz = foo.class;
Method[] methods = clazz.getDeclaredMethods();

So the problem is that methods doesn't return the public method test.

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire