No pitfalls; it works the same as you would expect if you expect the actual behavior :) Also, the equals()
method for Class
objects is only inherited from Object
, which in any case uses the ==
operator.
The only surprising part is that if the same class file is loaded by two different class loaders, you will get two separate class objects that will be compared as false
. This is by design.
source share