summaryrefslogtreecommitdiffstats
path: root/tests/bugs160
diff options
context:
space:
mode:
authoraclement <aclement>2007-05-21 11:54:17 +0000
committeraclement <aclement>2007-05-21 11:54:17 +0000
commit737c6db800db02ec36d0951edece92c72e183079 (patch)
tree99cae924f611ef99e0e04478274f32d809116f31 /tests/bugs160
parentfc33d332792e3bc792b0d6ded56e3d894a1442cc (diff)
downloadaspectj-737c6db800db02ec36d0951edece92c72e183079.tar.gz
aspectj-737c6db800db02ec36d0951edece92c72e183079.zip
test and fix for 172107
Diffstat (limited to 'tests/bugs160')
-rw-r--r--tests/bugs160/pr172107/Instrumentation.aj40
-rw-r--r--tests/bugs160/pr172107/ReadWriteAJBug172107.java39
2 files changed, 79 insertions, 0 deletions
diff --git a/tests/bugs160/pr172107/Instrumentation.aj b/tests/bugs160/pr172107/Instrumentation.aj
new file mode 100644
index 000000000..d937dcbb0
--- /dev/null
+++ b/tests/bugs160/pr172107/Instrumentation.aj
@@ -0,0 +1,40 @@
+import java.lang.reflect.Field;
+
+import org.aspectj.lang.reflect.*;
+
+public aspect Instrumentation {
+
+ /**
+ * Instrument field reads.
+ */
+ pointcut getField() : get(* *) && !within(Instrumentation);
+
+ after() : getField() {
+ final FieldSignature signature = (FieldSignature) thisJoinPointStaticPart
+ .getSignature();
+ final Field field = signature.getField();
+ final SourceLocation sl = thisJoinPointStaticPart.getSourceLocation();
+ if (field == null) {
+ throw new IllegalStateException(
+ "See pr172107: get FieldSignature#getField()==null in "
+ + sl.getFileName() + " at line " + sl.getLine());
+ }
+ }
+
+ /**
+ * Instrument field reads.
+ */
+ pointcut setField() : set(* *) && !within(Instrumentation);
+
+ after() : setField() {
+ final FieldSignature signature = (FieldSignature) thisJoinPointStaticPart
+ .getSignature();
+ final Field field = signature.getField();
+ final SourceLocation sl = thisJoinPointStaticPart.getSourceLocation();
+ if (field == null) {
+ throw new IllegalStateException(
+ "See pr172107: set FieldSignature#getField()==null in "
+ + sl.getFileName() + " at line " + sl.getLine());
+ }
+ }
+}
diff --git a/tests/bugs160/pr172107/ReadWriteAJBug172107.java b/tests/bugs160/pr172107/ReadWriteAJBug172107.java
new file mode 100644
index 000000000..999ed5bd6
--- /dev/null
+++ b/tests/bugs160/pr172107/ReadWriteAJBug172107.java
@@ -0,0 +1,39 @@
+interface I {
+ static final int CONST = 56;
+}
+
+class A {
+ protected int prot;
+ protected String protS;
+ int def;
+ String defS;
+}
+
+class B extends A implements I {
+ void m() {
+ // protected
+ super.prot = 1;
+ super.protS = "1";
+ System.out.println(super.protS + super.prot);
+ prot = 2;
+ protS = "2";
+ System.out.println(protS + prot);
+ // default
+ super.def = 1;
+ super.defS = "1";
+ System.out.println(defS + def);
+ def = 2;
+ defS = "2";
+ System.out.println(defS + def);
+ // interface
+ System.out.println(CONST);
+ }
+}
+
+public class ReadWriteAJBug172107 {
+
+ public static void main(String[] args) {
+ B b = new B();
+ b.m();
+ }
+}