RFR: 8285007: Use correct lookup mode for MethodHandleStatics.UNSAFE

Claes Redestad redestad at openjdk.java.net
Tue Apr 19 13:26:44 UTC 2022


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(..)`.

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

Commit messages:
 - Use correct lookup mode for MethodHandleStatics.UNSAFE

Changes: https://git.openjdk.java.net/jdk/pull/8297/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8297&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8285007
  Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8297.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8297/head:pull/8297

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


More information about the core-libs-dev mailing list