changeset 47634:389695e5e8db

8189266: (ann) Optimize AnnotationInvocationHandler.invoke Reviewed-by: jfranck, plevart Contributed-by: christoph.dreis@freenet.de
author redestad
date Mon, 23 Oct 2017 11:33:16 +0200
parents 80fd2dab3805
children 54a2f246edd8
files src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java	Mon Oct 23 10:43:45 2017 +0200
+++ b/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java	Mon Oct 23 11:33:16 2017 +0200
@@ -57,21 +57,22 @@
 
     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 (parameterCount == 1 && member == "equals" &&
+                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) {
-        case "toString":
+        if (member == "toString") {
             return toStringImpl();
-        case "hashCode":
+        } else if (member == "hashCode") {
             return hashCodeImpl();
-        case "annotationType":
+        } else if (member == "annotationType") {
             return type;
         }