On Mon, 22 Nov 2021 20:01:50 GMT, Mandy Chung <mch...@openjdk.org> wrote:

>> java.lang.reflect.Field::set on static field with invalid argument type 
>> should throw IAE.  But this regression is introduced by JEP 416 throwing NPE 
>> instead.
>> 
>> `ensureObj` is called as the first check of the `Field::set` method to 
>> ensure the receiver object is checked first before the argument.   For a 
>> Field instance with write-access, the method handle invocation will check 
>> the receiver.  Therefore for `Field::setXXX` methods to set a primitive 
>> value, `ensureObj` is only called if it's a read-only Field instance to 
>> ensure IllegalArgumentException is thrown first before 
>> IllegalAccessException to keep the existing behavior to avoid duplicated 
>> receiver check.
>
> Mandy Chung has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Improve the exception message when the type is not available

Marked as reviewed by alanb (Reviewer).

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

PR: https://git.openjdk.java.net/jdk/pull/6490

Reply via email to