aboutsummaryrefslogtreecommitdiffstats
path: root/tests/errors/protectedAccess
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/errors/protectedAccess
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/errors/protectedAccess')
-rw-r--r--tests/errors/protectedAccess/Main.java62
-rw-r--r--tests/errors/protectedAccess/p1/C1.java17
2 files changed, 79 insertions, 0 deletions
diff --git a/tests/errors/protectedAccess/Main.java b/tests/errors/protectedAccess/Main.java
new file mode 100644
index 000000000..39ba8307c
--- /dev/null
+++ b/tests/errors/protectedAccess/Main.java
@@ -0,0 +1,62 @@
+package protectedAccess;
+
+import org.aspectj.testing.Tester;
+import protectedAccess.p1.C1;
+
+public class Main {
+ public static void main(String[] args) {
+ SubC1 subc1 = new SubC1();
+ subc1.m(subc1, subc1);
+ }
+}
+
+class SubC1 extends C1 {
+ public void m(SubC1 subc1, C1 c1) {
+ Tester.checkEqual(this.s, "protected");
+ Tester.checkEqual(this.m(), "protected");
+
+ Tester.checkEqual(s, "protected");
+ Tester.checkEqual(m(), "protected");
+
+ Tester.checkEqual(subc1.s, "protected");
+ Tester.checkEqual(subc1.m(), "protected");
+
+ C1 c1a = new C1() { };
+
+ C1 c1b = new C1(); //ERROR: illegal protected access
+
+ Tester.checkEqual(c1.s, "protected"); //ERROR: illegal protected access
+ Tester.checkEqual(c1.m(), "protected"); //ERROR: illegal protected access
+
+ Tester.checkEqual(c1.m(), "protected"); //ERROR: illegal protected access
+ }
+
+ class SubI1 extends I1 {
+ public void m(SubC1 subc1, C1 c1, I1 i1) {
+ Tester.checkEqual(s, "protected");
+ Tester.checkEqual(m(), "protected"); //ERROR: method not found
+
+ Tester.checkEqual(SubC1.this.s, "protected");
+ Tester.checkEqual(SubC1.this.m(), "protected");
+
+ Tester.checkEqual(subc1.s, "protected");
+ Tester.checkEqual(subc1.m(), "protected");
+
+ Tester.checkEqual(c1.s, "protected"); //ERROR: illegal protected access
+ Tester.checkEqual(c1.m(), "protected"); //ERROR: illegal protected access
+
+ Tester.checkEqual(si, "ip");
+ Tester.checkEqual(mi(), "ip");
+
+ Tester.checkEqual(this.si, "ip");
+ Tester.checkEqual(this.mi(), "ip");
+
+ Tester.checkEqual(i1.si, "ip"); //ERROR: illegal protected access
+ Tester.checkEqual(i1.mi(), "ip"); //ERROR: illegal protected access
+ }
+ }
+
+ protected String mString(Object o) {
+ return o.toString();
+ }
+}
diff --git a/tests/errors/protectedAccess/p1/C1.java b/tests/errors/protectedAccess/p1/C1.java
new file mode 100644
index 000000000..976c8e7c6
--- /dev/null
+++ b/tests/errors/protectedAccess/p1/C1.java
@@ -0,0 +1,17 @@
+package protectedAccess.p1;
+
+
+public class C1 {
+ protected C1() { }
+
+ protected String s = "protected";
+
+ protected String m() { return "protected"; }
+
+ protected String mString(String s) { return s; }
+
+ protected static class I1 {
+ protected String si = "ip";
+ protected String mi() { return "ip"; }
+ }
+}