RFR: 8271820: Implementation of JEP 416: Reimplement Core Reflection with Method Handle [v12]
Mandy Chung
mchung at openjdk.java.net
Tue Oct 12 22:48:47 UTC 2021
On Tue, 12 Oct 2021 17:44:08 GMT, Peter Levart <plevart at 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
More information about the core-libs-dev
mailing list