RFR: 8254354: Add an asExact() VarHandle combinator

Jorn Vernee jvernee at openjdk.java.net
Fri Oct 23 17:55:52 UTC 2020


Hi,

This patch adds an asExact() combinator to VarHandle, that will return a new VarHandle that performs exact type checks, similar to MethodHandle::invokeExact, to help developers catch inexact VarHandle usage, which can lead to performance degradation.

This is implemented using a boolean flag in VarForm. If the flag is set, the exact type of the invocation is checked against the exact type in the VarForm. If there is a mismatch, a WrongMethodTypeException is thrown.

Thanks,
Jorn

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

Commit messages:
 - Add an asExact() combinator to VarHandle

Changes: https://git.openjdk.java.net/jdk/pull/843/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=843&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8254354
  Stats: 1339 lines in 10 files changed: 962 ins; 64 del; 313 mod
  Patch: https://git.openjdk.java.net/jdk/pull/843.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/843/head:pull/843

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


More information about the core-libs-dev mailing list