package org.aspectj.systemtest.ajc164;
import java.io.File;
+import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
import org.aspectj.apache.bcel.classfile.Method;
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.testing.XMLBasedAjcTestCase;
public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+ public void testHandles_pr263666() {
+ runTest("around advice handles");
+ IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
+ IProgramElement ipe = null;
+ ipe = findElementAtLine(top.getRoot(), 22);// public java.util.List<String> Ship.i(List<String>[][] u)
+ assertEquals("<x*OverrideOptions.aj}OverrideOptions&around", ipe.getHandleIdentifier());
+ ipe = findElementAtLine(top.getRoot(), 29);// public java.util.List<String> Ship.i(List<String>[][] u)
+ assertEquals("<x*OverrideOptions.aj}OverrideOptions&around!2", ipe.getHandleIdentifier());
+ }
+/*
+ // Only one of two aspects named
+ public void testAopConfig1() {
+ runTest("aop config - 1");
+ }
+
+ // Only one of two aspects named - and named one is scoped to only affect one type
+ public void testAopConfig2() {
+ runTest("aop config - 2");
+ }
+*/
public void testAjcThisNotRead() {
runTest("ajcthis not read");
}
runTest("recursive cflow");
}
- // public void testAopConfig1() {
- // runTest("aop config - 1");
- // }
-
public void testAnnoDecprecedence_pr256779() {
runTest("anno decprecedence");
}
return sb.toString();
}
+
+ private IProgramElement findElementAtLine(IProgramElement whereToLook, int line) {
+ if (whereToLook == null) {
+ return null;
+ }
+ if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) {
+ return whereToLook;
+ }
+ List kids = whereToLook.getChildren();
+ for (Iterator iterator = kids.iterator(); iterator.hasNext();) {
+ IProgramElement object = (IProgramElement) iterator.next();
+ if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) {
+ return object;
+ }
+ IProgramElement gotSomething = findElementAtLine(object, line);
+ if (gotSomething != null) {
+ return gotSomething;
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
<suite>
+ <ajc-test dir="bugs164/pr263666" title="around advice handles">
+ <compile files="x/A.java x/B.java x/OverrideOptions.aj" options="-1.5 -emacssym"/>
+ </ajc-test>
+
+
<ajc-test dir="features164/aopconfig/one" title="aop config - 1">
<compile files="A.java A2.java B.java foo.xml" options="-1.5 -showWeaveInfo">
- <message kind="weave" text="goo"/>
+ <message kind="weave" text="Join point 'staticinitialization(void A.<clinit>())' in Type 'A' (A.java:1) advised by before advice from 'A' (A.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void A2.<clinit>())' in Type 'A2' (A2.java:1) advised by before advice from 'A' (A.java:2)"/>
+ <message kind="weave" text="Join point 'staticinitialization(void B.<clinit>())' in Type 'B' (B.java:1) advised by before advice from 'A' (A.java:2)"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="features164/aopconfig/one" title="aop config - 2">
+ <compile files="A.java A2.java B.java B2.java foo2.xml" options="-1.5 -showWeaveInfo">
+ <message kind="weave" text="Join point 'staticinitialization(void B.<clinit>())' in Type 'B' (B.java:1) advised by before advice from 'A' (A.java:2)"/>
</compile>
</ajc-test>