Hi Claes,

> 
> I think this all seems reasonable, but subtle behavior changes like this
> needs more scrutiny than I can provide.  I've discussed this offline
> with Joe and sadly concluded it's probably too much, too late for 9 at
> this point.
> 
> Hope you don't mind re-targetting this to JDK 10.

Do you mean the error handling change or the ticket in general? In case of the 
latter, may I start a proposal?

As the original issue for me was to reduce the allocations coming from 
AnnotationInvocationHandler.invoke() caused by Method.getParameterTypes(), what 
about creating a sub-ticket of 8029019 and just take care of the low-risk 
change below? That would eventually allow a backbort to JDK 8 as well, although 
I'm not quite sure yet how the backport process is working.

What do you think?

Cheers,
Christoph

========= PATCH ===========
diff --git 
a/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
 
b/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
--- 
a/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
+++ 
b/src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
@@ -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 (parameterCount == 1 && member.equals("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) {

Reply via email to