On Thu, 6 Apr 2023 18:03:09 GMT, Chen Liang <li...@openjdk.org> wrote:
>> test/micro/org/openjdk/bench/java/lang/invoke/MethodHandleProxiesAsIFInstanceCall.java >> line 176: >> >>> 174: public void constantLambda() { >>> 175: i = constantLambda.doWork(i); >>> 176: } >> >> I think setting the result into an instance field like this can work, but >> it's imo better to let JMH handle it. So, these methods should just return >> the value instead of writing it to the `i` field. > > I think the point here is to make sure work is done by ensuring the VM cannot > figure out the input value to doWork, isn't it? To make that more clear, I > decide to initialize i to a random value from identity hash code instead. That too. But I'm talking about the value that is assigned to the field after calling `doWork`. That value should be 'consumed' as well. IMO it's better to do that the conventional way, by returning the value (or using a Blackhole). i.e. let JMH handle it. (IIRC writing the value to a field like this has some issue with it as well) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/13197#discussion_r1160109421