8189266: (ann) Optimize AnnotationInvocationHandler.invoke
authorredestad
Mon, 23 Oct 2017 11:33:16 +0200
changeset 47436 389695e5e8db
parent 47435 80fd2dab3805
child 47437 54a2f246edd8
8189266: (ann) Optimize AnnotationInvocationHandler.invoke Reviewed-by: jfranck, plevart Contributed-by: christoph.dreis@freenet.de
src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
--- 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;
         }