On Tue, 19 Apr 2022 13:19:31 GMT, Claes Redestad <redes...@openjdk.org> wrote:
> Trivially fix the resolution of the `NF_UNSAFE` named function to use the > appropriate lookup mode. > > In [JDK-8187826](https://bugs.openjdk.java.net/browse/JDK-8187826) we changed > from regular reflection to use a `NamedFunction` for this field, but it > appears the lookup mode came out wrong. This mismatch appears to be benign > and ignored by HotSpot, but a user implementing an experimental JVM ran into > some issues (and additionally noticed the resolve throws the wrong > exception). > > This patch is a point fix to this particular issue, but I think we should > consider following up with a stronger assertion or test for proper staticness > of fields somewhere when resolving fields via > `MemberName.getFactory().resolveOrNull(..)`. src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java line 901: > 899: MemberName member = new > MemberName(MethodHandleStatics.class, "UNSAFE", Unsafe.class, REF_getStatic); > 900: return new NamedFunction( > 901: > MemberName.getFactory().resolveOrFail(REF_getField, member, `REF_getField` passed to `resolveOrFail` should also be corrected? ------------- PR: https://git.openjdk.java.net/jdk/pull/8297