aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs161
diff options
context:
space:
mode:
authoraclement <aclement>2008-05-22 23:57:23 +0000
committeraclement <aclement>2008-05-22 23:57:23 +0000
commit5e3e0b6a07c1a1e270786faf72e6a7a54972f821 (patch)
tree712b3106023cf21bb76ffe64516dfa2ae885149a /tests/bugs161
parent93b7bedd6e367f07cf74782b6d367b9f6f418698 (diff)
downloadaspectj-5e3e0b6a07c1a1e270786faf72e6a7a54972f821.tar.gz
aspectj-5e3e0b6a07c1a1e270786faf72e6a7a54972f821.zip
227401: test and fix - use correct declaring type when building tjp so getDeclaringType() works at runtime
Diffstat (limited to 'tests/bugs161')
-rw-r--r--tests/bugs161/pr227401/Fails.java42
-rw-r--r--tests/bugs161/pr227401/Instrumentation.java50
-rw-r--r--tests/bugs161/pr227401/Works.java41
3 files changed, 133 insertions, 0 deletions
diff --git a/tests/bugs161/pr227401/Fails.java b/tests/bugs161/pr227401/Fails.java
new file mode 100644
index 000000000..385c143bd
--- /dev/null
+++ b/tests/bugs161/pr227401/Fails.java
@@ -0,0 +1,42 @@
+public class Fails {
+
+ interface I {
+ static final int CONST = 56;
+ }
+
+ static class A<T> {
+ protected int prot;
+ protected String protS;
+ int def;
+ String defS;
+ T foo;
+ }
+
+ static class B extends A<String> 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";
+ foo = "todo";
+ System.out.println(defS + def);
+// // interface
+// System.out.println(CONST);
+ }
+ }
+
+ public static void main(String[] args) {
+ B b = new B();
+ b.m();
+ }
+}
+
diff --git a/tests/bugs161/pr227401/Instrumentation.java b/tests/bugs161/pr227401/Instrumentation.java
new file mode 100644
index 000000000..64c6ec168
--- /dev/null
+++ b/tests/bugs161/pr227401/Instrumentation.java
@@ -0,0 +1,50 @@
+import java.lang.reflect.Field;
+
+import org.aspectj.lang.reflect.*;
+
+public aspect Instrumentation {
+ pointcut nofl() : !within(Instrumentation);
+
+ pointcut getField() : get(* *) && nofl() && !get(* System.out) ;
+
+ after() : getField() {
+ final FieldSignature signature = (FieldSignature) thisJoinPointStaticPart.getSignature();
+ StringBuffer jpInfo = new StringBuffer();
+ jpInfo.append("getField(* ").append(signature.getName()).append(")");
+ final Field field = signature.getField();
+ jpInfo.append(" getField()='").append(signature.getField()).append("'");
+ final Class<?> declaringType = signature.getDeclaringType();
+ jpInfo.append(" getDeclaringType()='"+declaringType).append("'");
+ final Object receiver = thisJoinPoint.getTarget();
+ if (receiver == null) {
+ jpInfo.append(" signature.getTarget() is null (only ok if static)");
+ }
+ System.out.println(jpInfo.toString());
+ }
+
+
+
+/*
+ pointcut setField() : set(* *) && nofl();
+
+ after() : setField() {
+ System.out.println("setField()");
+ final FieldSignature signature = (FieldSignature) thisJoinPointStaticPart
+ .getSignature();
+ final Field field = signature.getField();
+ if (field == null)
+ System.out.println(" - field " + signature.getName()
+ + " is null...bug!");
+ final Class<?> declaringType = signature.getDeclaringType();
+ if (declaringType == null)
+ System.out.println(" - declaringType for the field "
+ + signature.getName() + " is null...bug!");
+ final Object receiver = thisJoinPoint.getTarget();
+ if (receiver == null)
+ System.out.println(" - target (receiver) for the field "
+ + signature.getName() + " is null...bug!");
+ }
+*/
+
+}
+
diff --git a/tests/bugs161/pr227401/Works.java b/tests/bugs161/pr227401/Works.java
new file mode 100644
index 000000000..e8e31d206
--- /dev/null
+++ b/tests/bugs161/pr227401/Works.java
@@ -0,0 +1,41 @@
+public class Works {
+
+ interface I {
+ static final int CONST = 56;
+ }
+
+ static class A {
+ protected int prot;
+ protected String protS;
+ int def;
+ String defS;
+ String foo;
+ }
+
+ static 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 = 3;
+// super.defS = "3";
+// System.out.println(defS + def);
+// def = 4;
+// defS = "4";
+// foo = "todo";
+// System.out.println(defS + def);
+// // interface
+// System.out.println(CONST);
+ }
+ }
+
+ public static void main(String[] args) {
+ B b = new B();
+ b.m();
+ }
+}