From c3142b62c00a162fdba5d29ab5176b510065d586 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Mon, 23 Oct 2017 14:39:20 -0700 Subject: [PATCH] Fix 525972 - java.lang.ArrayIndexOutOfBoundsException: 2 (at org.aspectj.weaver.ResolvedType.getMemberParameterizationMap(ResolvedType.java:970)) --- .../src/org/aspectj/weaver/ResolvedType.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java index 5985e4b6d..daccec105 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java @@ -966,12 +966,38 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } TypeVariable[] tvs = getGenericType().getTypeVariables(); Map parameterizationMap = new HashMap(); - 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 getDeclaredAdvice() { List l = new ArrayList(); ResolvedMember[] methods = getDeclaredMethods(); -- 2.39.5