RFR: 8288327: Executable.hasRealParameterData should not be volatile [v7]
Peter Levart
plevart at openjdk.org
Mon Jul 4 06:34:29 UTC 2022
On Mon, 4 Jul 2022 06:19:00 GMT, Peter Levart <plevart at openjdk.org> wrote:
>> hmm, is the faster getParameters (without explicit index access) a result of the annotation? getParameter0 shows the documented effect but isn't quite our use case here.
>
> ...neither is obtaining a cloned array and passing its reference to JMH's black hole our usecase... Still, it seems that even part of that has some advantage. I would keep the @stable annotation then.
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;
}
}
-------------
PR: https://git.openjdk.org/jdk/pull/9143
More information about the core-libs-dev
mailing list