diff options
author | Andy Clement <andrew.clement@gmail.com> | 2012-04-02 14:15:08 -0700 |
---|---|---|
committer | Andy Clement <andrew.clement@gmail.com> | 2012-04-02 14:15:08 -0700 |
commit | 096b004fda4d21cca0e1ee4c776e5824715d0ecd (patch) | |
tree | 1b56bf3e3ba31d909df8822f9ef7093166916c19 /tests/bugs170 | |
parent | f85631fd2fb2e0f3213abb9c5a7cd86eec2c9ab5 (diff) | |
download | aspectj-096b004fda4d21cca0e1ee4c776e5824715d0ecd.tar.gz aspectj-096b004fda4d21cca0e1ee4c776e5824715d0ecd.zip |
375881
Diffstat (limited to 'tests/bugs170')
24 files changed, 372 insertions, 0 deletions
diff --git a/tests/bugs170/xmldefs/Anno.class b/tests/bugs170/xmldefs/Anno.class Binary files differnew file mode 100644 index 000000000..6e378d760 --- /dev/null +++ b/tests/bugs170/xmldefs/Anno.class diff --git a/tests/bugs170/xmldefs/Anno.java b/tests/bugs170/xmldefs/Anno.java new file mode 100644 index 000000000..7bb1cb2aa --- /dev/null +++ b/tests/bugs170/xmldefs/Anno.java @@ -0,0 +1,5 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +public @interface Anno { +} diff --git a/tests/bugs170/xmldefs/Anno2.java b/tests/bugs170/xmldefs/Anno2.java new file mode 100644 index 000000000..f5dfcb99f --- /dev/null +++ b/tests/bugs170/xmldefs/Anno2.java @@ -0,0 +1,5 @@ +import java.lang.annotation.*; + +// deliberately wrong retention +public @interface Anno2 { +} diff --git a/tests/bugs170/xmldefs/Anno4.java b/tests/bugs170/xmldefs/Anno4.java new file mode 100644 index 000000000..ebff22092 --- /dev/null +++ b/tests/bugs170/xmldefs/Anno4.java @@ -0,0 +1,25 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoString { + String value() default "xyz"; + String sss() default "xyz"; +} + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoLong { + long value() default 111L; + long jjj() default 111L; +} + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoBoolean { + boolean value() default false; + boolean zzz() default false; +} + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoClass { + Class value() default String.class; + Class ccc() default String.class; +} diff --git a/tests/bugs170/xmldefs/Anno5.java b/tests/bugs170/xmldefs/Anno5.java new file mode 100644 index 000000000..5906bcaa1 --- /dev/null +++ b/tests/bugs170/xmldefs/Anno5.java @@ -0,0 +1,37 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoShort { + short value() default 3; + short sss() default 3; +} + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoDouble { + double value() default 3.0d; + double ddd() default 3.0d; +} + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoFloat { + float value() default 4.0f; + float fff() default 4.0f; +} + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoChar { + char value() default 'a'; + char ccc() default 'a'; +} + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoByte { + byte value() default 66; + byte bbb() default 66; +} + +@Retention(RetentionPolicy.RUNTIME) +@interface AnnoInt { + int value() default 111; + int iii() default 111; +} diff --git a/tests/bugs170/xmldefs/Anno6.java b/tests/bugs170/xmldefs/Anno6.java new file mode 100644 index 000000000..18d8f544b --- /dev/null +++ b/tests/bugs170/xmldefs/Anno6.java @@ -0,0 +1,9 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface Annot { + char a(); + boolean fred(); + String value(); +} + diff --git a/tests/bugs170/xmldefs/AnnoBoolean.class b/tests/bugs170/xmldefs/AnnoBoolean.class Binary files differnew file mode 100644 index 000000000..33b76156a --- /dev/null +++ b/tests/bugs170/xmldefs/AnnoBoolean.class diff --git a/tests/bugs170/xmldefs/AnnoClass.class b/tests/bugs170/xmldefs/AnnoClass.class Binary files differnew file mode 100644 index 000000000..4071d56d6 --- /dev/null +++ b/tests/bugs170/xmldefs/AnnoClass.class diff --git a/tests/bugs170/xmldefs/AnnoLong.class b/tests/bugs170/xmldefs/AnnoLong.class Binary files differnew file mode 100644 index 000000000..a7990fbad --- /dev/null +++ b/tests/bugs170/xmldefs/AnnoLong.class diff --git a/tests/bugs170/xmldefs/AnnoString.class b/tests/bugs170/xmldefs/AnnoString.class Binary files differnew file mode 100644 index 000000000..ba0e8eaf7 --- /dev/null +++ b/tests/bugs170/xmldefs/AnnoString.class diff --git a/tests/bugs170/xmldefs/Foo.class b/tests/bugs170/xmldefs/Foo.class Binary files differnew file mode 100644 index 000000000..eaa12c965 --- /dev/null +++ b/tests/bugs170/xmldefs/Foo.class diff --git a/tests/bugs170/xmldefs/Foo.java b/tests/bugs170/xmldefs/Foo.java new file mode 100644 index 000000000..2edbdabfd --- /dev/null +++ b/tests/bugs170/xmldefs/Foo.java @@ -0,0 +1,3 @@ +public aspect Foo { + declare @method: * sayHello(..): @Anno; +} diff --git a/tests/bugs170/xmldefs/Hello.java b/tests/bugs170/xmldefs/Hello.java new file mode 100644 index 000000000..fdf29eab3 --- /dev/null +++ b/tests/bugs170/xmldefs/Hello.java @@ -0,0 +1,36 @@ +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; + +public class Hello { + + public static void main(String[] args) { + sayHello(); + printAnnos("sayHello"); + } + + public static void sayHello() { + System.out.println("Hello"); + sayWorld(); + } + + public static int sayWorld() { + System.out.println("World"); + return 0; + } + + public static void printAnnos(String methodname) { + try { + Method m = Hello.class.getDeclaredMethod(methodname); + Annotation[] annos = m.getAnnotations(); + System.out.println("Annotations on "+methodname+"? "+(annos!=null && annos.length!=0)); + if (annos!=null && annos.length>0) { + System.out.println("Annotation count is "+annos.length); + for (Annotation anno: annos) { + System.out.println(anno); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/tests/bugs170/xmldefs/Hello2.java b/tests/bugs170/xmldefs/Hello2.java new file mode 100644 index 000000000..9fa6a4a9a --- /dev/null +++ b/tests/bugs170/xmldefs/Hello2.java @@ -0,0 +1,27 @@ +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; + +public class Hello2 { + + public static int i; + + public static void main(String[] args) { + printAnnos("i"); + } + + public static void printAnnos(String fieldname) { + try { + Field m = Hello2.class.getDeclaredField(fieldname); + Annotation[] annos = m.getAnnotations(); + System.out.println("Annotations on "+fieldname+"? "+(annos!=null && annos.length!=0)); + if (annos!=null && annos.length>0) { + System.out.println("Annotation count is "+annos.length); + for (Annotation anno: annos) { + System.out.println(anno); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/tests/bugs170/xmldefs/Hello4.java b/tests/bugs170/xmldefs/Hello4.java new file mode 100644 index 000000000..7f7c6183b --- /dev/null +++ b/tests/bugs170/xmldefs/Hello4.java @@ -0,0 +1,42 @@ +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.*; +public class Hello4 { + + public static int field1; + public static int field2; + + public static void main(String[] args) { + printAnnos("field1"); + printAnnos("field2"); + } + + public static void printAnnos(String fieldname) { + try { + Field m = Hello4.class.getDeclaredField(fieldname); + Annotation[] annos = m.getAnnotations(); + System.out.println("Annotations on "+fieldname+"? "+(annos!=null && annos.length!=0)); + if (annos!=null && annos.length>0) { + List<Annotation> la = new ArrayList<Annotation>(); + for (Annotation anno: annos) { + la.add(anno); + } + Collections.<Annotation>sort(la,new AnnoComparator()); + + System.out.println("Annotation count is "+annos.length); + for (Annotation anno: la) { + System.out.println(anno); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + static class AnnoComparator implements Comparator<Annotation> { + public int compare(Annotation a, Annotation b) { + return a.toString().compareTo(b.toString()); + } + } +} diff --git a/tests/bugs170/xmldefs/Hello5.java b/tests/bugs170/xmldefs/Hello5.java new file mode 100644 index 000000000..361415a3e --- /dev/null +++ b/tests/bugs170/xmldefs/Hello5.java @@ -0,0 +1,42 @@ +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.*; +public class Hello5 { + + public static int field1; + public static int field2; + + public static void main(String[] args) { + printAnnos("field1"); + printAnnos("field2"); + } + + public static void printAnnos(String fieldname) { + try { + Field m = Hello5.class.getDeclaredField(fieldname); + Annotation[] annos = m.getAnnotations(); + System.out.println("Annotations on "+fieldname+"? "+(annos!=null && annos.length!=0)); + if (annos!=null && annos.length>0) { + List<Annotation> la = new ArrayList<Annotation>(); + for (Annotation anno: annos) { + la.add(anno); + } + Collections.<Annotation>sort(la,new AnnoComparator()); + + System.out.println("Annotation count is "+annos.length); + for (Annotation anno: la) { + System.out.println(anno); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + static class AnnoComparator implements Comparator<Annotation> { + public int compare(Annotation a, Annotation b) { + return a.toString().compareTo(b.toString()); + } + } +} diff --git a/tests/bugs170/xmldefs/Hello6.java b/tests/bugs170/xmldefs/Hello6.java new file mode 100644 index 000000000..568a5b46e --- /dev/null +++ b/tests/bugs170/xmldefs/Hello6.java @@ -0,0 +1,41 @@ +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.*; + +public class Hello6 { + + public static int field1; + + public static void main(String[] args) { + printAnnos("field1"); + } + + public static void printAnnos(String fieldname) { + try { + Field m = Hello6.class.getDeclaredField(fieldname); + Annotation[] annos = m.getAnnotations(); + System.out.println("Annotations on "+fieldname+"? "+(annos!=null && annos.length!=0)); + if (annos!=null && annos.length>0) { + List<Annotation> la = new ArrayList<Annotation>(); + for (Annotation anno: annos) { + la.add(anno); + } + Collections.<Annotation>sort(la,new AnnoComparator()); + + System.out.println("Annotation count is "+annos.length); + for (Annotation anno: la) { + System.out.println(anno); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + static class AnnoComparator implements Comparator<Annotation> { + public int compare(Annotation a, Annotation b) { + return a.toString().compareTo(b.toString()); + } + } +} diff --git a/tests/bugs170/xmldefs/aop.xml b/tests/bugs170/xmldefs/aop.xml new file mode 100644 index 000000000..afa85168b --- /dev/null +++ b/tests/bugs170/xmldefs/aop.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<aspectj> + <aspects> + <concrete-aspect name="ConjuredUp"> + <declare-annotation method="* Hello.sayHello(..)" annotation="@Anno"/> + </concrete-aspect> + </aspects> + + <weaver options="-Xreweavable -verbose -XlazyTjp -showWeaveInfo"> + <include within="Hello"/> + </weaver> +</aspectj> + diff --git a/tests/bugs170/xmldefs/aop2.xml b/tests/bugs170/xmldefs/aop2.xml new file mode 100644 index 000000000..d5ebdf7af --- /dev/null +++ b/tests/bugs170/xmldefs/aop2.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<aspectj> + <aspects> + <concrete-aspect name="ConjuredUp"> + <declare-annotation method="* Hello.sayHello(..)" annotation="@Anno2"/> + </concrete-aspect> + </aspects> + + <weaver options="-Xreweavable -verbose -XlazyTjp -showWeaveInfo"> + <include within="Hello"/> + </weaver> +</aspectj> + diff --git a/tests/bugs170/xmldefs/aop3.xml b/tests/bugs170/xmldefs/aop3.xml new file mode 100644 index 000000000..a65a552ed --- /dev/null +++ b/tests/bugs170/xmldefs/aop3.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<aspectj> + <aspects> + <concrete-aspect name="ConjuredUp"> + <declare-annotation field="* i" annotation="@Anno"/> + </concrete-aspect> + </aspects> + + <weaver options="-Xreweavable -verbose -XlazyTjp -showWeaveInfo"> + <include within="Hello2"/> + </weaver> +</aspectj> + diff --git a/tests/bugs170/xmldefs/aop4.xml b/tests/bugs170/xmldefs/aop4.xml new file mode 100644 index 000000000..1cf61807b --- /dev/null +++ b/tests/bugs170/xmldefs/aop4.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<aspectj> + <aspects> + <concrete-aspect name="ConjuredUp"> + <declare-annotation field="* field1(..)" annotation="@AnnoString("set from xml")"/> + <declare-annotation field="* field1(..)" annotation="@AnnoLong(999)"/> + <declare-annotation field="* field1(..)" annotation="@AnnoBoolean(true)"/> + <declare-annotation field="* field1(..)" annotation="@AnnoClass(Integer.class)"/> + <declare-annotation field="* field2(..)" annotation="@AnnoClass()"/> <!-- testing empty paren --> + </concrete-aspect> + </aspects> + + <weaver options="-Xreweavable -verbose -XlazyTjp -showWeaveInfo"> + <include within="Hello4"/> + </weaver> +</aspectj> + diff --git a/tests/bugs170/xmldefs/aop5.xml b/tests/bugs170/xmldefs/aop5.xml new file mode 100644 index 000000000..31a5f7d48 --- /dev/null +++ b/tests/bugs170/xmldefs/aop5.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<aspectj> + <aspects> + <concrete-aspect name="ConjuredUp"> + <declare-annotation field="* field1(..)" annotation="@AnnoShort(8)"/> + <declare-annotation field="* field1(..)" annotation="@AnnoChar('z')"/> + <declare-annotation field="* field1(..)" annotation="@AnnoDouble(99.0d)"/> + <declare-annotation field="* field1(..)" annotation="@AnnoFloat(6.0f)"/> + <declare-annotation field="* field2(..)" annotation="@AnnoByte(88)"/> + <declare-annotation field="* field2(..)" annotation="@AnnoInt(99)"/> + </concrete-aspect> + </aspects> + + <weaver options="-Xreweavable -verbose -XlazyTjp -showWeaveInfo"> + <include within="Hello5"/> + </weaver> +</aspectj> + diff --git a/tests/bugs170/xmldefs/aop6.xml b/tests/bugs170/xmldefs/aop6.xml new file mode 100644 index 000000000..06300b72f --- /dev/null +++ b/tests/bugs170/xmldefs/aop6.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<aspectj> + <aspects> + <concrete-aspect name="ConjuredUp"> + <declare-annotation field="* field1(..)" annotation="@Annot(a='a',fred=false,'abc')"/> + </concrete-aspect> + </aspects> + + <weaver options="-Xreweavable -verbose -XlazyTjp -showWeaveInfo"> + <include within="Hello6"/> + </weaver> +</aspectj> + diff --git a/tests/bugs170/xmldefs/aop6a.xml b/tests/bugs170/xmldefs/aop6a.xml new file mode 100644 index 000000000..2c6410a9b --- /dev/null +++ b/tests/bugs170/xmldefs/aop6a.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<aspectj> + <aspects> + <concrete-aspect name="ConjuredUp"> + <declare-annotation field="* field1(..)" annotation="@Annot( a= 'a' , fred = false, 'abc' )"/> + </concrete-aspect> + </aspects> + + <weaver options="-Xreweavable -verbose -XlazyTjp -showWeaveInfo"> + <include within="Hello6"/> + </weaver> +</aspectj> + |