aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2009-02-26 17:12:47 +0000
committeraclement <aclement>2009-02-26 17:12:47 +0000
commita378bdbeeb2f6fe19befbb45d2b44f1afb77ab44 (patch)
tree4f83570ee021d4349845c9411725246325cda939
parent7d41bf5a3b2fb4761c030c7c208752cfee2a514a (diff)
downloadaspectj-a378bdbeeb2f6fe19befbb45d2b44f1afb77ab44.tar.gz
aspectj-a378bdbeeb2f6fe19befbb45d2b44f1afb77ab44.zip
265729: testing ctor/field/method itds
-rw-r--r--tests/bugs164/pr265729/Aspect.java8
-rw-r--r--tests/bugs164/pr265729/Fruit.java3
-rw-r--r--tests/bugs164/pr265729/Orange.java4
-rw-r--r--tests/bugs164/pr265729/Strawberry.java4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java66
-rw-r--r--tests/src/org/aspectj/systemtest/ajc164/ajc164.xml6
6 files changed, 91 insertions, 0 deletions
diff --git a/tests/bugs164/pr265729/Aspect.java b/tests/bugs164/pr265729/Aspect.java
new file mode 100644
index 000000000..5e48a1ca3
--- /dev/null
+++ b/tests/bugs164/pr265729/Aspect.java
@@ -0,0 +1,8 @@
+import java.awt.*;
+import demo.*;
+
+public aspect Aspect {
+ public Color Orange.getColor() { return Color.orange; }
+ public Color Strawberry.color = Color.red;
+ public Fruit.new(Color c,String name) {this();}
+}
diff --git a/tests/bugs164/pr265729/Fruit.java b/tests/bugs164/pr265729/Fruit.java
new file mode 100644
index 000000000..ffe4d54e9
--- /dev/null
+++ b/tests/bugs164/pr265729/Fruit.java
@@ -0,0 +1,3 @@
+package demo;
+public class Fruit {
+}
diff --git a/tests/bugs164/pr265729/Orange.java b/tests/bugs164/pr265729/Orange.java
new file mode 100644
index 000000000..60c1dbff4
--- /dev/null
+++ b/tests/bugs164/pr265729/Orange.java
@@ -0,0 +1,4 @@
+package demo;
+
+public class Orange {
+}
diff --git a/tests/bugs164/pr265729/Strawberry.java b/tests/bugs164/pr265729/Strawberry.java
new file mode 100644
index 000000000..5547e3e36
--- /dev/null
+++ b/tests/bugs164/pr265729/Strawberry.java
@@ -0,0 +1,4 @@
+package demo;
+
+public class Strawberry {
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java b/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
index cfc86fce9..74175ea6a 100644
--- a/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
@@ -11,6 +11,7 @@
package org.aspectj.systemtest.ajc164;
import java.io.File;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -28,10 +29,75 @@ 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.testing.XMLBasedAjcTestCase;
public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+ /**
+ * This test program can be used to compare handles for faulted in binary
+ * aspects with handles that would be used if the aspect was available as
+ * source. There are two compile steps in the xml for the test - commenting
+ * out the first will allow the source handles to be seen, leaving it in
+ * will switch to binary. Effectively the only difference should be that in
+ * the binary case the handles are prefixed 'binaries'.
+ */
+ public void testItdsAspectPathModel_pr265729_1() {
+ runTest("aspectpath model");
+ AsmManager model = AsmManager.lastActiveStructureModel;
+ IHierarchy top = model.getHierarchy();
+ printModel(model);
+ IProgramElement ipe = null;
+
+ // ITD METHOD
+ // should be the ITD method from the binary aspect:
+ // public Color Orange.getColor() { return Color.orange; }
+ ipe = top.findElementForType("demo", "Orange");
+ assertNotNull(ipe);
+ assertEquals("<demo{Orange.java[Orange", ipe.getHandleIdentifier());
+ IRelationship ir = (IRelationship) model.getRelationshipMap().get(ipe).get(0);
+ String itdMethodHandle = (String) ir.getTargets().get(0);
+ // handle when all source: <{Aspect.java}Aspect)Orange.getColor
+ assertEquals("/binaries<{Aspect.java}Aspect)Orange.getColor", itdMethodHandle);
+ IProgramElement itdpe = model.getHierarchy().findElementForHandle(itdMethodHandle);
+ assertEquals("java.awt.Color", itdpe.getCorrespondingType(true));
+
+ // ITD FIELD
+ // should be the ITD field from the binary aspect:
+ // public Color Strawberry.color
+ ipe = top.findElementForType("demo", "Strawberry");
+ assertNotNull(ipe);
+ assertEquals("<demo{Strawberry.java[Strawberry", ipe.getHandleIdentifier());
+ ir = (IRelationship) model.getRelationshipMap().get(ipe).get(0);
+ String itdFieldHandle = (String) ir.getTargets().get(0);
+ // source handle <{Aspect.java}Aspect)Strawberry.color
+ assertEquals("/binaries<{Aspect.java}Aspect)Strawberry.color", itdFieldHandle);
+ IProgramElement itdfpe = model.getHierarchy().findElementForHandle(itdMethodHandle);
+ assertEquals("java.awt.Color", itdfpe.getCorrespondingType(true));
+
+ // ITD CONSTRUCTOR
+ // /binaries< Aspect.java}Aspect)java.awt.Color demo.Strawberry.color
+ ipe = top.findElementForType("demo", "Fruit");
+ assertNotNull(ipe);
+ assertEquals("<demo{Fruit.java[Fruit", ipe.getHandleIdentifier());
+ ir = (IRelationship) model.getRelationshipMap().get(ipe).get(0);
+ String itdCtorHandle = (String) ir.getTargets().get(0);
+ // source handle <{Aspect.java}Aspect)Fruit.Fruit_new)QColor;)QString;
+ assertEquals("/binaries<{Aspect.java}Aspect)Fruit.Fruit_new)QColor;)QString;", itdCtorHandle);
+ IProgramElement itdcpe = model.getHierarchy().findElementForHandle(itdCtorHandle);
+ List ptypes = itdcpe.getParameterTypes();
+ assertEquals("java.awt.Color", new String((char[]) ptypes.get(0)));
+ assertEquals("java.lang.String", new String((char[]) ptypes.get(1)));
+ }
+
+ private void printModel(AsmManager model) {
+ try {
+ model.dumptree(model.getHierarchy().getRoot(), 0);
+ model.dumprels(new PrintWriter(System.out));
+ } catch (Exception e) {
+ }
+ }
+
public void testGenericsAopXml_pr266220() {
runTest("generics and aop.xml");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc164/ajc164.xml b/tests/src/org/aspectj/systemtest/ajc164/ajc164.xml
index ecdf7ef9f..b7cba2424 100644
--- a/tests/src/org/aspectj/systemtest/ajc164/ajc164.xml
+++ b/tests/src/org/aspectj/systemtest/ajc164/ajc164.xml
@@ -2,6 +2,12 @@
<suite>
+ <ajc-test dir="bugs164/pr265729" title="aspectpath model">
+ <compile files="Aspect.java Orange.java Strawberry.java Fruit.java" outjar="library.jar" options="-emacssym"/>
+ <compile files="Orange.java Strawberry.java Fruit.java" aspectpath="library.jar" options="-emacssym"/>
+ <!--
+ -->
+ </ajc-test>
<ajc-test dir="bugs164/pr266220" title="generics and aop.xml">
<compile files="Code.java"/>