Clarifying record reflective support

Brian Goetz brian.goetz at
Wed Dec 4 14:46:01 UTC 2019

> 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.”  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the amber-spec-experts mailing list