RFR (S) 8073479: Replace obj.getClass hacks with Objects.requireNonNull

Aleksey Shipilev aleksey.shipilev at oracle.com
Thu Feb 19 15:17:20 UTC 2015


Hi Daniel,

On 02/19/2015 06:03 PM, Daniel Fuchs wrote:
> +1 for the java.logging changes :-)

Good, thank you!

> I wonder whether there was a subtle reason for calling
> .getClass() in java.lang.invoke? Maybe class initialization
> or whatever?

As far as I understand, if you are checking the argument, then it means
you are being handed over the object instance, then somebody already did
the instantiation, which means the class representing the object is
already initialized.

I think getClass() is just a trick employed in the absence of
Objects.requireNonNull.

Thanks,
-Aleksey.




More information about the core-libs-dev mailing list