Another reminder of java reflection

Java reflection is powerful, but there are much more things to watch out.

I went into below error when invoke a method using reflection:

java.lang.IllegalArgumentException: object is not an instance of declaring class

It take me almost one whole day to find out the reason, that is I invoke method on class loaded from different Class loader, although the Class looks like the same.


When debugging Java code in eclipse, every variable has a (id=**) at the end. It can be used to determine if tow objects, including Class, are the same one.