aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/privilegedAspects
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-16 18:51:06 +0000
committerwisberg <wisberg>2002-12-16 18:51:06 +0000
commit144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch)
treeb12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/privilegedAspects
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/privilegedAspects')
-rw-r--r--tests/new/privilegedAspects/driver/PR555.java65
-rw-r--r--tests/new/privilegedAspects/driver/PrivilegedAspect.java119
-rw-r--r--tests/new/privilegedAspects/driver/UnprivilegedAspect.java113
-rw-r--r--tests/new/privilegedAspects/fish/B.java27
-rw-r--r--tests/new/privilegedAspects/fish/PrivateClass.java32
-rw-r--r--tests/new/privilegedAspects/fowl/C.java18
-rw-r--r--tests/new/privilegedAspects/fowl/D.java17
-rw-r--r--tests/new/privilegedAspects/main/Main.java14
-rw-r--r--tests/new/privilegedAspects/notes.txt89
-rw-r--r--tests/new/privilegedAspects/pack/DefaultTarget.java70
-rw-r--r--tests/new/privilegedAspects/pack/PublicTarget.java69
-rw-r--r--tests/new/privilegedAspects/util/Util.java35
12 files changed, 668 insertions, 0 deletions
diff --git a/tests/new/privilegedAspects/driver/PR555.java b/tests/new/privilegedAspects/driver/PR555.java
new file mode 100644
index 000000000..92e1ef86e
--- /dev/null
+++ b/tests/new/privilegedAspects/driver/PR555.java
@@ -0,0 +1,65 @@
+
+package driver;
+
+//package pack; // check test passing
+// import pack.DefaultTarget; // not expected to work
+import org.aspectj.testing.Tester;
+import org.aspectj.testing.Tester;
+
+public class PR555 {
+ public static void main(String[] args) {
+ Tester.expectEvent("runner");
+ int i ;
+ i = PA.readPrivateStaticInt();
+ Tester.check(1==i,"PA.readPrivateStaticInt()");
+ i = PA.readPrivateStaticIntFromInner();
+ Tester.check(1==i,"PA.readPrivateStaticIntFromInner()");
+ i = PA.runIntroducedAnonymousInnerClass();
+ Tester.check(1==i,"PA.runIntroducedAnonymousInnerClass()");
+ Tester.checkAllEvents();
+ }
+
+}
+
+/* test access to private target variables */
+privileged aspect PA {
+
+ public static int readPrivateStaticInt() {
+ return pack.DefaultTarget.privateStaticInt;
+ }
+
+ public static int readPrivateStaticIntFromInner() {
+ return new Inner().readPrivateIntFromInner();
+ }
+
+ public static int runIntroducedAnonymousInnerClass() {
+ pack.DefaultTarget dtarget = new pack.DefaultTarget();
+ dtarget.runner.run();
+ return dtarget.privateInt;
+ //return dtarget.publicInt;
+ }
+
+ static class Inner {
+ public static final int i = pack.DefaultTarget.privateStaticInt;
+ //public static final int i = pack.DefaultTarget.publicStaticInt;
+ public int readPrivateIntFromInner() {
+ pack.DefaultTarget defaultTarget
+ = new pack.DefaultTarget();
+ return defaultTarget.privateInt;
+ //return defaultTarget.publicInt;
+ }
+ }
+
+ // todo: bug used unprivileged aspect to introduce
+ // todo: inner class of aspect or of DefaultTarget?
+ Runnable pack.DefaultTarget.runner = new Runnable() {
+ public void run() {
+ Tester.event("runner");
+ //if (1 != publicInt) {
+ if (1 != privateInt) {
+ throw new Error("1 != privateInt");
+ }
+ }
+ };
+}
+
diff --git a/tests/new/privilegedAspects/driver/PrivilegedAspect.java b/tests/new/privilegedAspects/driver/PrivilegedAspect.java
new file mode 100644
index 000000000..e29dffc17
--- /dev/null
+++ b/tests/new/privilegedAspects/driver/PrivilegedAspect.java
@@ -0,0 +1,119 @@
+
+package driver;
+
+// import pack.DefaultTarget; // does not work - ok
+import pack.PublicTarget;
+
+/**
+ * This aspect attempts to bind class references
+ * and read members of all access types
+ * from public- and default-access classes and inner classes
+ * from public static methods in the aspect. Usage:
+ * <pre>PrivilegedAspect.main(null);</pre>
+ * - or -
+ * <pre>PrivilegedAspect.readPublicTarget();
+ * PrivilegedAspect.readPublicInnerTarget();
+ * PrivilegedAspect.readDefaultTarget();
+ * PrivilegedAspect.readDefaultInnerTarget();</pre>
+ */
+public privileged aspect PrivilegedAspect {
+ /** run all other static methods
+ * @param args ignored */
+ public static void main(String[] args) {
+ readPublicTarget();
+ readPublicInnerTarget();
+ readDefaultTarget();
+ readDefaultInnerTarget();
+ }
+
+ /** in public class
+ * read static and instance fields and
+ * invoke methods, both of all access types
+ */
+ public static void readPublicTarget() {
+ Class c = PublicTarget.class;
+ int i = 0;
+ i += PublicTarget.publicStaticInt;
+ i += PublicTarget.protectedStaticInt;
+ i += PublicTarget.defaultStaticInt;
+ i += PublicTarget.privateStaticInt;
+ PublicTarget publicTarget = new PublicTarget();
+ i += publicTarget.publicInt;
+ i += publicTarget.protectedInt;
+ i += publicTarget.defaultInt;
+ i += publicTarget. privateInt;
+ publicTarget.publicMethod();
+ publicTarget.protectedMethod();
+ publicTarget.defaultMethod();
+ publicTarget.privateMethod();
+ }
+
+ /** in public inner class
+ * read static and instance fields and
+ * invoke methods, both of all access types
+ */
+ public static void readPublicInnerTarget() {
+ Class c = PublicTarget.PublicInner.class;
+ int i = 0;
+ i += PublicTarget.PublicInner.publicStaticPublicInnerInt;
+ i += PublicTarget.PublicInner.protectedStaticPublicInnerInt;
+ i += PublicTarget.PublicInner.defaultStaticPublicInnerInt;
+ i += PublicTarget.PublicInner.privateStaticPublicInnerInt;
+ PublicTarget.PublicInner publicInnerTarget
+ = new PublicTarget().new PublicInner();
+ i += publicInnerTarget.publicPublicInnerInt;
+ i += publicInnerTarget.protectedPublicInnerInt;
+ i += publicInnerTarget.defaultPublicInnerInt;
+ i += publicInnerTarget. privatePublicInnerInt;
+ publicInnerTarget.publicPublicInnerMethod();
+ publicInnerTarget.protectedPublicInnerMethod();
+ publicInnerTarget.defaultPublicInnerMethod();
+ publicInnerTarget.privatePublicInnerMethod();
+ }
+
+
+ /** in class with default access
+ * read static and instance fields and
+ * invoke methods, both of all access types
+ */
+ public static void readDefaultTarget() {
+ Class c = pack.DefaultTarget.class;
+ int i = 0;
+ i += pack.DefaultTarget.publicStaticInt;
+ i += pack.DefaultTarget.protectedStaticInt;
+ i += pack.DefaultTarget.defaultStaticInt;
+ i += pack.DefaultTarget.privateStaticInt;
+ pack.DefaultTarget defaultTarget = new pack.DefaultTarget();
+ i += defaultTarget.publicInt;
+ i += defaultTarget.protectedInt;
+ i += defaultTarget.defaultInt;
+ i += defaultTarget. privateInt;
+ defaultTarget.publicMethod();
+ defaultTarget.protectedMethod();
+ defaultTarget.defaultMethod();
+ defaultTarget.privateMethod();
+ }
+
+ /** in inner class with default access
+ * read static and instance fields and
+ * invoke methods, both of all access types
+ */
+ public static void readDefaultInnerTarget() {
+ Class c = pack.DefaultTarget.DefaultInner.class;
+ int i = 0;
+ i += pack.DefaultTarget.DefaultInner.publicStaticDefaultInnerInt;
+ i += pack.DefaultTarget.DefaultInner.protectedStaticDefaultInnerInt;
+ i += pack.DefaultTarget.DefaultInner.defaultStaticDefaultInnerInt;
+ i += pack.DefaultTarget.DefaultInner.privateStaticDefaultInnerInt;
+ pack.DefaultTarget.DefaultInner defaultInnerTarget
+ = new pack.DefaultTarget().new DefaultInner();
+ i += defaultInnerTarget.publicDefaultInnerInt;
+ i += defaultInnerTarget.protectedDefaultInnerInt;
+ i += defaultInnerTarget.defaultDefaultInnerInt;
+ i += defaultInnerTarget.privateDefaultInnerInt;
+ defaultInnerTarget.publicDefaultInnerMethod();
+ defaultInnerTarget.protectedDefaultInnerMethod();
+ defaultInnerTarget.defaultDefaultInnerMethod();
+ defaultInnerTarget.privateDefaultInnerMethod();
+ }
+}
diff --git a/tests/new/privilegedAspects/driver/UnprivilegedAspect.java b/tests/new/privilegedAspects/driver/UnprivilegedAspect.java
new file mode 100644
index 000000000..7a2c1283f
--- /dev/null
+++ b/tests/new/privilegedAspects/driver/UnprivilegedAspect.java
@@ -0,0 +1,113 @@
+
+package driver;
+
+// import pack.DefaultTarget; // does not work - ok
+import pack.PublicTarget;
+
+/**
+ * This is a copy of PrivilegedAspect, but without the privilege.
+ * It is an error test for unprivileged access to target classes
+ * esp. when compiled at the same time as PrivilegedAspect.
+ * todo: remove this case or render manageable.
+ */
+// Keep in sync with PrivilegedAspect
+public aspect UnprivilegedAspect {
+ /** run all other static methods
+ * @param args ignored */
+ public static void main(String[] args) {
+ readPublicTarget();
+ readPublicInnerTarget();
+ readDefaultTarget();
+ readDefaultInnerTarget();
+ }
+
+ /** in public class
+ * read static and instance fields and
+ * invoke methods, both of all access types
+ */
+ public static void readPublicTarget() {
+ Class c = PublicTarget.class;
+ int i = 0;
+ i += PublicTarget.publicStaticInt;
+ i += PublicTarget.protectedStaticInt;
+ i += PublicTarget.defaultStaticInt;
+ i += PublicTarget.privateStaticInt;
+ PublicTarget publicTarget = new PublicTarget();
+ i += publicTarget.publicInt;
+ i += publicTarget.protectedInt;
+ i += publicTarget.defaultInt;
+ i += publicTarget. privateInt;
+ publicTarget.publicMethod();
+ publicTarget.protectedMethod();
+ publicTarget.defaultMethod();
+ publicTarget.privateMethod();
+ }
+
+ /** in public inner class
+ * read static and instance fields and
+ * invoke methods, both of all access types
+ */
+ public static void readPublicInnerTarget() {
+ Class c = PublicTarget.PublicInner.class;
+ int i = 0;
+ i += PublicTarget.PublicInner.publicStaticPublicInnerInt;
+ i += PublicTarget.PublicInner.protectedStaticPublicInnerInt;
+ i += PublicTarget.PublicInner.defaultStaticPublicInnerInt;
+ i += PublicTarget.PublicInner.privateStaticPublicInnerInt;
+ PublicTarget.PublicInner publicInnerTarget
+ = new PublicTarget().new PublicInner();
+ i += publicInnerTarget.publicPublicInnerInt;
+ i += publicInnerTarget.protectedPublicInnerInt;
+ i += publicInnerTarget.defaultPublicInnerInt;
+ i += publicInnerTarget. privatePublicInnerInt;
+ publicInnerTarget.publicPublicInnerMethod();
+ publicInnerTarget.protectedPublicInnerMethod();
+ publicInnerTarget.defaultPublicInnerMethod();
+ publicInnerTarget.privatePublicInnerMethod();
+ }
+
+ /** in class with default access
+ * read static and instance fields and
+ * invoke methods, both of all access types
+ */
+ public static void readDefaultTarget() {
+ Class c = pack.DefaultTarget.class;
+ int i = 0;
+ i += pack.DefaultTarget.publicStaticInt;
+ i += pack.DefaultTarget.protectedStaticInt;
+ i += pack.DefaultTarget.defaultStaticInt;
+ i += pack.DefaultTarget.privateStaticInt;
+ pack.DefaultTarget defaultTarget = new pack.DefaultTarget();
+ i += defaultTarget.publicInt;
+ i += defaultTarget.protectedInt;
+ i += defaultTarget.defaultInt;
+ i += defaultTarget. privateInt;
+ defaultTarget.publicMethod();
+ defaultTarget.protectedMethod();
+ defaultTarget.defaultMethod();
+ defaultTarget.privateMethod();
+ }
+
+ /** in inner class with default access
+ * read static and instance fields and
+ * invoke methods, both of all access types
+ */
+ public static void readDefaultInnerTarget() {
+ Class c = pack.DefaultTarget.DefaultInner.class;
+ int i = 0;
+ i += pack.DefaultTarget.DefaultInner.publicStaticDefaultInnerInt;
+ i += pack.DefaultTarget.DefaultInner.protectedStaticDefaultInnerInt;
+ i += pack.DefaultTarget.DefaultInner.defaultStaticDefaultInnerInt;
+ i += pack.DefaultTarget.DefaultInner.privateStaticDefaultInnerInt;
+ pack.DefaultTarget.DefaultInner defaultInnerTarget
+ = new pack.DefaultTarget().new DefaultInner();
+ i += defaultInnerTarget.publicDefaultInnerInt;
+ i += defaultInnerTarget.protectedDefaultInnerInt;
+ i += defaultInnerTarget.defaultDefaultInnerInt;
+ i += defaultInnerTarget.privateDefaultInnerInt;
+ defaultInnerTarget.publicDefaultInnerMethod();
+ defaultInnerTarget.protectedDefaultInnerMethod();
+ defaultInnerTarget.defaultDefaultInnerMethod();
+ defaultInnerTarget.privateDefaultInnerMethod();
+ }
+}
diff --git a/tests/new/privilegedAspects/fish/B.java b/tests/new/privilegedAspects/fish/B.java
new file mode 100644
index 000000000..d56aef758
--- /dev/null
+++ b/tests/new/privilegedAspects/fish/B.java
@@ -0,0 +1,27 @@
+package fish;
+import main.Main;
+
+privileged aspect B {
+ private static String privateStatic = "B's private";
+
+ //introduction PrivateClass {
+ public void PrivateClass.fooB() {
+ b--;
+ Main.doThang("B: " + b);
+ Main.doThang("B: " + b());
+
+ System.out.println(privateStatic + "::" + FooC.privateStatic);
+ }
+ //}
+
+
+ before(PrivateClass obj): call(void PrivateClass.goo()) && target(obj) {
+ obj.b--;
+ Main.doThang("B: " + obj.b);
+ Main.doThang("B: " + obj.b());
+ }
+}
+
+class FooC {
+ private static int privateStatic = 2;
+}
diff --git a/tests/new/privilegedAspects/fish/PrivateClass.java b/tests/new/privilegedAspects/fish/PrivateClass.java
new file mode 100644
index 000000000..f02941036
--- /dev/null
+++ b/tests/new/privilegedAspects/fish/PrivateClass.java
@@ -0,0 +1,32 @@
+package fish;
+import main.Main;
+
+public class PrivateClass {
+ private int a = 999;
+ private int a() { return 888; }
+ private int b = 777;
+ private int b() { return 666; }
+ private int c = 555;
+ private int c() { return 444; }
+ private int d = 333;
+ private int d() { return 222; }
+
+ public void goo() {}
+}
+
+privileged aspect A {
+
+ public void PrivateClass.fooA() {
+ a--;
+ Main.doThang("A: " + a);
+ Main.doThang("A: " + a());
+ }
+
+ before(PrivateClass obj): call(void PrivateClass.goo()) && target(obj) {
+ obj.a--;
+ Main.doThang("A: " + obj.a);
+ Main.doThang("A: " + obj.a());
+ }
+}
+
+
diff --git a/tests/new/privilegedAspects/fowl/C.java b/tests/new/privilegedAspects/fowl/C.java
new file mode 100644
index 000000000..bc227f85f
--- /dev/null
+++ b/tests/new/privilegedAspects/fowl/C.java
@@ -0,0 +1,18 @@
+package fowl;
+import fish.PrivateClass;
+import main.Main;
+
+privileged aspect C {
+
+ public void PrivateClass.fooC() {
+ c--;
+ Main.doThang("C: " + c);
+ Main.doThang("C: " + c());
+ }
+
+ before(PrivateClass obj): call(void PrivateClass.goo()) && target(obj) {
+ obj.c--;
+ Main.doThang("C: " + obj.c);
+ Main.doThang("C: " + obj.c());
+ }
+}
diff --git a/tests/new/privilegedAspects/fowl/D.java b/tests/new/privilegedAspects/fowl/D.java
new file mode 100644
index 000000000..4b36d2fe8
--- /dev/null
+++ b/tests/new/privilegedAspects/fowl/D.java
@@ -0,0 +1,17 @@
+package fowl;
+import main.Main;
+
+privileged aspect D {
+
+ public void fish.PrivateClass.fooD() {
+ d--;
+ Main.doThang("D: " + d);
+ Main.doThang("D: " + d());
+ }
+
+ before(fish.PrivateClass obj): call(void fish.PrivateClass.goo()) && target(obj) {
+ obj.d--;
+ Main.doThang("D: " + obj.d);
+ Main.doThang("D: " + obj.d());
+ }
+}
diff --git a/tests/new/privilegedAspects/main/Main.java b/tests/new/privilegedAspects/main/Main.java
new file mode 100644
index 000000000..89b0877b7
--- /dev/null
+++ b/tests/new/privilegedAspects/main/Main.java
@@ -0,0 +1,14 @@
+package main;
+
+class Main {
+ public static void main(String[] args) {
+ fish.PrivateClass obj = new fish.PrivateClass();
+ obj.fooA();
+ obj.fooB();
+ obj.fooC();
+ obj.fooD();
+ obj.goo();
+ }
+
+ public static void doThang(String arg) {}
+}
diff --git a/tests/new/privilegedAspects/notes.txt b/tests/new/privilegedAspects/notes.txt
new file mode 100644
index 000000000..01eda6263
--- /dev/null
+++ b/tests/new/privilegedAspects/notes.txt
@@ -0,0 +1,89 @@
+
+testing privileged aspects
+These notes apply to subdirectories util, pack, and driver.
+
+---- privileged aspects
+- A privileged aspect ignores Java's accessibility rules and can access
+ any members anywhere in the world regardless of access restrictions.
+- The privilege extends to anything in the lexical scope of the
+ privileged aspect, including inner classes and aspects
+ - the privilege does not extend to members introduced
+ onto the privileged aspect
+ - the privilege does not extend to subaspects
+- a privileged aspect can be public
+- a privileged aspect can be an inner aspect
+ even a static inner aspect of a class
+- In some cases, providing this private access changes the access
+ permissions in the generated (byte)code, visible to other
+ classes compiled or running with the target class.
+ However, in the scope of the AspectJ compilation process,
+ only the privileged aspect should enjoy enhanced permissions
+- type names from external packages must be fully qualified in the
+ privileged aspect. the visibility of import statements in the
+ file of the privileged aspect is unchanged.
+ - as a result, if {static} inner aspects are permitted, they will
+ be unable to bind some names that their enclosing class/aspect
+ can bind unless they fully qualify the names.
+
+---- testing privileged aspects
+- binding: testing binding involves ensuring the class or aspect
+ can (or cannot) bind a name to a type or member at compile time
+ and can actually use that reference at runtime without an
+ IllegalAccessException
+
+testable statements:
+1 any aspect may be privileged, including abstract and inner aspects,
+ including static inner aspects of classes
+2 privileged aspects can bind any members of targets
+ - targets: classes, inner classes; aspects, inner aspects;
+ in the same package, a different package, and the default package
+ - sources in the privileged aspect:
+ - constructors, static and instance methods and initializers
+ - bodies for introduced methods and member initializers
+ - pointcut declarations
+ - pointcut pcd if() bodies
+ - advice bodies
+ - the same for inner classes and aspects
+3 when privileged aspects get this access, access does not change for
+ other classes in the same set of files compiled
+4 2 is not true of non-privileged subaspects of a privileged aspect
+5 AspectJ will open up the target class to the minimal extent possible,
+ subject to these rules:
+ - the access permissions for the privileged access will not change
+ - the class hierarchy of the privileged aspect or the target class
+ will not be modified to gain protected access
+ - if protected access is available, AspectJ will not convert
+ to default/package access or to public access
+ - if default/package access is available, AspectJ will not convert
+ to public access
+6 code in privileged aspects has no enhanced runtime permissions for
+ reflective access to (target classes or) non-target classes
+
+test plan:
+1 compile-time binding test:
+ - public and default access classes in one package
+ each with a corresponding inner class (public/default)
+ each class has static and instance members of all access types
+ -> pack.PublicTarget, pack.DefaultTarget
+ - privileged aspect in another package
+ accesses all target methods/members from static methods
+ -> driver.PrivilegedAspect
+2 test 1 with the aspect as an inner aspect
+ - unprivileged inner aspect of a privileged aspect
+ - privileged inner aspect of an unprivileged aspect
+ - static privileged inner aspect of a class
+3 test 1 with errors expected for protected/private/default access
+ for a non-privileged subaspect
+ -> driver.UnPrivilegedAspect
+
+----- Priority 3 tests
+4 test 1 with errors expected for private/default access
+ for a non-privileged subaspect inner class of a target subclass
+5 test 1 with errors expected for private access
+ for a non-privileged aspect in the same package
+
+---- current status
+Aggregate versions of tests 1 and 3 done; 2 is close. See -> above.
+Error tests are brittle since it is undefined how many errors the
+compiler will find in a file before giving up. The error test
+cases should be broken out into separate test cases/files.
diff --git a/tests/new/privilegedAspects/pack/DefaultTarget.java b/tests/new/privilegedAspects/pack/DefaultTarget.java
new file mode 100644
index 000000000..3c2231db4
--- /dev/null
+++ b/tests/new/privilegedAspects/pack/DefaultTarget.java
@@ -0,0 +1,70 @@
+
+package pack;
+
+import util.Util;
+
+/* copy/paste of PublicTarget with mods to default */
+class DefaultTarget {
+ public static int publicStaticInt = 1;
+ protected static int protectedStaticInt = 1;
+ static int defaultStaticInt = 1;
+ private static int privateStaticInt = 1;
+ public int publicInt = 1;
+ protected int protectedInt = 1;
+ int defaultInt = 1;
+ private int privateInt = 1;
+ public void publicMethod() { Util.signal(Util.defPublic); }
+ protected void protectedMethod() { Util.signal(Util.defProtected); }
+ void defaultMethod() { Util.signal(Util.defDefault); }
+ private void privateMethod() { Util.signal(Util.defPrivate); }
+
+ public static void readDefaultTarget() {
+ int i = 0;
+ i += DefaultTarget.publicStaticInt;
+ i += DefaultTarget.protectedStaticInt;
+ i += DefaultTarget.defaultStaticInt;
+ i += DefaultTarget.privateStaticInt;
+ DefaultTarget defaultTarget = new DefaultTarget();
+ i += defaultTarget.publicInt;
+ i += defaultTarget.protectedInt;
+ i += defaultTarget.defaultInt;
+ i += defaultTarget. privateInt;
+ defaultTarget.publicMethod();
+ defaultTarget.protectedMethod();
+ defaultTarget.defaultMethod();
+ defaultTarget.privateMethod();
+ }
+
+ class DefaultInner {
+ public static final int publicStaticDefaultInnerInt = 1;
+ protected static final int protectedStaticDefaultInnerInt = 1;
+ /* def */ static final int defaultStaticDefaultInnerInt = 1;
+ private static final int privateStaticDefaultInnerInt = 1;
+ public int publicDefaultInnerInt = 1;
+ protected int protectedDefaultInnerInt = 1;
+ /* default */ int defaultDefaultInnerInt = 1;
+ private int privateDefaultInnerInt = 1;
+ public void publicDefaultInnerMethod() { Util.signal(Util.defInnerPublic); }
+ protected void protectedDefaultInnerMethod() { Util.signal(Util.defInnerProtected); }
+ /* default */ void defaultDefaultInnerMethod() { Util.signal(Util.defInnerDefault); }
+ private void privateDefaultInnerMethod() { Util.signal(Util.defInnerPrivate); }
+
+ public void readDefaultInnerTarget() {
+ int i = 0;
+ i += DefaultTarget.DefaultInner.publicStaticDefaultInnerInt;
+ i += DefaultTarget.DefaultInner.protectedStaticDefaultInnerInt;
+ i += DefaultTarget.DefaultInner.defaultStaticDefaultInnerInt;
+ i += DefaultTarget.DefaultInner.privateStaticDefaultInnerInt;
+ DefaultTarget.DefaultInner defaultInnerTarget
+ = new DefaultTarget().new DefaultInner();
+ i += defaultInnerTarget.publicDefaultInnerInt;
+ i += defaultInnerTarget.protectedDefaultInnerInt;
+ i += defaultInnerTarget.defaultDefaultInnerInt;
+ i += defaultInnerTarget.privateDefaultInnerInt;
+ defaultInnerTarget.publicDefaultInnerMethod();
+ defaultInnerTarget.protectedDefaultInnerMethod();
+ defaultInnerTarget.defaultDefaultInnerMethod();
+ defaultInnerTarget.privateDefaultInnerMethod();
+ }
+ }
+}
diff --git a/tests/new/privilegedAspects/pack/PublicTarget.java b/tests/new/privilegedAspects/pack/PublicTarget.java
new file mode 100644
index 000000000..f32a5468a
--- /dev/null
+++ b/tests/new/privilegedAspects/pack/PublicTarget.java
@@ -0,0 +1,69 @@
+
+package pack;
+
+import util.Util;
+
+public class PublicTarget {
+ public static int publicStaticInt = 1;
+ protected static int protectedStaticInt = 1;
+ static int defaultStaticInt = 1;
+ private static int privateStaticInt = 1;
+ public int publicInt = 1;
+ protected int protectedInt = 1;
+ int defaultInt = 1;
+ private int privateInt = 1;
+ public void publicMethod() { Util.signal(Util.pubPublic); }
+ protected void protectedMethod() { Util.signal(Util.pubProtected); }
+ void defaultMethod() { Util.signal(Util.pubDefault); }
+ private void privateMethod() { Util.signal(Util.pubPrivate); }
+
+ public static void readPublicTarget() {
+ int i = 0;
+ i += PublicTarget.publicStaticInt;
+ i += PublicTarget.protectedStaticInt;
+ i += PublicTarget.defaultStaticInt;
+ i += PublicTarget.privateStaticInt;
+ PublicTarget publicTarget = new PublicTarget();
+ i += publicTarget.publicInt;
+ i += publicTarget.protectedInt;
+ i += publicTarget.defaultInt;
+ i += publicTarget. privateInt;
+ publicTarget.publicMethod();
+ publicTarget.protectedMethod();
+ publicTarget.defaultMethod();
+ publicTarget.privateMethod();
+ }
+
+ public class PublicInner {
+ public static final int publicStaticPublicInnerInt = 1;
+ protected static final int protectedStaticPublicInnerInt = 1;
+ /* def */ static final int defaultStaticPublicInnerInt = 1;
+ private static final int privateStaticPublicInnerInt = 1;
+ public int publicPublicInnerInt = 1;
+ protected int protectedPublicInnerInt = 1;
+ /* default */ int defaultPublicInnerInt = 1;
+ private int privatePublicInnerInt = 1;
+ public void publicPublicInnerMethod() { Util.signal(Util.pubInnerPublic); }
+ protected void protectedPublicInnerMethod() { Util.signal(Util.pubInnerProtected); }
+ /* default */ void defaultPublicInnerMethod() { Util.signal(Util.pubInnerDefault); }
+ private void privatePublicInnerMethod() { Util.signal(Util.pubInnerPrivate); }
+
+ public void readPublicInnerTarget() {
+ int i = 0;
+ i += PublicTarget.PublicInner.publicStaticPublicInnerInt;
+ i += PublicTarget.PublicInner.protectedStaticPublicInnerInt;
+ i += PublicTarget.PublicInner.defaultStaticPublicInnerInt;
+ i += PublicTarget.PublicInner.privateStaticPublicInnerInt;
+ PublicTarget.PublicInner publicInnerTarget
+ = new PublicTarget().new PublicInner();
+ i += publicInnerTarget.publicPublicInnerInt;
+ i += publicInnerTarget.protectedPublicInnerInt;
+ i += publicInnerTarget.defaultPublicInnerInt;
+ i += publicInnerTarget. privatePublicInnerInt;
+ publicInnerTarget.publicPublicInnerMethod();
+ publicInnerTarget.protectedPublicInnerMethod();
+ publicInnerTarget.defaultPublicInnerMethod();
+ publicInnerTarget.privatePublicInnerMethod();
+ }
+ }
+}
diff --git a/tests/new/privilegedAspects/util/Util.java b/tests/new/privilegedAspects/util/Util.java
new file mode 100644
index 000000000..7b9d70f22
--- /dev/null
+++ b/tests/new/privilegedAspects/util/Util.java
@@ -0,0 +1,35 @@
+
+package util;
+
+import org.aspectj.testing.Tester;
+import org.aspectj.testing.Tester;
+
+public class Util {
+ public static boolean PRINT = false;
+ public static final String pubPublic = "PublicTarget.publicPublicMethod";
+ public static final String pubProtected = "PublicTarget.protectedPublicMethod";
+ public static final String pubDefault = "PublicTarget.defaultPublicMethod";
+ public static final String pubPrivate = "PublicTarget.privatePublicMethod";
+ public static final String pubInnerPublic = "PublicTarget.publicPublicInnerMethod";
+ public static final String pubInnerProtected = "PublicTarget.protectedPublicInnerMethod";
+ public static final String pubInnerDefault = "PublicTarget.defaultPublicInnerMethod";
+ public static final String pubInnerPrivate = "PublicTarget.privatePublicInnerMethod";
+ public static final String defPublic = "DefaultTarget.publicDefaultMethod";
+ public static final String defProtected = "DefaultTarget.protectedDefaultMethod";
+ public static final String defDefault = "DefaultTarget.defaultDefaultMethod";
+ public static final String defPrivate = "DefaultTarget.privateDefaultMethod";
+ public static final String defInnerPublic = "DefaultTarget.publicDefaultInnerMethod";
+ public static final String defInnerProtected = "DefaultTarget.protectedDefaultInnerMethod";
+ public static final String defInnerDefault = "DefaultTarget.defaultDefaultInnerMethod";
+ public static final String defInnerPrivate = "DefaultTarget.privateDefaultInnerMethod";
+
+ /** signal some test event for later validation
+ * if PRINT, also outputs to System.err
+ */
+ public static void signal(String s) {
+ if (PRINT) {
+ System.err.println(" Util.signal: " + s);
+ }
+ Tester.event(s);
+ }
+}