java.lang.reflect.Method.copyOf (original) (raw)

John Rose john.r.rose at oracle.com
Wed Oct 14 20:42:50 UTC 2015


On Oct 14, 2015, at 3:38 AM, Remi Forax <forax at univ-mlv.fr> wrote:

Given that j.l.r.Method is mutable, the best way to have performance is too encapsulate it in a non mutable class, if possible.

OK, I'll bite. Here's a way to make Method its own non-mutable encapsulation, a la List::set or (future feature) frozen arrays.

diff --git a/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java b/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java --- a/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java +++ b/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java @@ -120,15 +120,36 @@ * * @param flag the new value for the {@code accessible} flag * @throws SecurityException if the request is denied.

@@ -166,6 +187,9 @@ // outside this package. boolean override;



More information about the core-libs-dev mailing list