On Tue, 12 Oct 2021 17:44:08 GMT, Peter Levart <plev...@openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/reflect/MethodHandleCharacterFieldAccessorImpl.java
>>  line 137:
>> 
>>> 135:     {
>>> 136:         if (isReadOnly()) {
>>> 137:             ensureObj(obj);     // throw NPE if obj is null on 
>>> instance field
>> 
>> I think ensureObj(obj) must go before if statement in setChar
>
> No, it's OK. You are relying on `setter.invokeExact(obj, c)` to throw NPE 
> later...

Yup.  This `ensureObj(obj)` call on a Field with no-write access is to ensure 
NPE is thrown before IAE consistent with the current behavior.

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

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

Reply via email to