From 00998fd4b23ad0d3e0cd292127297e0fb249c36f Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sun, 25 Jun 2023 12:22:34 +0200 Subject: [PATCH] BcelTypeMunger.getRealMemberForITDFromAspect code cosmetics Relates to #246. Signed-off-by: Alexander Kriegisch --- .../aspectj/weaver/bcel/BcelTypeMunger.java | 57 ++++++++----------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java index 64e9ce42f..1d33f417e 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java @@ -1593,7 +1593,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { System.err.println("Member we are looking for: " + lookingFor); } - ResolvedMember aspectMethods[] = aspectType.getDeclaredMethods(); + ResolvedMember[] aspectMethods = aspectType.getDeclaredMethods(); UnresolvedType[] lookingForParams = lookingFor.getParameterTypes(); ResolvedMember realMember = null; @@ -1602,47 +1602,38 @@ public class BcelTypeMunger extends ConcreteTypeMunger { if (member.getName().equals(lookingFor.getName())) { UnresolvedType[] memberParams = member.getGenericParameterTypes(); if (memberParams.length == lookingForParams.length) { - if (debug) { + if (debug) System.err.println("Reviewing potential candidates: " + member); - } boolean matchOK = true; - // Check that all method/ctor params all match, although only the erasure - for (int j = 0; j < memberParams.length && matchOK; j++) { - ResolvedType pMember = memberParams[j].resolve(world); - ResolvedType pLookingFor = lookingForParams[j].resolve(world); - if (pMember.isTypeVariableReference()) { - pMember = ((TypeVariableReference) pMember).getTypeVariable().getFirstBound().resolve(world); - } - if (pMember.isParameterizedType() || pMember.isGenericType()) { - pMember = pMember.getRawType().resolve(aspectType.getWorld()); - } - - if (pLookingFor.isTypeVariableReference()) { - pLookingFor = ((TypeVariableReference) pLookingFor).getTypeVariable().getFirstBound() - .resolve(world); - } - if (pLookingFor.isParameterizedType() || pLookingFor.isGenericType()) { - pLookingFor = pLookingFor.getRawType().resolve(world); - } + // Check that all method/ctor params all match, although only the erasure + for (int j = 0; j < memberParams.length && matchOK; j++) { + ResolvedType pMember = memberParams[j].resolve(world); + ResolvedType pLookingFor = lookingForParams[j].resolve(world); + + if (pMember.isTypeVariableReference()) + pMember = ((TypeVariableReference) pMember).getTypeVariable().getFirstBound().resolve(world); + if (pMember.isParameterizedType() || pMember.isGenericType()) + pMember = pMember.getRawType().resolve(aspectType.getWorld()); + + if (pLookingFor.isTypeVariableReference()) + pLookingFor = ((TypeVariableReference) pLookingFor).getTypeVariable().getFirstBound().resolve(world); + if (pLookingFor.isParameterizedType() || pLookingFor.isGenericType()) + pLookingFor = pLookingFor.getRawType().resolve(world); + + if (debug) + System.err.println("Comparing parameter " + j + " member=" + pMember + " lookingFor=" + pLookingFor); + if (!pMember.equals(pLookingFor)) + matchOK = false; + } - if (debug) { - System.err.println("Comparing parameter " + j + " member=" + pMember + " lookingFor=" - + pLookingFor); - } - if (!pMember.equals(pLookingFor)) { - matchOK = false; - } - } - if (matchOK) { + if (matchOK) realMember = member; - } } } } - if (debug && realMember == null) { + if (debug && realMember == null) System.err.println("Didn't find a match"); - } return realMember; } -- 2.39.5