]> source.dussan.org Git - aspectj.git/commitdiff
335682
authoraclement <aclement>
Wed, 2 Feb 2011 19:31:02 +0000 (19:31 +0000)
committeraclement <aclement>
Wed, 2 Feb 2011 19:31:02 +0000 (19:31 +0000)
weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
weaver/src/org/aspectj/weaver/bcel/BcelMethod.java

index b74f85210882c9f3f09a4a0b5d2853bbbfbafd0f..4e9495799bb576ce01d96ab22a26a5f47e376120 100644 (file)
@@ -231,7 +231,7 @@ public class AtAjAttributes {
                boolean hasAtAspectAnnotation = false;
                boolean hasAtPrecedenceAnnotation = false;
 
-               boolean versionProcessed = false;
+               WeaverVersionInfo wvinfo = null;
                for (int i = 0; i < attributes.length; i++) {
                        Attribute attribute = attributes[i];
                        if (acceptAttribute(attribute)) {
@@ -254,15 +254,14 @@ public class AtAjAttributes {
                                try {
                                        VersionedDataInputStream s = new VersionedDataInputStream(new ByteArrayInputStream(
                                                        ((Unknown) attribute).getBytes()), null);
-                                       WeaverVersionInfo wvi = WeaverVersionInfo.read(s);
-                                       struct.ajAttributes.add(0, wvi);
-                                       versionProcessed = true;
+                                       wvinfo = WeaverVersionInfo.read(s);
+                                       struct.ajAttributes.add(0, wvinfo);
                                } catch (IOException ioe) {
                                        ioe.printStackTrace();
                                }
                        }
                }
-               if (!versionProcessed) {
+               if (wvinfo == null) {
                        // If we are in here due to a resetState() call (presumably because of reweavable state processing), the
                        // original type delegate will have been set with a version but that version will be missing from
                        // the new set of attributes (looks like a bug where the version attribute was not included in the
@@ -270,15 +269,18 @@ public class AtAjAttributes {
                        // if it set on the delegate for the type.
                        ReferenceTypeDelegate delegate = type.getDelegate();
                        if (delegate instanceof BcelObjectType) {
-                               WeaverVersionInfo wvi = ((BcelObjectType) delegate).getWeaverVersionAttribute();
-                               if (wvi != null && wvi.getMajorVersion() != WeaverVersionInfo.WEAVER_VERSION_MAJOR_UNKNOWN) {
-                                       // use this one
-                                       struct.ajAttributes.add(0, wvi);
-                                       versionProcessed = true;
+                               wvinfo = ((BcelObjectType) delegate).getWeaverVersionAttribute();
+                               if (wvinfo != null) {
+                                       if (wvinfo.getMajorVersion() != WeaverVersionInfo.WEAVER_VERSION_MAJOR_UNKNOWN) {
+                                               // use this one
+                                               struct.ajAttributes.add(0, wvinfo);
+                                       } else {
+                                               wvinfo = null;
+                                       }
                                }
                        }
-                       if (!versionProcessed) {
-                               struct.ajAttributes.add(0, new AjAttribute.WeaverVersionInfo());
+                       if (wvinfo == null) {
+                               struct.ajAttributes.add(0, wvinfo = new AjAttribute.WeaverVersionInfo());
                        }
                }
 
@@ -358,9 +360,6 @@ public class AtAjAttributes {
                                }
                        }
                        if (processedPointcut) {
-                               // FIXME asc should check we aren't adding multiple versions...
-                               // will do once I get the tests passing again...
-                               struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo());
                                struct.ajAttributes.addAll(mstruct.ajAttributes);
                        }
                }
@@ -561,7 +560,7 @@ public class AtAjAttributes {
                                // struct.context.getOffset()+1);//FIXME
                                // AVASM
                                // Not setting version here
-                               //struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo());
+                               // struct.ajAttributes.add(new AjAttribute.WeaverVersionInfo());
                                AjAttribute.Aspect aspectAttribute = new AjAttribute.Aspect(perClause);
                                struct.ajAttributes.add(aspectAttribute);
                                FormalBinding[] bindings = new org.aspectj.weaver.patterns.FormalBinding[0];
index a97804404f6e25a9013ff627d5ccf41ee9790c4e..13f883f1eab45f3dcf843483595b76c781d3bb3a 100644 (file)
@@ -34,6 +34,7 @@ import org.aspectj.util.GenericSignature;
 import org.aspectj.util.GenericSignature.TypeVariableSignature;
 import org.aspectj.util.GenericSignatureParser;
 import org.aspectj.weaver.AjAttribute;
+import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
 import org.aspectj.weaver.AnnotationAJ;
 import org.aspectj.weaver.BCException;
 import org.aspectj.weaver.ISourceContext;
@@ -195,9 +196,9 @@ class BcelMethod extends ResolvedMemberImpl {
        private void unpackAjAttributes(World world) {
                associatedShadowMunger = null;
                ResolvedType resolvedDeclaringType = getDeclaringType().resolve(world);
+               WeaverVersionInfo wvinfo = bcelObjectType.getWeaverVersionAttribute();
                List<AjAttribute> as = Utility.readAjAttributes(resolvedDeclaringType.getClassName(), method.getAttributes(),
-                               resolvedDeclaringType.getSourceContext(), world, bcelObjectType.getWeaverVersionAttribute(),
-                               new BcelConstantPoolReader(method.getConstantPool()));
+                               resolvedDeclaringType.getSourceContext(), world, wvinfo, new BcelConstantPoolReader(method.getConstantPool()));
                processAttributes(world, as);
                as = AtAjAttributes.readAj5MethodAttributes(method, this, resolvedDeclaringType, preResolvedPointcut,
                                resolvedDeclaringType.getSourceContext(), world.getMessageHandler());