I'm trying to invoke a method via reflection. The method in question, let's say
public void someMethod(someInterface arg1)
I do not have access to someMethod and someInterface at runtime, and have to invoke by
someclass.getMethod("someMethod", new Class[]{Class.forName("someInterface")})
.invoke(...)
But it fails with a ClassNotFound exception for someInterface. How do I get the Class object for interfaces?
解决方案
I believe that you forgot the interface's package. You have to use fully qualified class name when you are calling Class.forName(), i.e. Class.forName('com.mycompany.MyClass')