How can you invoke a method using the Reflection API? - Cracking the Java Coding Interview

preview_player
Показать описание
Cracking the #Java #Coding #Interview - Question 96: How can you invoke a method using the Reflection API?
Рекомендации по теме
Комментарии
Автор

Of note, the object of invocation is ignored when calling static methods.

pavlg
Автор

As i understand it for now, invocation method using the Reflection API isn't the best idea because of poor performance. The main reason for that is JVM has to check it's accesibility before executing. Perhaps Method Handlers API works much faster in that regard, but it's harder to utilize.

qbert
Автор

This is really helpful

I didn't know we can invoke private methods using reflection API

I always wondered why people use reflection

jskr
Автор

I saw some developers try this trick to test the private method and I hate that. Instead, they can change the method accessibility then test it within a same package. But they always don’t do it and have a lot of reasons for it which are not reasonable.

longtranhoang