]> source.dussan.org Git - aspectj.git/commitdiff
fix for 137479: better isSynthetic() logic
authoraclement <aclement>
Wed, 19 Apr 2006 11:48:22 +0000 (11:48 +0000)
committeraclement <aclement>
Wed, 19 Apr 2006 11:48:22 +0000 (11:48 +0000)
weaver/src/org/aspectj/weaver/ResolvedMemberImpl.java
weaver/src/org/aspectj/weaver/bcel/BcelMethod.java
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java

index dad942f6c9bd96b161cbc40852d55779207e07dd..2049b554cc2b429a89bb268d8b2ede1b7547636e 100644 (file)
@@ -333,7 +333,8 @@ public class ResolvedMemberImpl extends MemberImpl implements IHasPosition, Anno
     }
     
        public boolean isSynthetic() {
-               return false;
+               // See Bcelmethod.isSynthetic() which takes account of preJava5 Synthetic modifier
+               return (modifiers & 4096)!=0; // do we know better? 
        }
 
     public void write(DataOutputStream s) throws IOException {
index ac8aef227f6dc3f5987678785cf973c6df592114..a9129fd623dc12b6951997ac7f55f0f11310c234 100644 (file)
@@ -22,6 +22,7 @@ import java.util.List;
 import org.aspectj.apache.bcel.classfile.Attribute;
 import org.aspectj.apache.bcel.classfile.ExceptionTable;
 import org.aspectj.apache.bcel.classfile.GenericSignatureParser;
+import org.aspectj.apache.bcel.classfile.JavaClass;
 import org.aspectj.apache.bcel.classfile.LocalVariable;
 import org.aspectj.apache.bcel.classfile.LocalVariableTable;
 import org.aspectj.apache.bcel.classfile.Method;
@@ -47,6 +48,8 @@ final class BcelMethod extends ResolvedMemberImpl {
 
        private Method method;
        private boolean isAjSynthetic;
+       private boolean isSynthetic;
+       private boolean knowIfSynthetic = false;
        private ShadowMunger associatedShadowMunger;
        private ResolvedPointcutDefinition preResolvedPointcut;  // used when ajc has pre-resolved the pointcut of some @Advice
        
@@ -395,4 +398,30 @@ final class BcelMethod extends ResolvedMemberImpl {
                         method = null;
                 }
         }
+
+       public boolean isSynthetic() {
+               if (!knowIfSynthetic) workOutIfSynthetic();
+               return isSynthetic;
+       }
+
+       // Pre Java5 synthetic is an attribute 'Synthetic', post Java5 it is a modifier (4096 or 0x1000)
+       private void workOutIfSynthetic() {
+               knowIfSynthetic=true;
+               JavaClass jc = bcelObjectType.getJavaClass();
+               isSynthetic=false;
+               if (jc==null) return; // what the hell has gone wrong?
+               if (jc.getMajor()<49/*Java5*/) {
+                       // synthetic is an attribute
+                       String[] synthetics =  getAttributeNames(false);
+                       if (synthetics!=null) {
+                               for (int i = 0; i < synthetics.length; i++) {
+                                       if (synthetics[i].equals("Synthetic")) {isSynthetic=true;break;}
+                               }
+                       }
+               } else {
+                       // synthetic is a modifier (4096)
+                       isSynthetic = (modifiers&4096)!=0;
+               }
+       }
+
 }
index b5122899ab83f4f2bf2b07e04922c5157d5d238d..2c8219356e018a8c07165fa6a422ba4e363fba66 100644 (file)
@@ -1464,6 +1464,12 @@ public final class LazyMethodGen {
        return memberView.isAjSynthetic();
     }
     
+
+    boolean isSynthetic() {
+       if (memberView == null) return false;
+       return memberView.isSynthetic();
+    }
+    
     public ISourceLocation getSourceLocation() {
       if (memberView!=null) return memberView.getSourceLocation();
       return null;