[NEW BUG]: Reduce allocations in sun.reflect.annotation.AnnotationInvocationHandler.invoke()

Christoph Dreis christoph.dreis at freenet.de
Fri Dec 2 17:31:29 UTC 2016


Hey,

>>> doing a bit of digging it appears a similar improvement - along with a
>>> lot of other things - was suggested and filed a few years back:
>>> https://bugs.openjdk.java.net/browse/JDK-8029019
>> Really sorry for missing that!
>>

If https://bugs.openjdk.java.net/browse/JDK-8029019 is decided to be solved
I'd like to add the following addition to that:

========= PATCH ===========
# User Christoph Dreis <christoph.dreis at freenet.de>
Avoid allocations in AnnotationType constructor coming from
Method.getParameterTypes()

diff --git
a/src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java
b/src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java
--- a/src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java
+++ b/src/java.base/share/classes/sun/reflect/annotation/AnnotationType.java
@@ -121,7 +121,7 @@
             if (Modifier.isPublic(method.getModifiers()) &&
                 Modifier.isAbstract(method.getModifiers()) &&
                 !method.isSynthetic()) {
-                if (method.getParameterTypes().length != 0) {
+                if (method.getParameterCount() != 0) {
                     throw new IllegalArgumentException(method + " has
params");
                 }
                 String name = method.getName();



More information about the core-libs-dev mailing list