ride_on_the_NOP_sled
ride_on_the_NOP_sled

Reputation: 135

Reflection dalvik.system.DexClassLoader.findClass() NoSuchMethodException

For method:

Ldalvik/system/DexClassLoader;->findClass(Ljava/lang/String;)Ljava/lang/Class;

that DexClassLoader inherits from ClassLoader

The following call to Class.getMethod() fails with a NoSuchMethodException:

Class.forName("dalvik.system.DexClassLoader")).getMethod("findClass",Class.forName("java.lang.String"))

I don't understand why this call fails. Unless I am missing something, the method is inherited and should be returned.

Upvotes: 1

Views: 117

Answers (1)

ride_on_the_NOP_sled
ride_on_the_NOP_sled

Reputation: 135

findClass is protected and will thus not be returned by getMethod(). Instead getDeclaredMethod() should be used, as it will also return private and protected access level methods.

Upvotes: 1

Related Questions