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

Christoph Dreis christoph.dreis at freenet.de
Mon Nov 28 12:46:03 UTC 2016


Apparently, the attachment got lost. So here it is:

Reduce allocations in
sun.reflect.annotation.AnnotationInvocationHandler.invoke()

diff -r ba70dcd8de76 -r 86bbc5442c1d
src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandl
er.java
---
a/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHan
dler.java	Fri Nov 11 13:11:27 2016 +0000
+++
b/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHan
dler.java	Mon Nov 14 19:04:33 2016 +0100
@@ -57,13 +57,13 @@
 
     public Object invoke(Object proxy, Method method, Object[] args) {
         String member = method.getName();
-        Class<?>[] paramTypes = method.getParameterTypes();
+        int parameterCount = method.getParameterCount();
 
         // Handle Object and Annotation methods
-        if (member.equals("equals") && paramTypes.length == 1 &&
-            paramTypes[0] == Object.class)
+        if (member.equals("equals") && parameterCount == 1 &&
+            method.getParameterTypes()[0] == Object.class)
             return equalsImpl(proxy, args[0]);
-        if (paramTypes.length != 0)
+        if (parameterCount != 0)
             throw new AssertionError("Too many parameters for an annotation
method");
 
         switch(member) {





More information about the jdk9-dev mailing list