RFR: 8288327: Executable.hasRealParameterData should not be volatile [v7]
Peter Levart
plevart at openjdk.org
Mon Jul 4 21:25:34 UTC 2022
On Mon, 4 Jul 2022 10:06:12 GMT, Сергей Цыпанов <duke at openjdk.org> wrote:
>> A more realistic use case would be something in the lines of checking whether the method is an expected one:
>>
>>
>> @Benchmark
>> public boolean isFoo() {
>> return matches(method, "foo", int.class, String.class);
>> }
>>
>> private boolean matches(Method method, String name, Class<?> ...parameterTypes) {
>> if (method.getName().equals(name) &&
>> method.getParameterCount() == parameterTypes.length) {
>> var params = method.getParameters();
>> for (int i = 0; i < parameterTypes.length; i++) {
>> if (params[i].getType() != parameterTypes[i]) {
>> return false;
>> }
>> }
>> return true;
>> } else {
>> return false;
>> }
>> }
>
> Without `@Stable` your benchmark yields
>
> Benchmark Mode Cnt Score Error Units
> AccessParamsBenchmark.isFoo avgt 40 1,110 ± 0,062 ns/op
>
> and with `@Stable` it yields
>
> Benchmark Mode Cnt Score Error Units
> AccessParamsBenchmark.isFoo avgt 40 0,836 ± 0,015 ns/op
>
> Java 18:
>
> Benchmark Mode Cnt Score Error Units
> AccessParamsBenchmark.isFoo avgt 40 6,105 ± 0,107 ns/op
So, it looks like @Stable should stay.
-------------
PR: https://git.openjdk.org/jdk/pull/9143
More information about the core-libs-dev
mailing list