java.lang.reflect.Method.copyOf
Kasper Nielsen
kasperni at gmail.com
Wed Oct 14 10:02:01 UTC 2015
Hi,
I was wondering if there is any reason for Method.copyOf (and friends)
being package private.
I'm trying to make a copy of a large number of Method objects in some
performance sensitive code to avoid sharing the isAccessible flag.
And while this is fairly fast.
Class<?> declaringClass = method.getDeclaringClass();
try {
return declaringClass.getDeclaredMethod(method.getName(),
method.getParameterTypes());
} catch (NoSuchMethodException e) {
throw new RuntimeException("This should never happen", e);
}
I would to like to avoid the performance penalty if possible.
- Kasper
More information about the core-libs-dev
mailing list