> I pretty sure there is an item in Effective Java saying that It's bad 
> practice to have a method that return null instead of an empty array.

This is true, but remember where this method lives — java.lang.Class.  All the 
other methods return null here.  So if we were to do the new one “right”, now 
the poor users are in an _even worse_ situation — some of the methods do the 
wrong thing — but not all of them, and so the user has to keep it in their head 
to remember which is which!  

The lesser of evils here is to follow the convention established by previous 
reflection methods, especially — as Maurizio pointed out — the name of the 
method screams “don’t call me if you’re not a record.”  



Reply via email to