RFR: 8254354: Add an asExact() VarHandle combinator [v6]
    Jorn Vernee 
    jvernee at openjdk.java.net
       
    Mon Oct 26 13:41:36 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.
> 
> Other than that, there is also an asGeneric() combinator added that does the inverse operation (thanks to Rémi for the suggestion). I've also added The `@Hidden` annotation to the VarHandleGuards methods, as well as a type-checking helper method called from the generic invocation lambda form, so that the stack trace we get points at the location where the VarHandle is being used.
> 
> Thanks,
> Jorn
Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
  Add benchmarks
-------------
Changes:
  - all: https://git.openjdk.java.net/jdk/pull/843/files
  - new: https://git.openjdk.java.net/jdk/pull/843/files/354e233b..7b5966dd
Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=843&range=05
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=843&range=04-05
  Stats: 170 lines in 2 files changed: 170 ins; 0 del; 0 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