diff options
Diffstat (limited to 'tests')
23 files changed, 246 insertions, 90 deletions
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index 4df86dcec..a7e0c270c 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -30,6 +30,9 @@ knownLimitation-ajdeCompiler Accepted limitation of the AJDE CompileCommand wrapper + poorErrorMessages test case passes but errors produced by compiler could do with + improvement + Test titles: Titles should be unique and not change, and related tests should have the @@ -1088,7 +1091,7 @@ </ajc-test> <ajc-test dir="new" title="Error expected for constructor in interfaces" - keywords="from-java"> + keywords="from-java,purejava"> <compile files="InterfaceConstructor.java"> <message kind="error" line="2"/> <message kind="error" line="6"/> @@ -1572,7 +1575,6 @@ keywords="from-errors"> <compile files="MismatchedParens.java"> <message kind="error" line="16"/> - <message kind="error" line="17"/> </compile> </ajc-test> @@ -1585,7 +1587,7 @@ <ajc-test dir="errors" pr="218" title="import statement within class body crashes compiler" - keywords="from-errors"> + keywords="from-errors,purejava"> <compile files="ImportWithinClassBody.java"> <message kind="error" line="8"/> </compile> @@ -1594,8 +1596,7 @@ <ajc-test dir="errors" pr="219" title="extra closing brace" keywords="from-errors"> <compile files="ExtraClosingBrace.java"> - <message kind="error" line="9"/> - <message kind="error" line="10"/> + <message kind="error" line="8"/> </compile> </ajc-test> @@ -1642,7 +1643,7 @@ <ajc-test dir="errors" pr="280" title="wildcard used for returns clause" keywords="from-errors"> <compile files="WildcardForReturns.java"> - <message kind="error" line="17"/> + <message kind="error" line="17"/> </compile> </ajc-test> @@ -1776,7 +1777,7 @@ title="pre 0.7 introduction form outside aspect body causes an EmptyStackException" keywords="from-errors"> <compile files="BadIntroduction.java"> - <message kind="error" line="10"/> + <message kind="error" line="3"/> </compile> </ajc-test> @@ -1791,7 +1792,7 @@ title="a before() clause at the class-level causes an EmptyStackException" keywords="from-errors"> <compile files="TopLevelBefore.java"> - <message kind="error" line="9"/> + <message kind="error" line="3"/> </compile> </ajc-test> @@ -1799,7 +1800,7 @@ title="an after() clause at the class-level causes an EmptyStackException" keywords="from-errors"> <compile files="TopLevelAfter.java"> - <message kind="error" line="9"/> + <message kind="error" line="3"/> </compile> </ajc-test> @@ -1807,7 +1808,7 @@ title="an around() clause at the class-level causes an EmptyStackException" keywords="from-errors"> <compile files="TopLevelAround.java"> - <message kind="error" line="9"/> + <message kind="error" line="3"/> </compile> </ajc-test> @@ -2288,11 +2289,14 @@ <ajc-test dir="new" pr="457" title="Compiler should suggest using aspect when advice, pointcuts, or introduction is in a class" - keywords="from-errors"> + keywords="from-errors,poorErrorMessages"> <compile files="RecognizeAspectCE.java"> + <message kind="error" line="3" + file="RecognizeAspectCE.java" + text="Syntax error"/> <message kind="error" line="6" file="RecognizeAspectCE.java" - text="Syntax error on token"/> + text="Syntax error"/> </compile> </ajc-test> @@ -3115,7 +3119,8 @@ <run class="NewAnonymous"/> </ajc-test> - <ajc-test dir="new" title="Cannot bind a name." keywords="from-resolved_10x"> + <ajc-test dir="new" + title="Cannot bind a name." keywords="from-resolved_10x,purejava"> <compile files="CannotReferenceSuper.java"/> <run class="CannotReferenceSuper"/> </ajc-test> @@ -3298,10 +3303,17 @@ <ajc-test dir="new" title="around advice on calls within inner classes (including protected method calls)" keywords="from-resolved_10x"> - <compile files="AroundInnerCalls.java"/> - <run class="AroundInnerCalls"/> + <compile files="AroundInnerCalls13.java" options="-1.3"/> + <run class="AroundInnerCalls13"/> </ajc-test> + <ajc-test dir="new" + title="around advice on calls within inner classes (including protected method calls)" + keywords="from-resolved_10x"> + <compile files="AroundInnerCalls.java" options="-1.4"/> + <run class="AroundInnerCalls"/> + </ajc-test> + <ajc-test dir="new" title="Arguments to runNext should be final when needed" keywords="from-resolved_10x"> <compile files="Finals.java"/> @@ -3380,13 +3392,13 @@ <run class="EmptyStack"/> </ajc-test> - <ajc-test dir="new" - title="check that MightHaveAspect interface is created correctly for an aspect in deep package" - keywords="from-resolved_10x"> - <compile files="EachObjectTarget.java,EachObjectInDeepPackage.java"/> - <run class="EachObjectTarget"/> - </ajc-test> - + <ajc-test dir="new/perThis" + title="check that MightHaveAspect interface is created correctly for an aspect in deep package" + keywords="from-resolved_10x"> + <compile files="p/EachObjectTarget.java,the/deep/pkg/EachObjectInDeepPackage.java"/> + <run class="p.EachObjectTarget"/> + </ajc-test> + <ajc-test dir="new" title="Defines clfow$ajc0 more once. [eachcflow]" keywords="from-resolved_10x"> <compile files="Binkley.java"/> @@ -4433,7 +4445,7 @@ <ajc-test dir="new" title="changing this in around's proceed reported by Rich Price" keywords="from-resolved_104"> - <compile files="AroundChangeThis.java"/> + <compile files="AroundChangeThis.java" options="-1.4"/> <run class="AroundChangeThis"/> </ajc-test> @@ -5213,17 +5225,17 @@ <!-- .................................... option tests --> <!-- .................................... -warn tests --> - <ajc-test dir="options" + <ajc-test dir="options/deprecated" title="options -warn:deprecation"> - <compile files="WarnDeprecated.java" + <compile files="WarnDeprecated.java,OldStuff.java" options="!eclipse,-warn:deprecation"> <message kind="warning" line="10"/> </compile> </ajc-test> - <ajc-test dir="options" + <ajc-test dir="options/deprecated" title="options -warn:deprecation not enabled"> - <compile files="WarnDeprecated.java" + <compile files="WarnDeprecated.java,OldStuff.java" options="!eclipse"> </compile> </ajc-test> @@ -5350,7 +5362,7 @@ <ajc-test dir="new" title="expect CE for unterminated declare error"> <compile files="UnterminatedDeclareErrorCE.java"> - <message kind="error" line="5"/> + <message kind="error" line="4"/> </compile> </ajc-test> @@ -6777,13 +6789,18 @@ </ajc-test> <ajc-test dir="bugs/concretizeNpe" pr="43033" - title="NPE in concretization error path"> + title="NPE in concretization error path" + keywords="poorErrorMessages"> <compile files="base/ExceptionHandling.java,model/ModelExceptionHandling.java"> + <!-- <message line="5" kind="error" text="pointcut base.ExceptionHandling.scope() is abstract"/> <message line="4" kind="error" text="inherited abstract pointcut base.ExceptionHandling.scope() is not made concrete"/> <message line="8" kind="error" text="inherited abstract pointcut base.ExceptionHandling.scope() is not made concrete"/> - <message line="12" kind="error" text="Unmatched bracket"/> - <message line="13" kind="error" text="Syntax error on token"/> + <message line="12" kind="error" /> + <message line="13" kind="error" /> + --> + <message line="12" kind="error" /> + <message line="13" kind="error" /> </compile> </ajc-test> @@ -6862,7 +6879,8 @@ pr="41952" > <compile - files="DeclaringTypeWarning.java" > + files="DeclaringTypeWarning.java" + options="-1.3" > <message kind="warning" line="6" text="declaring type"> <source line="12" file="DeclaringTypeWarning.java" /> </message> @@ -6872,16 +6890,27 @@ </compile> </ajc-test> + <ajc-test dir="bugs" + title="XLint warning for call PCD's using subtype of defining type (-1.3 -Xlint:ignore)" + pr="41952" + > + <compile + options="-Xlint:ignore,-1.3" + files="DeclaringTypeWarning.java" > + </compile> + </ajc-test> + <ajc-test dir="bugs" - title="XLint warning for call PCD's using subtype of defining type (-Xlint:ignore)" + title="XLint warning for call PCD's using subtype of defining type (-1.4 -Xlint:ignore)" pr="41952" > <compile - options="-Xlint:ignore" + options="-Xlint:ignore,-1.4" files="DeclaringTypeWarning.java" > + <message kind="warning" line="12"/> </compile> </ajc-test> - + <ajc-test dir="bugs" title="XLint warning for call PCD's using subtype of defining type (-1.4)" pr="41952" @@ -6920,4 +6949,19 @@ <compile files="TestSoftening.java"> </compile> </ajc-test> + + <ajc-test dir="bugs" pr="45663" + title="Bad parser error recovery in advice"> + <compile files="ParserRecoveryTest.java"> + <message kind="error" line="7"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs" pr="45663" + title="Bad parser error recovery in java source"> + <compile files="ParserRecoveryTestPureJava.java"> + <message kind="error" line="6"/> + <message kind="error" line="8"/> + </compile> + </ajc-test> </suite> diff --git a/tests/bugs/ParserRecoveryTest.java b/tests/bugs/ParserRecoveryTest.java new file mode 100644 index 000000000..0969b3ea1 --- /dev/null +++ b/tests/bugs/ParserRecoveryTest.java @@ -0,0 +1,8 @@ +// pr 45663 +aspect ParserRecoveryTest1 +{ + pointcut s(int x): + execution(* fred(x)); + + after(int xxx x x x x): this(*) {} +}
\ No newline at end of file diff --git a/tests/bugs/ParserRecoveryTestPureJava.java b/tests/bugs/ParserRecoveryTestPureJava.java new file mode 100644 index 000000000..811d1fb55 --- /dev/null +++ b/tests/bugs/ParserRecoveryTestPureJava.java @@ -0,0 +1,9 @@ +// pr 45663 +abstract class ParserRecoveryTestPureJava +{ + abstract int s(int x); + + void after(int xxx x x x x) {} + + void m() { return 2;} +}
\ No newline at end of file diff --git a/tests/errors/BadIntroduction.java b/tests/errors/BadIntroduction.java index b4bdf5740..7939f702d 100644 --- a/tests/errors/BadIntroduction.java +++ b/tests/errors/BadIntroduction.java @@ -1,5 +1,7 @@ import org.aspectj.testing.Tester; +introduction (String) {} + public class BadIntroduction { public static void main(String[] args) { String s; @@ -7,5 +9,4 @@ public class BadIntroduction { } } -introduction (String) { -} + diff --git a/tests/errors/BadIntroductionDesignator.java b/tests/errors/BadIntroductionDesignator.java index 9b97d4aae..ecd8fba57 100644 --- a/tests/errors/BadIntroductionDesignator.java +++ b/tests/errors/BadIntroductionDesignator.java @@ -2,10 +2,8 @@ package errors; // PR#129 -public class BadIntroductionDesignator { - introduction (M||) { - public boolean m_foo; - } +public aspect BadIntroductionDesignator { + public boolean (M||).m_foo; } class M {} diff --git a/tests/errors/ExtraClosingBrace.java b/tests/errors/ExtraClosingBrace.java index 0a46739af..c0991be40 100644 --- a/tests/errors/ExtraClosingBrace.java +++ b/tests/errors/ExtraClosingBrace.java @@ -5,6 +5,4 @@ package errors; public aspect ExtraClosingBrace { public void doIt() { - }} -} -} + }}}} diff --git a/tests/errors/NoAspect.java b/tests/errors/NoAspect.java index c735fd27a..14099bd6a 100644 --- a/tests/errors/NoAspect.java +++ b/tests/errors/NoAspect.java @@ -7,8 +7,7 @@ public class NoAspect { } } -class A { - static pointcut p(): target(*) && call(* go(..)); - before(): p() { - } + +class A +{ before(): target(*) && call(* go(..)) {} } diff --git a/tests/errors/NoSource.java b/tests/errors/NoSource.java index 31549fd77..6a7c52281 100644 --- a/tests/errors/NoSource.java +++ b/tests/errors/NoSource.java @@ -1,7 +1,5 @@ import org.aspectj.testing.Tester; class NoSource { - introduction String { - public void foo() {} - } + public void String.foo() {} } diff --git a/tests/errors/TopLevelAfter.java b/tests/errors/TopLevelAfter.java index 7db612660..b8186446a 100644 --- a/tests/errors/TopLevelAfter.java +++ b/tests/errors/TopLevelAfter.java @@ -1,9 +1,10 @@ import org.aspectj.testing.Tester; +after(): call(void main(..)) {} // CE 3 + public class TopLevelAfter { public static void main(String[] args) { Tester.check(false, "should not have compiled"); } } -after(): {} diff --git a/tests/errors/TopLevelAround.java b/tests/errors/TopLevelAround.java index 52beae80e..89e99cfd2 100644 --- a/tests/errors/TopLevelAround.java +++ b/tests/errors/TopLevelAround.java @@ -1,9 +1,10 @@ import org.aspectj.testing.Tester; -public class TopLevelAround { +void around(): call(void main(..)) {} // CE 3 + +public aspect TopLevelAround { public static void main(String[] args) { Tester.check(false, "should not have compiled"); } } -around(): {} // CE 9 diff --git a/tests/errors/TopLevelBefore.java b/tests/errors/TopLevelBefore.java index 4341e6941..8fdca0a0c 100644 --- a/tests/errors/TopLevelBefore.java +++ b/tests/errors/TopLevelBefore.java @@ -1,9 +1,9 @@ import org.aspectj.testing.Tester; +before(): call(void main(..)) {} // CE 3 + public class TopLevelBefore { public static void main(String[] args) { Tester.check(false, "should not have compiled"); } } - -before(): {} diff --git a/tests/errors/WildcardForReturns.java b/tests/errors/WildcardForReturns.java index e330b474f..2235c3cbc 100644 --- a/tests/errors/WildcardForReturns.java +++ b/tests/errors/WildcardForReturns.java @@ -11,11 +11,10 @@ public class WildcardForReturns { new WildcardForReturns().m(); } - public void m() { } - - static aspect A { - * around (WildcardForReturns t): this(t) && call(* m()) { // CE 17 - // bad test - return null; //return proceed(t); - } - } + public void m() { } +} +aspect A { + * around (WildcardForReturns t): this(t) && call(* m()) { // CE 17 + // bad test - return null; //return proceed(t); + } } diff --git a/tests/new/AroundChangeThis.java b/tests/new/AroundChangeThis.java index bf96cdd9b..826e95b52 100644 --- a/tests/new/AroundChangeThis.java +++ b/tests/new/AroundChangeThis.java @@ -12,15 +12,23 @@ public class AroundChangeThis { c1.m(sc); Tester.checkAndClearEvents(new String[] { "c1.m(sc)", "sc.m(c1)" }); - sc.m(c1); - Tester.checkAndClearEvents(new String[] { "sc.m(c1)", "c1.m(sc)" }); - +// this is the 1.3 behaviour +// sc.m(c1); +// Tester.checkAndClearEvents(new String[] { "sc.m(c1)", "c1.m(sc)" }); + + try { + // the 1.4 behaviour is.... + // in byte code we have a call to SubC.m + sc.m(c1); + Tester.checkFailed("Expected ClassCastException"); + } catch (ClassCastException e) { + } + try { sc.m1(c1); + Tester.checkFailed("Expected ClassCastException"); } catch (ClassCastException e) { - Tester.event("ClassCastException"); } - Tester.checkAndClearEvents(new String[] { "ClassCastException" }); Tester.printEvents(); } diff --git a/tests/new/AroundInnerCalls.java b/tests/new/AroundInnerCalls.java index 6cdd966a1..64a55caf8 100644 --- a/tests/new/AroundInnerCalls.java +++ b/tests/new/AroundInnerCalls.java @@ -6,11 +6,11 @@ public class AroundInnerCalls { Tester.check("Outer.foo() calls Outer.Inner.mi()"); Tester.check("Outer.foo() calls Outer.InnerRandom.nextHook(..)"); - Tester.check("Outer.InnerRandom.nextHook(..) calls Random.next(..)"); + Tester.check("Outer.InnerRandom.nextHook(..) calls Outer.InnerRandom.next(..)"); Tester.check("Outer.Inner.mi() calls PrintStream.println(..)"); Tester.check("X.toString()"); - Tester.check("Outer.foo() calls Random.nextInt(..)"); + Tester.check("Outer.foo() calls Outer.1.nextInt(..)"); } } @@ -37,7 +37,7 @@ class Outer { aspect A { Object around(): call(* *(..)) && !within(A) { - //System.out.println +// System.out.println Tester.note (thisEnclosingJoinPointStaticPart.getSignature().toShortString() + " calls " + thisJoinPointStaticPart.getSignature().toShortString()); diff --git a/tests/new/AroundInnerCalls13.java b/tests/new/AroundInnerCalls13.java new file mode 100644 index 000000000..0903eae27 --- /dev/null +++ b/tests/new/AroundInnerCalls13.java @@ -0,0 +1,56 @@ +import org.aspectj.testing.Tester; + +public class AroundInnerCalls13 { + public static void main(String[] args) { + new Outer().foo(); + + Tester.check("Outer.foo() calls Outer.Inner.mi()"); + Tester.check("Outer.foo() calls Outer.InnerRandom.nextHook(..)"); + Tester.check("Outer.InnerRandom.nextHook(..) calls Random.next(..)"); + Tester.check("Outer.Inner.mi() calls PrintStream.println(..)"); + + Tester.check("X.toString()"); + Tester.check("Outer.foo() calls Random.nextInt(..)"); + } +} + +class Outer { + private class Inner extends Object { + public void mi() { + System.out.println("."); + } + } + + public void foo() { + new Inner().mi(); + new InnerRandom().nextHook(2); + + new java.util.Random() { public String toString() { Tester.note("X.toString()"); return "X"; } }.nextInt(2); + } + + private class InnerRandom extends java.util.Random { + public int nextHook(int bits) { + return next(bits); + } + } +} + +aspect A { + Object around(): call(* *(..)) && !within(A) { +// System.out.println + Tester.note + (thisEnclosingJoinPointStaticPart.getSignature().toShortString() + + " calls " + thisJoinPointStaticPart.getSignature().toShortString()); + return proceed(); + } + + before(Object caller, Object callee): + this(caller) && target(callee) && call(* *(..)) && !within(A) + { + System.out.println(thisEnclosingJoinPointStaticPart.getSignature().toShortString() + + " calls " + thisJoinPointStaticPart.getSignature().toShortString()); + System.out.println + (caller + "." + thisEnclosingJoinPointStaticPart.getSignature().getName() + + " calls " + callee + "." + thisJoinPoint.getSignature().getName()); + } +} diff --git a/tests/new/DeclareMethodCE.java b/tests/new/DeclareMethodCE.java index ded55022f..bad23e569 100644 --- a/tests/new/DeclareMethodCE.java +++ b/tests/new/DeclareMethodCE.java @@ -5,7 +5,6 @@ class B {} aspect A { void B.n() { - void n() { // CE 8 method declared in method - } + void n() { } // CE 8 method declared in method } } diff --git a/tests/new/InterfaceConstructor.java b/tests/new/InterfaceConstructor.java index 080e4406b..49a6ded3c 100644 --- a/tests/new/InterfaceConstructor.java +++ b/tests/new/InterfaceConstructor.java @@ -3,7 +3,7 @@ interface i { } class c { - c(); //ERR: constructors must have bodies + c(); //ERR: constructors must have bodies abstract c(int i) { } //ERR: constructors can't be abstract } diff --git a/tests/new/RecognizeAspectCE.java b/tests/new/RecognizeAspectCE.java index a84effb04..92fb6df1c 100644 --- a/tests/new/RecognizeAspectCE.java +++ b/tests/new/RecognizeAspectCE.java @@ -1,7 +1,7 @@ // PR#457 class RecognizeAspectCE { public static void main(String[] ignore) { } - pointcut mumble() // would like error here: "pointcuts not allowed in classes - use aspect" - : execution(public static void RecognizeAspectCE.main(String[])); - before(): mumble() { } // ok: get error here: constructor has the wrong name +// pointcut mumble() +// : execution(public static void RecognizeAspectCE.main(String[])); + before(): this(*) { } // ok: get error here: constructor has the wrong name } diff --git a/tests/new/perThis/p/EachObjectTarget.java b/tests/new/perThis/p/EachObjectTarget.java new file mode 100644 index 000000000..bf9c364af --- /dev/null +++ b/tests/new/perThis/p/EachObjectTarget.java @@ -0,0 +1,13 @@ +package p; +import org.aspectj.testing.Tester; + +public class EachObjectTarget { + public static void main(String[] args) { + EachObjectTarget o = new EachObjectTarget(); + o.foo(); + } + + void foo() { + Tester.check(true, "Dummy test"); + } +} diff --git a/tests/new/perThis/the/deep/pkg/EachObjectInDeepPackage.java b/tests/new/perThis/the/deep/pkg/EachObjectInDeepPackage.java new file mode 100644 index 000000000..8b862e451 --- /dev/null +++ b/tests/new/perThis/the/deep/pkg/EachObjectInDeepPackage.java @@ -0,0 +1,11 @@ +package the.deep.pkg; + +import org.aspectj.testing.Tester; +import p.EachObjectTarget; + +aspect Aspect pertarget(target(EachObjectTarget)) { + before(): call(void foo(..)) { + EachObjectTarget t = null; + Tester.check(true, "Dummy test"); + } +} diff --git a/tests/options/WarnDeprecated.java b/tests/options/WarnDeprecated.java deleted file mode 100644 index e86b79522..000000000 --- a/tests/options/WarnDeprecated.java +++ /dev/null @@ -1,13 +0,0 @@ - - - - -public class WarnDeprecated { - - /** */ - public static void main(String[] args) { - if (null == args) { - String s = new String(new byte[] {}, 0); // CE 10 deprecated if warn:deprecated - } - } -} diff --git a/tests/options/deprecated/OldStuff.java b/tests/options/deprecated/OldStuff.java new file mode 100644 index 000000000..4179ebf26 --- /dev/null +++ b/tests/options/deprecated/OldStuff.java @@ -0,0 +1,8 @@ +class OldStuff { + + /** + * @deprecated + */ + public static void foo() {} + +}
\ No newline at end of file diff --git a/tests/options/deprecated/WarnDeprecated.java b/tests/options/deprecated/WarnDeprecated.java new file mode 100644 index 000000000..ac2a02226 --- /dev/null +++ b/tests/options/deprecated/WarnDeprecated.java @@ -0,0 +1,18 @@ + + + + +public class WarnDeprecated { + + /** */ + public static void main(String[] args) { + if (null == args) { + OldStuff.foo(); // CE 10 deprecated if warn:deprecated + + // This is only picked up as a deprecation error when compiling against developer + // libraries, it will be ignored if compiling against the user jre libraries. + // We're not going to include this in the test suite for robustness of the suite. + //"hello".getBytes(0, 1, new byte[10], 0); + } + } +} |