Bug 143924 - Missing relationship for declare @method when annotating a method with non primitive argument
Summary: Missing relationship for declare @method when annotating a method with non pr...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.2   Edit
Assignee: Helen Beeken CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-26 06:17 EDT by Helen Beeken CLA
Modified: 2012-04-03 16:16 EDT (History)
0 users

See Also:


Attachments
failing testcase (5.42 KB, patch)
2006-05-26 07:00 EDT, Helen Beeken CLA
aclement: iplog+
Details | Diff
proposed fix (1.47 KB, patch)
2006-05-26 07:18 EDT, Helen Beeken CLA
aclement: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Helen Beeken CLA 2006-05-26 06:17:05 EDT
Given this program there is no marker from the declare to the annotated method, although this is being woven since there is output from -showWeaveInfo:

----------------------------------------------------------------

public aspect DeclareAnnotation {
    declare @method : * debit(..) : @Secured(role="supervisor");
}

class BankAccount {
	
    public void debit(String accId,long amount) {
    }
}

@interface Secured {
    String role();
}
Comment 1 Helen Beeken CLA 2006-05-26 07:00:20 EDT
Created attachment 42697 [details]
failing testcase

Apply this patch to the tests project
Comment 2 Helen Beeken CLA 2006-05-26 07:00:51 EDT
The reason this is failing is that in AsmRelationshipProvider.addDeclareAnnotationRelationship(..) we are asking for the IProgramElement with signature debit(String,long) rather than debit(java.lang.String,long). This is because earlier in the method we strip java.lang.String down to String.
Comment 3 Helen Beeken CLA 2006-05-26 07:18:37 EDT
Created attachment 42698 [details]
proposed fix

Apply the patch to the weaver project.

The fix is to not strip out the "java.lang" part of "java.lang.String" in the case of methods. At the moment I've added a guard to the proposed fix to still to the same if its a constructor. This is because, as mentioned in bug 143930, constructors and methods are currently dealt with differently. When bug 143930 is fixed, the extra check for "isConstructor" can be removed and constructors and methods can be dealt with the same way when constructing the parmString:

Type type2 = args[i];
    if (isConstructor) {
        String s = Utility.signatureToString(type2.getSignature());
        if (s.lastIndexOf(".")!=-1) s =s.substring(s.lastIndexOf(".")+1);
            parmString.append(s);
    } else {
        String s = Utility.signatureToString(type2.getSignature(),false);
        parmString.append(s);
    }
    if ((i+1)<args.length) parmString.append(",");
}
Comment 4 Helen Beeken CLA 2006-05-26 10:14:20 EDT
Just as a note, the modification to the proposed fix mentioned in the above comment has been submitted (along with this testcase) in the bug report for bug 143930.
Comment 5 Andrew Clement CLA 2006-05-30 06:04:15 EDT
patches from other bug committed.