diff options
author | aclement <aclement> | 2005-07-26 14:15:32 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-07-26 14:15:32 +0000 |
commit | a3dd516b80debb7dfd0c45fa2b0e8ad7959b4b91 (patch) | |
tree | c190ee75eb281833b9ccaf889eae96eacb08a74e | |
parent | 8db7e37a1b2a2c81f977157a9c8e9470a3ff72e6 (diff) | |
download | aspectj-a3dd516b80debb7dfd0c45fa2b0e8ad7959b4b91.tar.gz aspectj-a3dd516b80debb7dfd0c45fa2b0e8ad7959b4b91.zip |
minor versioning improvement. dont add the version attribute if someone else already has.
-rw-r--r-- | org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java | 15 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java | 11 |
2 files changed, 23 insertions, 3 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java index 580020a2e..ac88e4a07 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java @@ -27,6 +27,7 @@ import org.aspectj.ajdt.internal.compiler.lookup.EclipseTypeMunger; import org.aspectj.ajdt.internal.compiler.lookup.HelperInterfaceBinding; import org.aspectj.ajdt.internal.compiler.lookup.InlineAccessFieldBinding; import org.aspectj.ajdt.internal.compiler.lookup.PrivilegedHandler; +import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; @@ -272,7 +273,7 @@ public class AspectDeclaration extends TypeDeclaration { generateInlineAccessMembers(classFile); - classFile.extraAttributes.add(new EclipseAttributeAdapter(new AjAttribute.WeaverVersionInfo())); + addVersionAttributeIfNecessary(classFile); classFile.extraAttributes.add( new EclipseAttributeAdapter(new AjAttribute.Aspect(perClause))); @@ -292,6 +293,18 @@ public class AspectDeclaration extends TypeDeclaration { super.generateAttributes(classFile); } + /** + * A pointcut might have already added the attribute, let's not add it again. + */ + private void addVersionAttributeIfNecessary(ClassFile classFile) { + for (Iterator iter = classFile.extraAttributes.iterator(); iter.hasNext();) { + EclipseAttributeAdapter element = (EclipseAttributeAdapter) iter.next(); + if (CharOperation.equals(element.getNameChars(),weaverVersionChars)) return; + } + classFile.extraAttributes.add(new EclipseAttributeAdapter(new AjAttribute.WeaverVersionInfo())); + } + private static char[] weaverVersionChars = "org.aspectj.weaver.WeaverVersion".toCharArray(); + private void generateInlineAccessMembers(ClassFile classFile) { for (Iterator i = superAccessForInline.values().iterator(); i.hasNext(); ) { AccessForInlineVisitor.SuperAccessMethodPair pair = (AccessForInlineVisitor.SuperAccessMethodPair)i.next(); diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java index 81490d5eb..2bf207c97 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java @@ -422,8 +422,15 @@ public final class LazyClassGen { // } } - // Add a weaver version attribute to the file being produced - myGen.addAttribute(BcelAttributes.bcelAttribute(new AjAttribute.WeaverVersionInfo(),getConstantPoolGen())); + // Add a weaver version attribute to the file being produced (if necessary...) + boolean hasVersionAttribute = false; + Attribute[] attrs = myGen.getAttributes(); + for (int i = 0; i < attrs.length && !hasVersionAttribute; i++) { + Attribute attribute = attrs[i]; + if (attribute.getName().equals("org.aspectj.weaver.WeaverVersion")) hasVersionAttribute=true; + } + if (!hasVersionAttribute) + myGen.addAttribute(BcelAttributes.bcelAttribute(new AjAttribute.WeaverVersionInfo(),getConstantPoolGen())); if (myType != null && myType.getWeaverState() != null) { myGen.addAttribute(BcelAttributes.bcelAttribute( |