Kasper Nielsen kasperni at
Wed Oct 14 10:02:01 UTC 2015


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(),
} 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