aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-20 04:54:45 +0000
committerwisberg <wisberg>2002-12-20 04:54:45 +0000
commit8312dfbc60b4589559f6943973cec819d28c68d6 (patch)
treec923c4f05b3049e9f18ab63c4ca50c42d2199b6c /tests/bugs
parentbc0c559654cb471c8392ded0f25d12b527e1f115 (diff)
downloadaspectj-8312dfbc60b4589559f6943973cec819d28c68d6.tar.gz
aspectj-8312dfbc60b4589559f6943973cec819d28c68d6.zip
added test cases for old jitterbugs
moved passing tests from ajcTestsFailing to ajcTests
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/AfterStaticCall.java22
-rw-r--r--tests/bugs/CircularDominates.java29
-rw-r--r--tests/bugs/ExecutionCflow.java22
-rw-r--r--tests/bugs/IncompatibleClassChangeErrorBug.java38
-rw-r--r--tests/bugs/InstanceAsClassRefToConstant.java40
-rw-r--r--tests/bugs/PrivilegeBeyondScope.java26
6 files changed, 177 insertions, 0 deletions
diff --git a/tests/bugs/AfterStaticCall.java b/tests/bugs/AfterStaticCall.java
new file mode 100644
index 000000000..fc3a5b76a
--- /dev/null
+++ b/tests/bugs/AfterStaticCall.java
@@ -0,0 +1,22 @@
+
+import org.aspectj.testing.Tester;
+
+/** @testcase PR#900 after advice on static call jp */
+public class AfterStaticCall {
+ public static void main(String[] args) {
+ Tester.expectEvent("foo()");
+ Tester.expectEvent("after() : call(void Test.foo())");
+ foo();
+ Tester.checkAllEvents();
+ }
+
+ public static void foo() {
+ Tester.event("foo()");
+ }
+}
+
+aspect LogFooCall {
+ after() : call(static void foo()) {
+ Tester.event("after() : call(void Test.foo())");
+ }
+} \ No newline at end of file
diff --git a/tests/bugs/CircularDominates.java b/tests/bugs/CircularDominates.java
new file mode 100644
index 000000000..b35423e8b
--- /dev/null
+++ b/tests/bugs/CircularDominates.java
@@ -0,0 +1,29 @@
+
+import org.aspectj.testing.Tester;
+import java.util.*;
+
+/** @testcase PR#902 circularity in declare dominates */
+public class CircularDominates {
+
+ public static void main(String[] args) {
+ foo();
+ throw new Error("expected compiler error");
+ }
+
+ public static void foo() {
+ }
+}
+
+aspect BugDemoAspect {
+ declare dominates : B, A, B; // CE 18
+}
+
+aspect A {
+ before() : target(CircularDominates) && call(static void foo(..)) {
+ }
+}
+
+aspect B {
+ before() : cflowbelow(execution(static void main(String[]))) {
+ }
+}
diff --git a/tests/bugs/ExecutionCflow.java b/tests/bugs/ExecutionCflow.java
new file mode 100644
index 000000000..ac72b44a4
--- /dev/null
+++ b/tests/bugs/ExecutionCflow.java
@@ -0,0 +1,22 @@
+
+import org.aspectj.testing.Tester;
+import java.util.*;
+
+/** @testcase PR#903 cflow of execution */
+public class ExecutionCflow {
+
+ static int field;
+
+ public static void main(String[] args) {
+ field = 0;
+ Tester.expectEvent("before");
+ Tester.checkAllEvents();
+ }
+}
+
+aspect A {
+ before() : cflow(execution(static void main(String[])))
+ && set(int field) {
+ Tester.event("before");
+ }
+}
diff --git a/tests/bugs/IncompatibleClassChangeErrorBug.java b/tests/bugs/IncompatibleClassChangeErrorBug.java
new file mode 100644
index 000000000..3bb968703
--- /dev/null
+++ b/tests/bugs/IncompatibleClassChangeErrorBug.java
@@ -0,0 +1,38 @@
+
+import org.aspectj.testing.Tester;
+import org.aspectj.lang.*;
+import org.aspectj.lang.reflect.*;
+
+/** @testcase PR#901 IncompatibleClassChangeError bug */
+public class IncompatibleClassChangeErrorBug {
+
+ public static void main(String[] args) {
+ Tester.expectEvent("printed");
+ method1();
+ Tester.checkAllEvents();
+ }
+ public static void method1() {
+ }
+}
+
+aspect JoinpointTestAspect {
+ before() : call(static void method1()) {
+ printArgs(thisJoinPoint);
+
+ // This call is required to reproduce the bug...
+ printStaticInfo(thisJoinPointStaticPart);
+ }
+
+
+ private void printArgs(JoinPoint joinPoint) {
+ Object[] args = joinPoint.getArgs();
+ // While the original code had a for() loop to print arguments
+ // bug can be seen without it...
+ }
+
+ private void printStaticInfo(JoinPoint.StaticPart
+ joinPointStaticPart) {
+ Tester.check(null != joinPointStaticPart, "null parm");
+ Tester.event("printed");
+ }
+}
diff --git a/tests/bugs/InstanceAsClassRefToConstant.java b/tests/bugs/InstanceAsClassRefToConstant.java
new file mode 100644
index 000000000..6e615ae97
--- /dev/null
+++ b/tests/bugs/InstanceAsClassRefToConstant.java
@@ -0,0 +1,40 @@
+
+import org.aspectj.testing.Tester;
+import java.util.*;
+
+/** @testcase PR#909 instance as class reference to constant */
+public class InstanceAsClassRefToConstant {
+ public static void main(String[] args) {
+ throw new Error("XXX not set up to run");
+ }
+}
+
+abstract class CWithLongConst {
+ public static final long MAX = 1000000;
+}
+
+class A extends CWithLongConst {
+}
+
+class TestCase {
+ public final static void main(String[] argv) {
+ A aL = new A();
+
+ // bad error
+ // a) Sanity check:
+ // stack size is -1 after stmt BreakStmt(label: null) (warning)
+ for (long l=0; l<2000000; l+=100000) {
+ if (l > aL.MAX) {
+ break;
+ }
+ }
+
+ // b) Sanity check: stack size is -1 after stmt ExprStmt() (warning)
+ String[] stringsL = null;
+ for (long k=0; (k<2000000) && (stringsL == null); k+=100000) {
+ if (k > aL.MAX) {
+ stringsL = new String[1];
+ }
+ }
+ }
+}
diff --git a/tests/bugs/PrivilegeBeyondScope.java b/tests/bugs/PrivilegeBeyondScope.java
new file mode 100644
index 000000000..77b706b15
--- /dev/null
+++ b/tests/bugs/PrivilegeBeyondScope.java
@@ -0,0 +1,26 @@
+
+import java.util.Observable;
+
+
+/** @testcase PR#906 privileged access out of code the compiler controls */
+public class PrivilegeBeyondScope {
+
+ public static void main (String[] args) {
+ new C().get();
+ throw new Error("expected compiler error");
+ }
+}
+
+class C {
+ Object get() {return null;}
+}
+
+privileged aspect A {
+ Observable observable = new Observable();
+
+ after() returning (Object o ) :
+ execution(Object C.get()) {
+ observable.setChanged(); // CE 22 (unable to implement privilege outside C
+ // CE unable to implement privilege outside code the compiler controls
+ }
+}