From db423fea1bfc5f7a3fcda442fcad64a442c0eff0 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 5 Aug 2010 16:49:45 +0000 Subject: [PATCH] 278496: anon inner types affected by aspects --- .../org/aspectj/weaver/bcel/BcelWeaver.java | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index d71d5b367..f812e81f2 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -28,10 +28,10 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.jar.Attributes; +import java.util.jar.Attributes.Name; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; -import java.util.jar.Attributes.Name; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; @@ -932,8 +932,8 @@ public class BcelWeaver { * @param userPointcut */ private void raiseUnboundFormalError(String name, Pointcut userPointcut) { - world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.UNBOUND_FORMAL, name), userPointcut - .getSourceLocation(), null); + world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.UNBOUND_FORMAL, name), + userPointcut.getSourceLocation(), null); } public void addManifest(Manifest newManifest) { @@ -1335,8 +1335,8 @@ public class BcelWeaver { ResolvedType rtx = world.resolve(UnresolvedType.forSignature(requiredTypeSignature), true); boolean exists = !rtx.isMissing(); if (!exists) { - world.getLint().missingAspectForReweaving.signal(new String[] { rtx.getName(), className }, classType - .getSourceLocation(), null); + world.getLint().missingAspectForReweaving.signal(new String[] { rtx.getName(), className }, + classType.getSourceLocation(), null); // world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.MISSING_REWEAVABLE_TYPE, // requiredTypeName, className), classType.getSourceLocation(), null); } else { @@ -1353,8 +1353,8 @@ public class BcelWeaver { world.showMessage(IMessage.ERROR, WeaverMessages.format( WeaverMessages.REWEAVABLE_ASPECT_NOT_REGISTERED, rtx.getName(), className), null, null); } else if (!world.getMessageHandler().isIgnoring(IMessage.INFO)) { - world.showMessage(IMessage.INFO, WeaverMessages.format(WeaverMessages.VERIFIED_REWEAVABLE_TYPE, rtx - .getName(), rtx.getSourceLocation().getSourceFile()), null, null); + world.showMessage(IMessage.INFO, WeaverMessages.format(WeaverMessages.VERIFIED_REWEAVABLE_TYPE, + rtx.getName(), rtx.getSourceLocation().getSourceFile()), null, null); } } alreadyConfirmedReweavableState.add(requiredTypeSignature); @@ -1528,10 +1528,11 @@ public class BcelWeaver { // TAG: WeavingMessage if (!getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)) { getWorld().getMessageHandler().handleMessage( - WeaveMessage.constructWeavingMessage(WeaveMessage.WEAVEMESSAGE_ANNOTATES, new String[] { - onType.toString(), Utility.beautifyLocation(onType.getSourceLocation()), - decA.getAnnotationString(), "type", decA.getAspect().toString(), - Utility.beautifyLocation(decA.getSourceLocation()) })); + WeaveMessage.constructWeavingMessage( + WeaveMessage.WEAVEMESSAGE_ANNOTATES, + new String[] { onType.toString(), Utility.beautifyLocation(onType.getSourceLocation()), + decA.getAnnotationString(), "type", decA.getAspect().toString(), + Utility.beautifyLocation(decA.getSourceLocation()) })); } didSomething = true; ResolvedTypeMunger newAnnotationTM = new AnnotationOnTypeMunger(annoX); @@ -1554,13 +1555,15 @@ public class BcelWeaver { if (outputProblems) { if (decA.isExactPattern()) { world.getMessageHandler().handleMessage( - MessageUtil.error(WeaverMessages.format(WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION, - onType.getName(), annoX.getTypeName(), annoX.getValidTargets()), decA.getSourceLocation())); + MessageUtil.error( + WeaverMessages.format(WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION, + onType.getName(), annoX.getTypeName(), annoX.getValidTargets()), + decA.getSourceLocation())); } else { if (world.getLint().invalidTargetForAnnotation.isEnabled()) { world.getLint().invalidTargetForAnnotation.signal(new String[] { onType.getName(), annoX.getTypeName(), - annoX.getValidTargets() }, decA.getSourceLocation(), new ISourceLocation[] { onType - .getSourceLocation() }); + annoX.getValidTargets() }, decA.getSourceLocation(), + new ISourceLocation[] { onType.getSourceLocation() }); } } } @@ -1601,8 +1604,8 @@ public class BcelWeaver { } public void weaveNormalTypeMungers(ResolvedType onType) { - ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS, onType - .getName()); + ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_TYPE_MUNGERS, + onType.getName()); if (onType.isRawType() || onType.isParameterizedType()) { onType = onType.getGenericType(); } @@ -1721,7 +1724,7 @@ public class BcelWeaver { String pkgname = classType.getResolvedTypeX().getPackageName(); String tname = classType.getResolvedTypeX().getSimpleBaseName(); IProgramElement typeElement = hierarchy.findElementForType(pkgname, tname); - if (typeElement != null && !hasInnerAspect(typeElement)) { + if (typeElement != null && !hasInnerType(typeElement)) { // Set deleted = new HashSet(); // deleted.add(model.getCanonicalFilePath(typeElement.getSourceLocation().getSourceFile())); @@ -1782,14 +1785,18 @@ public class BcelWeaver { // ---- writing - private boolean hasInnerAspect(IProgramElement typeNode) { + // TODO could be smarter - really only matters if inner type has been woven, but there is a chance we haven't woven it *yet* + private boolean hasInnerType(IProgramElement typeNode) { for (IProgramElement child : typeNode.getChildren()) { IProgramElement.Kind kind = child.getKind(); - if (kind == IProgramElement.Kind.ASPECT) { + if (kind.isType()) { return true; } - if (kind.isType()) { - boolean b = hasInnerAspect(child); + // if (kind == IProgramElement.Kind.ASPECT) { + // return true; + // } + if (kind.isType() || kind == IProgramElement.Kind.METHOD || kind == IProgramElement.Kind.CONSTRUCTOR) { + boolean b = hasInnerType(child); if (b) { return b; } -- 2.39.5