How can I improve performance of Field.set (perhap using MethodHandles)?

2015-06-01: Updated to reflect @JoeC’s comment about another case when handles are static. Also updated to latest JMH and re-ran on modern hardware. The conclusion stays almost the same. Please do proper benchmarking, it is arguably not that hard with JMH. Once you do that, the answer becomes obvious. It can also showcase the proper … Read more