]> source.dussan.org Git - aspectj.git/commitdiff
Fix 525972 - java.lang.ArrayIndexOutOfBoundsException: 2 (at org.aspectj.weaver.Resol...
authorAndy Clement <aclement@pivotal.io>
Mon, 23 Oct 2017 21:39:20 +0000 (14:39 -0700)
committerAndy Clement <aclement@pivotal.io>
Mon, 23 Oct 2017 21:39:20 +0000 (14:39 -0700)
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java

index 5985e4b6dd42161e01615fc5528fa0ebef941a77..daccec105c8e9b9eb3e764bf3062e32f97d49069 100644 (file)
@@ -966,12 +966,38 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl
                }
                TypeVariable[] tvs = getGenericType().getTypeVariables();
                Map<String, UnresolvedType> parameterizationMap = new HashMap<String, UnresolvedType>();
-               for (int i = 0; i < tvs.length; i++) {
-                       parameterizationMap.put(tvs[i].getName(), typeParameters[i]);
+               if (tvs.length != typeParameters.length) {
+                       world.getMessageHandler()
+                                       .handleMessage(
+                                                       new Message("Mismatch when building parameterization map. For type '" + this.signature +
+                                                                       "' expecting "+tvs.length+":["+toString(tvs)+"] type parameters but found "+typeParameters.length+
+                                                                       ":["+toString(typeParameters)+"]", "",
+                                                                       IMessage.ERROR, getSourceLocation(), null,
+                                                                       new ISourceLocation[] { getSourceLocation() }));
+               } else {
+                       for (int i = 0; i < tvs.length; i++) {
+                               parameterizationMap.put(tvs[i].getName(), typeParameters[i]);
+                       }
                }
                return parameterizationMap;
        }
 
+       private String toString(UnresolvedType[] typeParameters) {
+               StringBuilder s = new StringBuilder();
+               for (UnresolvedType tv: typeParameters) {
+                       s.append(tv.getSignature()).append(" ");
+               }
+               return s.toString().trim();
+       }
+
+       private String toString(TypeVariable[] tvs) {
+               StringBuilder s = new StringBuilder();
+               for (TypeVariable tv: tvs) {
+                       s.append(tv.getName()).append(" ");
+               }
+               return s.toString().trim();
+       }
+
        public List<ShadowMunger> getDeclaredAdvice() {
                List<ShadowMunger> l = new ArrayList<ShadowMunger>();
                ResolvedMember[] methods = getDeclaredMethods();