From c8e951296c5f95e82d4c7c3f8eb9b0a647014e20 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Mon, 6 Oct 2014 17:35:51 -0700 Subject: Fix 436653: conditional aspect activation plus various polish Modified test expectation system so it is possible to say the test cares about one particular message and the rest do not matter (prefix message string with '*') - crude but quick. Polished many places to exploit generics Upgraded all the tests to work on Java8 - some serious changes regarding ajdoc on Java8. Hopefully it has stayed backwards compatible with earlier JDK versions (e.g. if using AspectJ 1.8.3+ with a JDK less than 8) but no explicit testing done for this. --- tests/java5/annotations/itds/AtItd3.aj | 3 ++- tests/java5/ataspectj/ajc-ant.xml | 8 ++++---- tests/java5/ataspectj/annotationGen/SA.aj | 14 ++++++++++++++ tests/java5/ataspectj/annotationGen/SA.class | Bin 0 -> 2832 bytes tests/java5/ataspectj/annotationGen/SimpleAspect.aj | 4 ++-- tests/java5/ataspectj/annotationGen/SimpleAspect.class | Bin 0 -> 2725 bytes 6 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 tests/java5/ataspectj/annotationGen/SA.aj create mode 100644 tests/java5/ataspectj/annotationGen/SA.class create mode 100644 tests/java5/ataspectj/annotationGen/SimpleAspect.class (limited to 'tests/java5') diff --git a/tests/java5/annotations/itds/AtItd3.aj b/tests/java5/annotations/itds/AtItd3.aj index bc6c671f9..c3412cf56 100644 --- a/tests/java5/annotations/itds/AtItd3.aj +++ b/tests/java5/annotations/itds/AtItd3.aj @@ -22,7 +22,8 @@ public class AtItd3 { Annotation aa = m.getAnnotation(Ann.class); System.err.println("Ann.class retrieved is: "+aa); - if (!aa.toString().equals("@Ann(id=goodbye, anInt=4)")) + if (!aa.toString().equals("@Ann(id=goodbye, anInt=4)")) // < Java8 order + if (!aa.toString().equals("@Ann(anInt=4, id=goodbye)")) // Java8 order throw new RuntimeException("Incorrect output, expected:"+ "@Ann(id=goodbye, anInt=4) but got "+aa.toString()); diff --git a/tests/java5/ataspectj/ajc-ant.xml b/tests/java5/ataspectj/ajc-ant.xml index 4f2e9f36c..0730d7b85 100644 --- a/tests/java5/ataspectj/ajc-ant.xml +++ b/tests/java5/ataspectj/ajc-ant.xml @@ -10,7 +10,7 @@ - - @@ -125,7 +125,7 @@ - @@ -171,7 +171,7 @@ - diff --git a/tests/java5/ataspectj/annotationGen/SA.aj b/tests/java5/ataspectj/annotationGen/SA.aj new file mode 100644 index 000000000..5ca3d661a --- /dev/null +++ b/tests/java5/ataspectj/annotationGen/SA.aj @@ -0,0 +1,14 @@ +import org.aspectj.lang.annotation.Aspect; +import java.lang.annotation.*; + +public aspect SA { + + public static void main(String[] args) { + Annotation[] annotations = SA.class.getAnnotations(); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation but has "+annotations.length); + Aspect aspectAnnotation = (Aspect) annotations[0]; +System.out.println(aspectAnnotation); + if (!aspectAnnotation.value().equals("")) throw new RuntimeException("value should be empty"); + } + +} diff --git a/tests/java5/ataspectj/annotationGen/SA.class b/tests/java5/ataspectj/annotationGen/SA.class new file mode 100644 index 000000000..1ce9f8f94 Binary files /dev/null and b/tests/java5/ataspectj/annotationGen/SA.class differ diff --git a/tests/java5/ataspectj/annotationGen/SimpleAspect.aj b/tests/java5/ataspectj/annotationGen/SimpleAspect.aj index 34f6954dc..731ef5ca9 100644 --- a/tests/java5/ataspectj/annotationGen/SimpleAspect.aj +++ b/tests/java5/ataspectj/annotationGen/SimpleAspect.aj @@ -5,9 +5,9 @@ public aspect SimpleAspect { public static void main(String[] args) { Annotation[] annotations = SimpleAspect.class.getAnnotations(); - if (annotations.length != 1) throw new RuntimeException("Should have one annotation"); + if (annotations.length != 1) throw new RuntimeException("Should have one annotation but has "+annotations.length); Aspect aspectAnnotation = (Aspect) annotations[0]; if (!aspectAnnotation.value().equals("")) throw new RuntimeException("value should be empty"); } -} \ No newline at end of file +} diff --git a/tests/java5/ataspectj/annotationGen/SimpleAspect.class b/tests/java5/ataspectj/annotationGen/SimpleAspect.class new file mode 100644 index 000000000..a5d815f04 Binary files /dev/null and b/tests/java5/ataspectj/annotationGen/SimpleAspect.class differ -- cgit v1.2.3