java.lang.reflect.Method.copyOf
Uwe Schindler
uschindler at apache.org
Wed Oct 14 15:36:53 UTC 2015
Hi,
Just as idea: Why not implement Cloneable for that purpose? Adding new methods does not look like a good idea.
-----
Uwe Schindler
uschindler at apache.org
ASF Member, Apache Lucene PMC / Committer
Bremen, Germany
http://lucene.apache.org/
> -----Original Message-----
> From: core-libs-dev [mailto:core-libs-dev-bounces at openjdk.java.net] On
> Behalf Of Kasper Nielsen
> Sent: Wednesday, October 14, 2015 12:02 PM
> To: core-libs-dev
> Subject: java.lang.reflect.Method.copyOf
>
> 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