aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs1612
diff options
context:
space:
mode:
authoraclement <aclement>2011-09-02 22:33:11 +0000
committeraclement <aclement>2011-09-02 22:33:11 +0000
commit49a7b98059209f2454dde2b32875f8809d9f4fd4 (patch)
tree1483844dc57c87e08d58347ec2f0f7f24514f0f5 /tests/bugs1612
parent09d62cfc430b911d96ab80e889f6e7c8aee827a1 (diff)
downloadaspectj-49a7b98059209f2454dde2b32875f8809d9f4fd4.tar.gz
aspectj-49a7b98059209f2454dde2b32875f8809d9f4fd4.zip
356612
Diffstat (limited to 'tests/bugs1612')
-rw-r--r--tests/bugs1612/pr356612/AnnoBinding.java68
-rw-r--r--tests/bugs1612/pr356612/AnnoBinding2.java48
2 files changed, 116 insertions, 0 deletions
diff --git a/tests/bugs1612/pr356612/AnnoBinding.java b/tests/bugs1612/pr356612/AnnoBinding.java
new file mode 100644
index 000000000..7bee9c52f
--- /dev/null
+++ b/tests/bugs1612/pr356612/AnnoBinding.java
@@ -0,0 +1,68 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import org.aspectj.lang.reflect.FieldSignature;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Marker {
+ String message();
+}
+
+public class AnnoBinding {
+ public static void main(String[] argv) {
+ long stime = System.currentTimeMillis();
+ for (int i = 0; i < 10000; i++) {
+ runOne();
+ }
+ long etime = System.currentTimeMillis();
+ long manual = (etime - stime);
+ stime = System.currentTimeMillis();
+ for (int i = 0; i < 10000; i++) {
+ runTwo();
+ }
+ etime = System.currentTimeMillis();
+ long woven = (etime - stime);
+ System.out.println("woven=" + woven + " manual=" + manual);
+ if (woven > manual) {
+ throw new RuntimeException("woven=" + woven + " manual=" + manual);
+ }
+ if (X.a != X.b) {
+ throw new RuntimeException("a=" + X.a + " b=" + X.b);
+ }
+ }
+
+ @Marker(message = "string")
+ static int field1;
+
+ @Marker(message = "string")
+ static int field2;
+
+ public static void runOne() {
+ field1 = field1 * 2; // set and get jps
+ }
+
+ public static void runTwo() {
+ field1 = field1 * 2; // set and get jps
+ }
+
+}
+
+aspect X {
+ pointcut pManual(): withincode(* runOne(..)) && get(@Marker * *);
+ pointcut pWoven(Marker l): withincode(* runTwo(..)) && get(@Marker * * ) && @annotation(l);
+
+ public static int a,b;
+
+ before(): pManual() {
+ Marker marker = (Marker) ((FieldSignature) thisJoinPointStaticPart.getSignature()).getField().getAnnotation(Marker.class);
+ String s = marker.message();
+ a+=s.length();
+ }
+
+ before(Marker l): pWoven(l) {
+ String s = l.message();
+ b+=s.length();
+ }
+
+
+}
diff --git a/tests/bugs1612/pr356612/AnnoBinding2.java b/tests/bugs1612/pr356612/AnnoBinding2.java
new file mode 100644
index 000000000..6c9b0b2be
--- /dev/null
+++ b/tests/bugs1612/pr356612/AnnoBinding2.java
@@ -0,0 +1,48 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import org.aspectj.lang.reflect.FieldSignature;
+
+import com.sun.org.apache.bcel.internal.classfile.Field;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Marker {
+ String message();
+}
+
+public class AnnoBinding2 {
+ public static void main(String[] argv) {
+ runOne();
+ runTwo();
+ java.lang.reflect.Field[] fs = AnnoBinding2.class.getDeclaredFields();
+ int count = 0;
+ for (java.lang.reflect.Field f: fs) {
+ if (f.getName().startsWith("ajc$anno")) {
+ count++;
+ }
+ }
+ System.out.println(count+" ajc$anno$NNN fields");
+ }
+
+ @Marker(message = "foo")
+ static int field1;
+
+ @Marker(message = "bar")
+ static int field2;
+
+ public static void runOne() {
+ field1 = field1 * 2; // set and get jps
+ }
+
+ public static void runTwo() {
+ field2 = field2 * 2; // set and get jps
+ }
+}
+
+aspect X {
+ pointcut pWoven(Marker l): withincode(* run*(..)) && get(@Marker * * ) && @annotation(l);
+
+ before(Marker l): pWoven(l) {
+ System.out.println(thisJoinPointStaticPart+" "+l);
+ }
+}