@@ -22,7 +22,17 @@ public class ParameterAnnotationFixer extends ClassVisitor
2222
2323 public ParameterAnnotationFixer (ClassVisitor cn , MCInjectorImpl mci )
2424 {
25- super (Opcodes .ASM5 , cn );
25+ super (Opcodes .ASM6 , cn );
26+ // Extra version check, since these were added in ASM 6.1 and there
27+ // isn't a constant for it
28+ try {
29+ MethodNode .class .getField ("visibleAnnotableParameterCount" );
30+ MethodNode .class .getField ("invisibleAnnotableParameterCount" );
31+ } catch (Exception ex ) {
32+ throw new IllegalArgumentException (
33+ "AnnotableParameterCount fields are not present -- wrong ASM version?" ,
34+ ex );
35+ }
2636 }
2737
2838 @ Override
@@ -123,6 +133,16 @@ private void processConstructor(ClassNode cls, MethodNode mn, Type[] syntheticPa
123133 mn .invisibleParameterAnnotations = process (methodInfo ,
124134 "RuntimeInvisibleParameterAnnotations" , params .length ,
125135 syntheticParams .length , mn .invisibleParameterAnnotations );
136+ // ASM uses this value, not the length of the array
137+ // Note that this was added in ASM 6.1
138+ if (mn .visibleParameterAnnotations != null )
139+ {
140+ mn .visibleAnnotableParameterCount = mn .visibleParameterAnnotations .length ;
141+ }
142+ if (mn .invisibleParameterAnnotations != null )
143+ {
144+ mn .invisibleAnnotableParameterCount = mn .invisibleParameterAnnotations .length ;
145+ }
126146 }
127147 else
128148 {
0 commit comments