diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/RestrictingVisibilityCF.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/RestrictingVisibilityCF.java')
-rw-r--r-- | tests/new/RestrictingVisibilityCF.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/new/RestrictingVisibilityCF.java b/tests/new/RestrictingVisibilityCF.java new file mode 100644 index 000000000..429590e48 --- /dev/null +++ b/tests/new/RestrictingVisibilityCF.java @@ -0,0 +1,62 @@ +import org.aspectj.testing.Tester; + +/** @testcase PR#536 expecting compile failures with subclass narrowing scope of superclass methods or accessing private superclass variables */ +public class RestrictingVisibilityCF { + public static void main(String[] args) { + Tester.check(false, "compile should fail"); + } +} + +class Parent { + public int publicAccess; + protected int protectedAccess; + int defaultAccess; + private int privateAccess; + + public void publicAccess() {} + protected void protectedAccess() {} + void defaultAccess() {} + private void privateAccess() {} + void drivePrivateAccess() { + privateAccess(); + } +} + +class InValidChild extends Parent { + /** @testcase subclass private implementation of public method */ + private void publicAccess() { } // errLine 27 + /** @testcase subclass private implementation of method with default access */ + private void defaultAccess() { } // errLine 29 + /** @testcase subclass private implementation of protected method */ + private void protectedAccess() { } // errLine 31 + + // todo: sep package, attempt package acces + int defaultAccessSub = defaultAccess; +} + +class InValidChild2 extends Parent { + /** @testcase subclass private implementation of method with default access */ + private void defaultAccess() { } // errLine 39 + /** @testcase subclass protected implementation of public method */ + protected void publicAccess() { } // errLine 41 +} + +class InValidChild3 extends Parent { + /** @testcase subclass default implementation of method with protected access */ + void protectedAccess() { } // errLine 46 + /** @testcase subclass default implementation of public method */ + void publicAccess() { } // errLine 48 +} + +class InValidChild4 extends Parent { + /** @testcase private access members unavailable in subclass */ + private int foo = new Parent().privateAccess; // errLine 53 +} + +// /** todo: separate package test */ +// class Invalid { +// /** @testcase default access members unavailable from separate package */ +// private int bar = new Parent().defaultAccess; +// /** @testcase protected access members unavailable from separate package */ +// private int foo = new Parent().protectedAccess; +// } |