diff options
author | wisberg <wisberg> | 2002-12-20 04:54:45 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-20 04:54:45 +0000 |
commit | 8312dfbc60b4589559f6943973cec819d28c68d6 (patch) | |
tree | c923c4f05b3049e9f18ab63c4ca50c42d2199b6c | |
parent | bc0c559654cb471c8392ded0f25d12b527e1f115 (diff) | |
download | aspectj-8312dfbc60b4589559f6943973cec819d28c68d6.tar.gz aspectj-8312dfbc60b4589559f6943973cec819d28c68d6.zip |
added test cases for old jitterbugs
moved passing tests from ajcTestsFailing to ajcTests
-rw-r--r-- | tests/ajcTests.xml | 50 | ||||
-rw-r--r-- | tests/ajcTestsFailing.xml | 77 | ||||
-rw-r--r-- | tests/bugs/AfterStaticCall.java | 22 | ||||
-rw-r--r-- | tests/bugs/CircularDominates.java | 29 | ||||
-rw-r--r-- | tests/bugs/ExecutionCflow.java | 22 | ||||
-rw-r--r-- | tests/bugs/IncompatibleClassChangeErrorBug.java | 38 | ||||
-rw-r--r-- | tests/bugs/InstanceAsClassRefToConstant.java | 40 | ||||
-rw-r--r-- | tests/bugs/PrivilegeBeyondScope.java | 26 |
8 files changed, 233 insertions, 71 deletions
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 501543aaf..129a3b6d0 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -4234,8 +4234,7 @@ <ajc-test dir="new" pr="694" title="after returning advice param" keywords="from-resolved_10x"> - <compile files="AfterReturningParam.java"> - </compile> + <compile files="AfterReturningParam.java"/> <run class="AfterReturningParam"/> </ajc-test> @@ -4331,16 +4330,14 @@ <ajc-test dir="new" pr="573" title="pertarget stack overflow getting name of anonymous (Interface) class" keywords="from-resolved_10rc3"> - <compile files="PR573.java"> - </compile> + <compile files="PR573.java"/> <run class="PR573"/> </ajc-test> <ajc-test dir="new" pr="573" title="pertarget stack overflow getting name of anonymous (Object) class" keywords="from-resolved_10rc3"> - <compile files="PR573_1.java"> - </compile> + <compile files="PR573_1.java"/> <run class="PR573_1"/> </ajc-test> @@ -5105,6 +5102,20 @@ <run class="AssertInAdviceBug" vm="1.4"/> </ajc-test> + <ajc-test dir="new" pr="823" + title="declaring a private method on an inner interface" + keywords="tofix"> + <compile files="PrivateMethodOnInnerInterface.java"/> + <run class="PrivateMethodOnInnerInterface"/> + </ajc-test> + + <ajc-test dir="new" pr="829" + title="CE expected when declaring fields on arrays" keywords="tofix"> + <compile files="ArrayFieldDeclarationCE.java"> + <message kind="error" line="14"/> + </compile> + </ajc-test> + <ajc-test dir="pureJava" pr="866" title="non-constant static final fields marked as final in .class"> <compile files="FinalStaticField.java"/> @@ -5136,6 +5147,31 @@ <run class="AfterReturningInterfaceConstructor"/> </ajc-test> + <ajc-test dir="bugs" pr="900" + title="after advice on static call join point"> + <compile files="AfterStaticCall.java"/> + <run class="AfterStaticCall"/> + </ajc-test> + + <ajc-test dir="bugs" pr="901" + title="incompatible class change error" + comment="XXX Jim and Erik found/fixed this - need basis"> + <compile files="IncompatibleClassChangeErrorBug.java"/> + <run class="IncompatibleClassChangeErrorBug"/> + </ajc-test> + + <ajc-test dir="bugs" pr="903" + title="simple cflow of method execution"> + <compile files="ExecutionCflow.java"/> + <run class="ExecutionCflow"/> + </ajc-test> + + <ajc-test dir="bugs" pr="909" + title="using instance as class reference to constant field" + comment="XXX need to verify run"> + <compile files="InstanceAsClassRefToConstant.java"/> + </ajc-test> + <!-- .................................... option tests --> <!-- .................................... -warn tests --> <ajc-test dir="options" @@ -5249,7 +5285,7 @@ <compile files="Main.java,injar.jar,Aspect.java" aspectpath="aspectlib1.jar,aspectlib2.jar"/> <!-- can't run until we support classpath including the above jars - <run class="Main"/> + <run class="Main"/> --> </ajc-test> diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml index 01bf6505a..9a1410de4 100644 --- a/tests/ajcTestsFailing.xml +++ b/tests/ajcTestsFailing.xml @@ -1,7 +1,6 @@ <!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"> - <suite> <ajc-test dir="new" pr="774" title="interface self-reference in anonymous instance (correct test in knownbugs)" @@ -21,14 +20,6 @@ </compile> </ajc-test> - <ajc-test dir="ng" - title="parenthesized type name as qualifying expr is illegal (in j2sdk1.4.1beta)" - keywords="tofix"> - <compile files="Parens1.java"> - <message kind="error" line="3"/> - </compile> - </ajc-test> - <ajc-test dir="new" title="expect CE for unterminated declare error" keywords="tofix"> <compile files="UnterminatedDeclareErrorCE.java"> @@ -50,14 +41,6 @@ <compile files="DominatesTypePattern.java"/> <run class="DominatesTypePattern"/> </ajc-test> - - <ajc-test dir="ng" - title="long-standing bug in javac and ajc about non-verifiable try stmt" - keywords="tofix"> - <compile files="TryVerification.java"/> - <run class="TryVerification"/> - </ajc-test> - <ajc-test dir="new" title="unmatched type name in a declare parents should result in a warning in -Xlint mode" keywords="tofix"> @@ -88,20 +71,6 @@ <run class="AfterThrowingNonThrowable"/> </ajc-test> - <ajc-test dir="new" pr="823" - title="declaring a private method on an inner interface" - keywords="tofix"> - <compile files="PrivateMethodOnInnerInterface.java"/> - <run class="PrivateMethodOnInnerInterface"/> - </ajc-test> - - <ajc-test dir="new" pr="829" - title="CE expected when declaring fields on arrays" keywords="tofix"> - <compile files="ArrayFieldDeclarationCE.java"> - <message kind="error" line="14"/> - </compile> - </ajc-test> - <ajc-test dir="new" pr="829" title="declare array field using postfix" keywords="tofix"> <compile files="ArrayFieldDeclaration.java"/> @@ -173,47 +142,27 @@ </compile> <run class="pack.ImportInnerFromInterfaceImplementor"/> </ajc-test> - - <ajc-test dir="ng" - title="wrong scope for inner class creation expression"> - <compile files="InnerClassCreate.java"/> - <run class="InnerClassCreate"/> - </ajc-test> - - <ajc-test dir="ng" - title="definite unassignment versus try-finally"> - <compile files="DefiniteUnassignmentTry.java"/> - <run class="DefiniteUnassignmentTry"/> - </ajc-test> - <ajc-test dir="ng" - title="definite assignment with constant subexpression in control-flow ops"> - <compile files="DefiniteAssignmentControlFlow.java"> - <dir-changes added="DefiniteAssignmentControlFlow"/> + <ajc-test dir="new" + title="if and cflow arg binding"> + <compile files="CflowBinding.java"> + <message kind="error" line="13"/> </compile> - <run class="DefiniteAssignmentControlFlow"/> </ajc-test> - <ajc-test dir="ng" - title="conversion from null"> - <compile files="ConvertFromNull.java"> - <message kind="error" line="8"/> + <ajc-test dir="bugs" pr="902" + title="circularity in declare dominates"> + <compile files="CircularDominates.java"> + <message kind="error" line="18"/> </compile> </ajc-test> - <ajc-test dir="ng" - title="conflicting throws on inherited abstract methods"> - <compile files="ConflictingThrows.java"/> - <run class="ConflictingThrows"/> - </ajc-test> - - <ajc-test dir="new" - title="if and cflow arg binding"> - <compile files="CflowBinding.java"> - <message kind="error" line="13"/> + <ajc-test dir="bugs" pr="906" + title="privileged access to code outside the control of the compiler"> + <compile files="PrivilegeBeyondScope.java"> + <message kind="error" line="21"/> </compile> + <run class="PrivilegeBeyondScope"/> </ajc-test> - - </suite> 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 + } +} |