]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for pr113073 from Helen
authoraclement <aclement>
Thu, 20 Oct 2005 13:54:50 +0000 (13:54 +0000)
committeraclement <aclement>
Thu, 20 Oct 2005 13:54:50 +0000 (13:54 +0000)
tests/bugs150/pr113073.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java

diff --git a/tests/bugs150/pr113073.java b/tests/bugs150/pr113073.java
new file mode 100644 (file)
index 0000000..9e57ffa
--- /dev/null
@@ -0,0 +1,17 @@
+@interface Annotation{}
+aspect B {
+       declare @method : public * C.anotherMethod(..) : @Annotation; // should be woven
+       declare @constructor : C.new(String) : @Annotation;
+}
+
+class C {
+}
+
+aspect D {
+       public C.new(String s) {
+       }
+       public void C.anotherMethod(String s) {
+       }
+       public void C.anotherMethod() {
+       }
+}
index c2ac24822d7992f8358e9a223e7ee4b176220db6..a6f8acb46141bb0a9f556a7ffdaf81335394cc4f 100644 (file)
@@ -618,6 +618,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void testVarArgsIITDInConstructor() {
          runTest("ITD varargs in constructor");
   }
+   
+  public void testWeaveInfoMessageForDeclareAtMethodOnITDdMethod() {
+         runTest("weaveinfo message for declare at method on an ITDd method");
+  }
   
   // helper methods.....
   
index 4c43a907e37c0d85bc1007cb062165c3677886cc..b4648155f577982b654ee4433357c607a9a7490d 100644 (file)
         </compile>
     </ajc-test> 
 
+    <ajc-test dir="bugs150" title="weaveinfo message for declare at method on an ITDd method">
+        <compile files="pr113073.java" options="-1.5 -showWeaveInfo">
+                       <message kind="weave" text="Type 'C' (pr113073.java) has intertyped method from 'D' (pr113073.java:'void C.anotherMethod()')"/>
+                       <message kind="weave" text="'public void C.anotherMethod()' (pr113073.java) is annotated with @Annotation method annotation from 'B' (pr113073.java:3)"/>
+                       <message kind="weave" text="Type 'C' (pr113073.java) has intertyped method from 'D' (pr113073.java:'void C.anotherMethod(java.lang.String)')"/>
+                       <message kind="weave" text="'public void C.anotherMethod(String)' (pr113073.java) is annotated with @Annotation method annotation from 'B' (pr113073.java:3)"/>
+                       <message kind="weave" text="Type 'C' (pr113073.java) has intertyped constructor from 'D' (pr113073.java:'void C."/>
+                       <message kind="weave" text="'public void C.new(String)' (pr113073.java) is annotated with @Annotation constructor annotation from 'B' (pr113073.java:4)"/>
+        </compile>
+    </ajc-test> 
 
     <!-- ============================================================================ -->
     <!-- ============================================================================ -->
index 0ad3caa6491748b0db55ffbb2741ca6f2404ab86..97401295fccfc08d7bab3bbc119a9bbb0bbb746e 100644 (file)
@@ -491,8 +491,7 @@ class BcelClassWeaver implements IClassWeaver {
                                members.set(memberCounter,new LazyMethodGen(newMethod,clazz));
                                
                                AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaM.getSourceLocation(),clazz.getName(),mg.getMethod());
-                               
-                               reportMethodCtorWeavingMessage(clazz, mg, decaM);
+                               reportMethodCtorWeavingMessage(clazz, mg.getMemberView(), decaM,mg.getDeclarationLineNumber());
                                isChanged = true;
                                modificationOccured = true;
                        } else {
@@ -525,26 +524,27 @@ class BcelClassWeaver implements IClassWeaver {
                return isChanged;
     }
 
-       // TAG: WeavingMessage
-       private void reportMethodCtorWeavingMessage(LazyClassGen clazz, LazyMethodGen mg, DeclareAnnotation decaM) {
+       
+    // TAG: WeavingMessage
+       private void reportMethodCtorWeavingMessage(LazyClassGen clazz, ResolvedMember member, DeclareAnnotation decaM,int memberLineNumber) {
                if (!getWorld().getMessageHandler().isIgnoring(IMessage.WEAVEINFO)){
                        StringBuffer parmString = new StringBuffer("(");
-                       Type[] args = mg.getMethod().getArgumentTypes();
-                       for (int i = 0; i < args.length; i++) {
-                               Type type2 = args[i];
-                               String s = org.aspectj.apache.bcel.classfile.Utility.signatureToString(type2.getSignature());
+                       UnresolvedType[] paramTypes = member.getParameterTypes();
+                       for (int i = 0; i < paramTypes.length; i++) {
+                               UnresolvedType type = paramTypes[i];
+                               String s = org.aspectj.apache.bcel.classfile.Utility.signatureToString(type.getSignature());
                                if (s.lastIndexOf(".")!=-1) s =s.substring(s.lastIndexOf(".")+1);
                                parmString.append(s);
-                               if ((i+1)<args.length) parmString.append(",");
+                               if ((i+1)<paramTypes.length) parmString.append(",");
                        }
                        parmString.append(")");
-                       String methodName = mg.getMethod().getName();
+                       String methodName = member.getName();
                        StringBuffer sig = new StringBuffer();
-                       sig.append(org.aspectj.apache.bcel.classfile.Utility.accessToString(mg.getMethod().getAccessFlags()) );
+                       sig.append(org.aspectj.apache.bcel.classfile.Utility.accessToString(member.getModifiers()));
                        sig.append(" ");
-                       sig.append(mg.getMethod().getReturnType().toString());
+                       sig.append(member.getReturnType().toString());
                        sig.append(" ");
-                       sig.append(clazz.getName());
+                       sig.append(member.getDeclaringType().toString());
                        sig.append(".");
                        sig.append(methodName.equals("<init>")?"new":methodName);
                        sig.append(parmString);
@@ -554,8 +554,8 @@ class BcelClassWeaver implements IClassWeaver {
                                loc.append("no debug info available");
                        } else {
                                loc.append(clazz.getFileName());
-                               if (mg.getDeclarationLineNumber()!=-1) {
-                                       loc.append(":"+mg.getDeclarationLineNumber());
+                               if (memberLineNumber!=-1) {
+                                       loc.append(":"+memberLineNumber);
                                }
                        }
                        getWorld().getMessageHandler().handleMessage(
@@ -715,6 +715,7 @@ class BcelClassWeaver implements IClassWeaver {
                                        annotationHolder.addAnnotation(decaMC.getAnnotationX());
                                        isChanged=true;
                                        AsmRelationshipProvider.getDefault().addDeclareAnnotationRelationship(decaMC.getSourceLocation(),unMangledInterMethod.getSourceLocation());
+                                       reportMethodCtorWeavingMessage(clazz, unMangledInterMethod, decaMC,-1);
                                        modificationOccured = true;                                     
                                } else {
                                        if (!decaMC.isStarredAnnotationPattern())