RFR: 8371953: Document null handling in core reflection APIs [v3]

Chen Liang liach at openjdk.org
Wed Nov 19 13:34:53 UTC 2025


On Wed, 19 Nov 2025 07:32:14 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Removed erroneous comment
>
> I went back through the nestmates design archives that I have to see if this particular issue was ever raised but I could not find it called out. I'm not a fan of explicit null checks as they penalize all the good code. I also don't think the inconsistency is/was an issue. If code does not need to use a parameter to complete its function then it also doesn't need to validate the unused parameter. YMMV.

I think checking ahead is better. If we move c.isPrimitive call to be before isPrimitive, the new consistent NPE becomes a compatibility risk. Better perform checks early to prevent compatibility constraints. And I don't think c is an unused parameter here.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28336#discussion_r2542027546


More information about the core-libs-dev mailing list