diff options
author | aclement <aclement> | 2006-05-30 09:59:53 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-05-30 09:59:53 +0000 |
commit | 26a8a862994acefb10a57d561b18c94ffeba41a4 (patch) | |
tree | 49791e4148a73d090e0c34fd22ab8ad9951ca137 | |
parent | 9eb7fa0bc21878bfd2c0251afb4001b5eb55e346 (diff) | |
download | aspectj-26a8a862994acefb10a57d561b18c94ffeba41a4.tar.gz aspectj-26a8a862994acefb10a57d561b18c94ffeba41a4.zip |
test and fixes for 143930, 143924
8 files changed, 67 insertions, 7 deletions
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java index 09d6ede30..b76b0b116 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java @@ -211,7 +211,7 @@ public class CoverageTestCase extends AjdocTestCase { "before(): getP..", "HREF=\"../foo/Point.html#getX()\"", "before(): setP..", - "HREF=\"../foo/Point.html\"><tt>foo.Point</tt></A>, <A HREF=\"../foo/Point.html#Point()\"><tt>foo.Point.Point()</tt></A>, <A HREF=\"../foo/Point.html#setX(int)\"", + "HREF=\"../foo/Point.html\"><tt>foo.Point</tt></A>, <A HREF=\"../foo/Point.html#Point()\"><tt>foo.Point.Point</tt></A>, <A HREF=\"../foo/Point.html#setX(int)\"", "before(): initializationP..", "HREF=\"../foo/Point.html#Point()\"", "before(): staticinitializationP..", diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java index 0916356d7..ee303df18 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java @@ -40,6 +40,7 @@ import org.aspectj.weaver.patterns.ReferencePointcut; import org.aspectj.weaver.patterns.TypePattern; import org.aspectj.weaver.patterns.TypePatternList; import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; @@ -291,7 +292,7 @@ public class AsmElementFormatter { // return args; // } - private void setParameters(MethodDeclaration md, IProgramElement pe) { + public void setParameters(AbstractMethodDeclaration md, IProgramElement pe) { Argument[] argArray = md.arguments; if (argArray == null) { pe.setParameterNames(Collections.EMPTY_LIST); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java index 4b48ccff1..2912e787c 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java @@ -711,12 +711,12 @@ public class AsmHierarchyBuilder extends ASTVisitor { } argumentsSignature.append(")"); IProgramElement peNode = new ProgramElement( - new String(constructorDeclaration.selector)+argumentsSignature, + new String(constructorDeclaration.selector), IProgramElement.Kind.CONSTRUCTOR, makeLocation(constructorDeclaration), constructorDeclaration.modifiers, null,null); - + formatter.setParameters(constructorDeclaration, peNode); peNode.setModifiers(constructorDeclaration.modifiers); peNode.setSourceSignature(genSourceSignature(constructorDeclaration)); diff --git a/tests/bugs152/pr143924.aj b/tests/bugs152/pr143924.aj new file mode 100644 index 000000000..7ea1e8d24 --- /dev/null +++ b/tests/bugs152/pr143924.aj @@ -0,0 +1,13 @@ +aspect DeclareAnnotation { + declare @method : * debit(..) : @Secured(role="supervisor"); +} + +class BankAccount { + + public void debit(String accId,long amount) { + } +} + +@interface Secured { + String role(); +} diff --git a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java index 3a76b645c..443418a78 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -232,7 +232,7 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase { IProgramElement.Kind.DECLARE_ANNOTATION_AT_CONSTRUCTOR,"declare @constructor: BankAccount+.new(..) : @Secured(role = \"supervisor\")"); assertNotNull("Couldn't find 'declare @constructor' element in the tree",decac); IProgramElement ctr = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.CONSTRUCTOR,"BankAccount(String,int)"); + IProgramElement.Kind.CONSTRUCTOR,"BankAccount(java.lang.String,int)"); assertNotNull("Couldn't find the 'BankAccount(String,int)' constructor element in the tree",ctr); diff --git a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java index 405f56250..67cb7c1db 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java @@ -11,9 +11,15 @@ package org.aspectj.systemtest.ajc152; import java.io.File; +import java.util.List; + import junit.framework.Test; //import org.aspectj.systemtest.ajc150.GenericsTests; +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; +import org.aspectj.asm.internal.Relationship; import org.aspectj.testing.XMLBasedAjcTestCase; public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { @@ -68,6 +74,41 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testSuperCallsInAtAspectJAdvice_pr139749() { runTest("Super calls in @AspectJ advice");} public void testNoClassCastExceptionWithPerThis_pr138286() { runTest("No ClassCastException with perThis");} + public void testDeclareAtMethodRelationship_pr143924() { + //AsmManager.setReporting("c:/debug.txt",true,true,true,true); + runTest("declare @method relationship"); + IHierarchy top = AsmManager.getDefault().getHierarchy(); + + // get the IProgramElements corresponding to the different code entries + IProgramElement decam = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD, + "declare @method: * debit(..) : @Secured(role = \"supervisor\")"); + assertNotNull("Couldn't find 'declare @method' element in the tree",decam); + IProgramElement method = top.findElementForLabel(top.getRoot(), + IProgramElement.Kind.METHOD,"debit(java.lang.String,long)"); + assertNotNull("Couldn't find the 'debit(String,long)' method element in the tree",method); + + List matches = AsmManager.getDefault().getRelationshipMap().get(decam); + assertNotNull("'declare @method' should have some relationships but does not",matches); + assertTrue("'declare @method' should have one relationships but has " + matches.size(),matches.size()==1); + List matchesTargets = ((Relationship)matches.get(0)).getTargets(); + assertTrue("'declare @method' should have one targets but has" + matchesTargets.size(),matchesTargets.size()==1); + IProgramElement target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)matchesTargets.get(0)); + assertEquals("target of relationship should be the 'debit(java.lang.String,long)' method but is IPE with label " + + target.toLabelString(),method,target); + + // check that the debit method has an annotated by relationship with the declare @method + matches = AsmManager.getDefault().getRelationshipMap().get(method); + assertNotNull("'debit(java.lang.String,long)' should have some relationships but does not",matches); + assertTrue("'debit(java.lang.String,long)' should have one relationships but has " + matches.size(),matches.size()==1); + matchesTargets = ((Relationship)matches.get(0)).getTargets(); + assertTrue("'debit(java.lang.String,long)' should have one targets but has" + matchesTargets.size(),matchesTargets.size()==1); + target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)matchesTargets.get(0)); + assertEquals("target of relationship should be the 'declare @method' ipe but is IPE with label " + + target.toLabelString(),decam,target); + + } + // this next one reported as a bug by Rob Harrop, but I can't reproduce the failure yet... //public void testAtAspectWithReferencePCPerClause_pr138220() { runTest("@Aspect with reference pointcut in perclause");} diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml index 4230c07f9..5741576b1 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml @@ -527,6 +527,12 @@ <compile files="Covariance.java" options="-1.5"/> </ajc-test> + <ajc-test dir="bugs152" title="declare @method relationship"> + <compile files="pr143924.aj" options="-1.5 -showWeaveInfo -emacssym"> + <message kind="weave" text="'public void BankAccount.debit(String,long)' (pr143924.aj:7) is annotated with @Secured"/> + </compile> + </ajc-test> + <!-- wont work whilst the compiler BuildArgParser.setDebugOptions is always switching debug on --> <ajc-test dir="bugs152/pr129408" title="long winded ataj messages"> <compile files="AtAj.java" options="-XterminateAfterCompilation -g:none -1.5"/> diff --git a/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java b/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java index 96db20473..636c95898 100644 --- a/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java +++ b/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java @@ -369,8 +369,7 @@ public class AsmRelationshipProvider { Type[] args = method.getArgumentTypes(); for (int i = 0; i < args.length; i++) { Type type2 = args[i]; - String s = Utility.signatureToString(type2.getSignature()); - if (s.lastIndexOf(".")!=-1) s =s.substring(s.lastIndexOf(".")+1); + String s = Utility.signatureToString(type2.getSignature(),false); parmString.append(s); if ((i+1)<args.length) parmString.append(","); } |