aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java13
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java16
-rw-r--r--tests/bugs150/pr77269/pack/pr77269.aj24
-rw-r--r--tests/bugs150/pr77269/pack/pr77269c.aj19
-rw-r--r--tests/bugs150/pr77269b.aj23
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java105
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150.xml22
7 files changed, 218 insertions, 4 deletions
diff --git a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
index cc95646cf..e1757981f 100644
--- a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
+++ b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java
@@ -153,7 +153,7 @@ public class AspectJElementHierarchy implements IHierarchy {
// this searches each file for a class
for (Iterator it = packageNode.getChildren().iterator(); it.hasNext(); ) {
IProgramElement fileNode = (IProgramElement)it.next();
- IProgramElement cNode = findClassInNodes(fileNode.getChildren(), typeName);
+ IProgramElement cNode = findClassInNodes(fileNode.getChildren(), typeName, typeName);
if (cNode != null) {
ret = cNode;
typeMap.put(key,ret);
@@ -163,7 +163,7 @@ public class AspectJElementHierarchy implements IHierarchy {
return ret;
}
- private IProgramElement findClassInNodes(Collection nodes, String name) {
+ private IProgramElement findClassInNodes(Collection nodes, String name, String typeName) {
String baseName;
String innerName;
int dollar = name.indexOf('$');
@@ -179,9 +179,16 @@ public class AspectJElementHierarchy implements IHierarchy {
IProgramElement classNode = (IProgramElement)j.next();
if (baseName.equals(classNode.getName())) {
if (innerName == null) return classNode;
- else return findClassInNodes(classNode.getChildren(), innerName);
+ else return findClassInNodes(classNode.getChildren(), innerName, typeName);
} else if (name.equals(classNode.getName())) {
return classNode;
+ } else if (typeName.equals(classNode.getBytecodeSignature())) {
+ return classNode;
+ } else if (classNode.getChildren() != null && !classNode.getChildren().isEmpty()){
+ IProgramElement node = findClassInNodes(classNode.getChildren(),name, typeName);
+ if (node != null) {
+ return node;
+ }
}
}
return null;
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 165b21ba4..b46866d0f 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
@@ -331,7 +331,21 @@ public class AsmHierarchyBuilder extends ASTVisitor {
new ArrayList());
peNode.setSourceSignature(genSourceSignature(memberTypeDeclaration));
peNode.setFormalComment(generateJavadocComment(memberTypeDeclaration));
-
+ // if we're something like 'new Runnable(){..}' then set the
+ // bytecodeSignature to be the typename so we can match it later
+ // when creating the structure model
+ if (peNode.getBytecodeSignature() == null
+ && memberTypeDeclaration.binding != null
+ && memberTypeDeclaration.binding.constantPoolName() != null) {
+ StringTokenizer st = new StringTokenizer(
+ new String(memberTypeDeclaration.binding.constantPoolName()),"/");
+ while(st.hasMoreTokens()) {
+ String s = st.nextToken();
+ if (!st.hasMoreTokens()) {
+ peNode.setBytecodeSignature(s);
+ }
+ }
+ }
((IProgramElement)stack.peek()).addChild(peNode);
stack.push(peNode);
diff --git a/tests/bugs150/pr77269/pack/pr77269.aj b/tests/bugs150/pr77269/pack/pr77269.aj
new file mode 100644
index 000000000..014c1bed8
--- /dev/null
+++ b/tests/bugs150/pr77269/pack/pr77269.aj
@@ -0,0 +1,24 @@
+package pack;
+class Test {
+
+ public void testMethod() {
+ new Runnable() {
+ public void run() {
+ }
+ };
+ class C {
+ public void m(){
+ }
+ }
+ }
+
+}
+
+aspect A {
+
+ pointcut p() : execution(* run(..));
+
+ before() : p() {
+ }
+
+}
diff --git a/tests/bugs150/pr77269/pack/pr77269c.aj b/tests/bugs150/pr77269/pack/pr77269c.aj
new file mode 100644
index 000000000..948902347
--- /dev/null
+++ b/tests/bugs150/pr77269/pack/pr77269c.aj
@@ -0,0 +1,19 @@
+package pack;
+
+class Test {
+
+ public void testMethod() {
+ new Runnable() {
+ public void run() {
+ someMethod();
+ }
+ };
+ }
+
+ public void someMethod() {
+ }
+}
+
+aspect A {
+ declare warning : call(void someMethod(..)) : "blah blah blah";
+}
diff --git a/tests/bugs150/pr77269b.aj b/tests/bugs150/pr77269b.aj
new file mode 100644
index 000000000..4f95dbb2c
--- /dev/null
+++ b/tests/bugs150/pr77269b.aj
@@ -0,0 +1,23 @@
+class Test {
+
+ public void testMethod() {
+ new Runnable() {
+ public void run() {
+ }
+ };
+ class C {
+ public void m(){
+ }
+ }
+ }
+
+}
+
+aspect A {
+
+ pointcut p() : execution(* m(..));
+
+ before() : p() {
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
index f0e767625..e41053fe0 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
@@ -14,6 +14,8 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
@@ -23,6 +25,10 @@ import org.aspectj.apache.bcel.classfile.Signature;
import org.aspectj.apache.bcel.util.ClassPath;
import org.aspectj.apache.bcel.util.SyntheticRepository;
import org.aspectj.asm.AsmManager;
+import org.aspectj.asm.IHierarchy;
+import org.aspectj.asm.IProgramElement;
+import org.aspectj.asm.IRelationship;
+import org.aspectj.asm.internal.Relationship;
import org.aspectj.testing.XMLBasedAjcTestCase;
import org.aspectj.util.LangUtil;
@@ -490,6 +496,105 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
runTest("debug info in around advice inlining");
}
+ public void testAdviceInStructureModelWithAnonymousInnerClass_pr77269() {
+ //AsmManager.setReporting("c:/debug.txt",true,true,true,true);
+ runTest("advice in structure model with anonymous inner class");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+
+ // checking that the run() method inside anonymous inner class is in
+ // the structure model
+ IProgramElement anonRunMethodIPE = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.METHOD,"run()");
+
+ assertNotNull("Couldn't find 'run()' element in the tree",anonRunMethodIPE);
+ List l = AsmManager.getDefault().getRelationshipMap().get(anonRunMethodIPE);
+ assertNotNull("Should have some relationships but does not",l);
+ assertTrue("Should have one relationship but has " + l.size(),l.size()==1);
+ Relationship rel = (Relationship)l.get(0);
+ List targets = rel.getTargets();
+ assertTrue("Should have one target but has" + targets.size(),
+ targets.size()==1);
+ IProgramElement target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)targets.get(0));
+ assertEquals("target of relationship should be 'before(): p..' but is "
+ + target.toLabelString(),"before(): p..",target.toLabelString());
+
+
+ IProgramElement adviceIPE = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.ADVICE,"before(): p..");
+ assertNotNull("Couldn't find 'before(): p..' element in the tree",adviceIPE);
+ l = AsmManager.getDefault().getRelationshipMap().get(adviceIPE);
+ assertNotNull("Should have some relationships but does not",l);
+ assertTrue("Should have a relationship but does not ",l.size()>0);
+ for (Iterator iter = l.iterator(); iter.hasNext();) {
+ IRelationship element = (IRelationship) iter.next();
+ if (element.getName().equals("advises")) {
+ rel = (Relationship) element;
+ break;
+ }
+ }
+ targets = rel.getTargets();
+ assertTrue("Should have one target but has" + targets.size(),
+ targets.size()==1);
+ target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)targets.get(0));
+ assertEquals("target of relationship should be 'run()' but is "
+ + target.toLabelString(),"run()",target.toLabelString());
+
+ }
+
+ public void testAdviceInStructureModelWithNamedInnerClass_pr77269() {
+ //AsmManager.setReporting("c:/debug.txt",true,true,true,true);
+ runTest("advice in structure model with named inner class");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+
+ // checking that the m() method inside named inner class is in
+ // the structure model
+ IProgramElement namedMethodIPE = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.METHOD,"m()");
+ assertNotNull("Couldn't find 'm()' element in the tree",namedMethodIPE);
+ List l = AsmManager.getDefault().getRelationshipMap().get(namedMethodIPE);
+ assertNotNull("Should have some relationships but does not",l);
+ assertTrue("Should have one relationship but has " + l.size(),l.size()==1);
+ Relationship rel = (Relationship)l.get(0);
+ List targets = rel.getTargets();
+ assertTrue("Should have one target but has" + targets.size(),
+ targets.size()==1);
+ IProgramElement target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)targets.get(0));
+ assertEquals("target of relationship should be 'before(): p..' but is "
+ + target.toLabelString(),"before(): p..",target.toLabelString());
+
+
+ IProgramElement adviceIPE = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.ADVICE,"before(): p..");
+ assertNotNull("Couldn't find 'before(): p..' element in the tree",adviceIPE);
+ l = AsmManager.getDefault().getRelationshipMap().get(adviceIPE);
+ assertNotNull("Should have some relationships but does not",l);
+ assertTrue("Should have a relationship but does not ",l.size()>0);
+ for (Iterator iter = l.iterator(); iter.hasNext();) {
+ IRelationship element = (IRelationship) iter.next();
+ if (element.getName().equals("advises")) {
+ rel = (Relationship) element;
+ break;
+ }
+ }
+ targets = rel.getTargets();
+ assertTrue("Should have one target but has" + targets.size(),
+ targets.size()==1);
+ target = AsmManager.getDefault().getHierarchy().findElementForHandle((String)targets.get(0));
+ assertEquals("target of relationship should be 'm()' but is "
+ + target.toLabelString(),"m()",target.toLabelString());
+
+ }
+
+ public void testDWInStructureModelWithAnonymousInnerClass_pr77269() {
+ // AsmManager.setReporting("c:/debug.txt",true,true,true,true);
+ runTest("declare warning in structure model with anonymous inner class");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ IProgramElement pe = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.CODE,"method-call(void pack.Test.someMethod())");
+ assertNotNull("Couldn't find 'method-call(void pack.Test.someMethod())' element in the tree",pe);
+ }
+
+
// helper methods.....
public SyntheticRepository createRepos(File cpentry) {
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
index b91a3714d..c06e718ac 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
@@ -643,6 +643,24 @@
</compile>
<run class="pr100195"/>
</ajc-test>
+
+ <ajc-test dir="bugs150/pr77269" title="advice in structure model with anonymous inner class">
+ <compile files="pack/pr77269.aj" options="-emacssym">
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs150" title="advice in structure model with named inner class">
+ <compile files="pr77269b.aj" options="-emacssym">
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs150/pr77269" title="declare warning in structure model with anonymous inner class">
+ <compile files="pack/pr77269c.aj" options="-emacssym">
+ <message kind="warning" line="8" text="blah blah blah"/>
+ </compile>
+ </ajc-test>
+
+
<!-- ============================================================================ -->
<!-- ============================================================================ -->
@@ -4881,6 +4899,10 @@
<compile files="pr92311.aj"/>
</ajc-test>
+ <ajc-test dir="bugs150" title="ITD varargs problem">
+ <compile files="pr110906.aj"/>
+ </ajc-test>
+
<ajc-test dir="bugs150" title="generic itds and abstract method error">
<compile files="pr102357.aj"/>
<run class="pr102357"/>