summaryrefslogtreecommitdiffstats
path: root/tests/bugs151
diff options
context:
space:
mode:
authoraclement <aclement>2006-01-17 13:34:44 +0000
committeraclement <aclement>2006-01-17 13:34:44 +0000
commit8b6fbd3ae387e8746cd24184e747d3f8acef3dc2 (patch)
tree38e2eb691c15216cf0b38729d9a2e5d6e26dbcdd /tests/bugs151
parentf4c8bf91bced2ba5bc1e0aa6b264549ced1efe70 (diff)
downloadaspectj-8b6fbd3ae387e8746cd24184e747d3f8acef3dc2.tar.gz
aspectj-8b6fbd3ae387e8746cd24184e747d3f8acef3dc2.zip
testcode for 123695
Diffstat (limited to 'tests/bugs151')
-rw-r--r--tests/bugs151/pr123695/InjectName.java7
-rw-r--r--tests/bugs151/pr123695/Main.java32
-rw-r--r--tests/bugs151/pr123695/MarkMyMethods.java7
-rw-r--r--tests/bugs151/pr123695/MarkMyMethodsAspect.java60
-rw-r--r--tests/bugs151/pr123695/NameAspect.java18
-rw-r--r--tests/bugs151/pr123695/Named.java5
-rw-r--r--tests/bugs151/pr123695/Read.java7
-rw-r--r--tests/bugs151/pr123695/Write.java7
8 files changed, 143 insertions, 0 deletions
diff --git a/tests/bugs151/pr123695/InjectName.java b/tests/bugs151/pr123695/InjectName.java
new file mode 100644
index 000000000..e1cfec5b3
--- /dev/null
+++ b/tests/bugs151/pr123695/InjectName.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+public @interface InjectName {
+
+}
diff --git a/tests/bugs151/pr123695/Main.java b/tests/bugs151/pr123695/Main.java
new file mode 100644
index 000000000..f70f2d674
--- /dev/null
+++ b/tests/bugs151/pr123695/Main.java
@@ -0,0 +1,32 @@
+import java.io.Serializable;
+@InjectName
+@MarkMyMethods
+public class Main {
+
+ public String name;
+
+ public Main() {
+ name = "jack";
+ }
+
+ public String testMethod() {
+ return "Test";
+ }
+
+ protected String testMethodProtected() {
+ return "Blah!";
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ Main m = new Main();
+ Class[] cls = Main.class.getInterfaces();
+ for(Class cl:cls) {
+ System.out.println("Interface : " + cl.getCanonicalName());
+ }
+ }
+
+}
diff --git a/tests/bugs151/pr123695/MarkMyMethods.java b/tests/bugs151/pr123695/MarkMyMethods.java
new file mode 100644
index 000000000..22536d9db
--- /dev/null
+++ b/tests/bugs151/pr123695/MarkMyMethods.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+public @interface MarkMyMethods {
+
+}
diff --git a/tests/bugs151/pr123695/MarkMyMethodsAspect.java b/tests/bugs151/pr123695/MarkMyMethodsAspect.java
new file mode 100644
index 000000000..3d6a57422
--- /dev/null
+++ b/tests/bugs151/pr123695/MarkMyMethodsAspect.java
@@ -0,0 +1,60 @@
+
+
+public aspect MarkMyMethodsAspect {
+
+ /* All methods not marked with @Read nor @Write are marked with @Write
+ *
+ * When @MarkMyMethods is present on a Type, all public methods of
+ * that type must either be marked with @Read or @Write. If neither of
+ * @Read or @Write is present on such a method, the method is automatically
+ * annotated with the default marker, i.e. @Write
+ *
+ * *******************************************************
+ * BUG
+ * internal null pointer exception with the first part
+ * of the declare statement.
+ * *******************************************************
+ *
+ */
+ declare @method : !@(Write || Read) public !static * (@MarkMyMethods *).*(..) : @Write;
+
+ // This one works
+ //declare @method : !@(Read) public !static * (@MarkMyMethods *).*(..) : @Write;
+ // This one too
+ //declare @method : !@(Write) public !static * (@MarkMyMethods *).*(..) : @Write;
+
+
+ /* Cannot have @Read or @Write methods without @MarkMyMethods
+ *
+ * When @Read or @Write is present on a method, the enclosing type must
+ * have the @AccessClassified annotation.
+ */
+ declare error : execution(@Read public * !@MarkMyMethods *.*(..)) :
+ "Cannot have public @Read methods inside non @AccessClassified types.";
+ declare error : execution(@Write public * !@MarkMyMethods *.*(..)) :
+ "Cannot have public @Write methods inside non @AccessClassified types.";
+
+ /* Cannot have a method marked with both @Read and @Write
+ *
+ * What would be necessary is to have an annotation that can take
+ * a parameter to identify which type of access is needed that would prevent
+ * the user from having the 2 at the same time e.g. @Access(READ). Unfortunately,
+ * AspectJ 1.5 can currently only work with marker annotations and ignores
+ * parameter annotations.
+ */
+ declare error : readMethod() && writeMethod() :
+ "Cannot have both @Read and @Write on the same method.";
+
+ /*
+ * public @Read methods inside @MarkMyMethods types
+ */
+ public pointcut readMethod() :
+ execution(@Read public !static * @MarkMyMethods *.*(..));
+
+ /*
+ * public @Write methods inside @MarkMyMethods types
+ */
+ public pointcut writeMethod() :
+ execution(@Write public !static * @MarkMyMethods *.*(..));
+
+}
diff --git a/tests/bugs151/pr123695/NameAspect.java b/tests/bugs151/pr123695/NameAspect.java
new file mode 100644
index 000000000..2e4f77f34
--- /dev/null
+++ b/tests/bugs151/pr123695/NameAspect.java
@@ -0,0 +1,18 @@
+
+public aspect NameAspect {
+
+
+ declare parents: @InjectName * implements Named;
+
+ /*
+ * The injection of that method interferes with the declare
+ * statements in MarkMyMethodsAspect
+ */
+ public String Named.getName() { return name; }
+ private String Named.name;
+
+ after(Named newinstance) : execution(Named+.new(..)) && target(newinstance) {
+ System.out.println("A new name was created");
+ newinstance.name = "TikaTikaSlimShady";
+ }
+}
diff --git a/tests/bugs151/pr123695/Named.java b/tests/bugs151/pr123695/Named.java
new file mode 100644
index 000000000..59b5464f2
--- /dev/null
+++ b/tests/bugs151/pr123695/Named.java
@@ -0,0 +1,5 @@
+
+public interface Named {
+ public String getName();
+
+}
diff --git a/tests/bugs151/pr123695/Read.java b/tests/bugs151/pr123695/Read.java
new file mode 100644
index 000000000..b874d7851
--- /dev/null
+++ b/tests/bugs151/pr123695/Read.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+public @interface Read {
+
+}
diff --git a/tests/bugs151/pr123695/Write.java b/tests/bugs151/pr123695/Write.java
new file mode 100644
index 000000000..1acdc9a0a
--- /dev/null
+++ b/tests/bugs151/pr123695/Write.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.METHOD)
+public @interface Write {
+
+}