From 8804ab51509ace3479735013356edc571de282cf Mon Sep 17 00:00:00 2001 From: avasseur Date: Tue, 17 May 2005 08:59:54 +0000 Subject: [PATCH] LTW and around inling test for code style --- tests/java5/ataspectj/ajc-ant.xml | 8 ++ .../ataspectj/AroundInlineMungerTest2.aj | 41 +++++++++ .../AroundInlineMungerTestAspects2.aj | 87 +++++++++++++++++++ .../ataspectj/aop-aroundinlinemungertest2.xml | 7 ++ .../ajc150/ataspectj/AtAjLTWTests.java | 3 + .../ajc150/ataspectj/AtAjSyntaxTests.java | 3 + .../systemtest/ajc150/ataspectj/ltw.xml | 9 ++ .../systemtest/ajc150/ataspectj/syntax.xml | 5 ++ 8 files changed, 163 insertions(+) create mode 100644 tests/java5/ataspectj/ataspectj/AroundInlineMungerTest2.aj create mode 100644 tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects2.aj create mode 100644 tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml diff --git a/tests/java5/ataspectj/ajc-ant.xml b/tests/java5/ataspectj/ajc-ant.xml index d6034f2a7..ab0e52437 100644 --- a/tests/java5/ataspectj/ajc-ant.xml +++ b/tests/java5/ataspectj/ajc-ant.xml @@ -38,5 +38,13 @@ + + + + + + + + \ No newline at end of file diff --git a/tests/java5/ataspectj/ataspectj/AroundInlineMungerTest2.aj b/tests/java5/ataspectj/ataspectj/AroundInlineMungerTest2.aj new file mode 100644 index 000000000..eeec49f9f --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/AroundInlineMungerTest2.aj @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexandre Vasseur initial implementation + *******************************************************************************/ +package ataspectj; + +import junit.framework.TestCase; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.ProceedingJoinPoint; + +/** + * @author Alexandre Vasseur + */ +public class AroundInlineMungerTest2 extends TestCase { + + public static void main(String[] args) { + TestHelper.runAndThrowOnFailure(suite()); + } + + public static junit.framework.Test suite() { + return new junit.framework.TestSuite(AroundInlineMungerTest2.class); + } + + public void testAccessNonPublicFromAroundAdvice() { + target(); + assertEquals(3, AroundInlineMungerTestAspects2.Open.aroundCount); + assertEquals(6, AroundInlineMungerTestAspects2.Open.beforeCount); + } + + public void target() {} + +} diff --git a/tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects2.aj b/tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects2.aj new file mode 100644 index 000000000..28d7f05af --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects2.aj @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2005 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexandre Vasseur initial implementation + *******************************************************************************/ +package ataspectj; + +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.ProceedingJoinPoint; + +/** + * @author Alexandre Vasseur + */ +public class AroundInlineMungerTestAspects2 { + + public static abstract aspect OpenBase { + protected void superMethod() {} + } + + public static abstract aspect OpenSubBase extends OpenBase {} + + // aspect will be prepared for inlining + public static aspect Open extends OpenSubBase { + + public static int aroundCount = 0; + public static int beforeCount = 0; + + private int i; + private static int I; + + Object around() : execution(* ataspectj.AroundInlineMungerTest2.target()) { + aroundCount++; + priv(1, 2L, 3); + super.superMethod(); + new Inner().priv();//fails to be wrapped so this advice will not be inlined but previous call were still prepared + return proceed(); + } + + // this advice to test around advice body call/get/set advising + before() : (call(* ataspectj.AroundInlineMungerTestAspects2.Open.priv(..)) + || get(int ataspectj.AroundInlineMungerTestAspects2.Open.i) + || set(int ataspectj.AroundInlineMungerTestAspects2.Open.i) + || get(int ataspectj.AroundInlineMungerTestAspects2.Open.I) + || set(int ataspectj.AroundInlineMungerTestAspects2.Open.I) + )&& this(ataspectj.AroundInlineMungerTestAspects2.Open) { + beforeCount++; + } + + Object around() : execution(* ataspectj.AroundInlineMungerTest2.target()) { + aroundCount++; + super.superMethod(); + new Inner().priv();//fails to be wrapped so next calls won't be prepared but previous was + priv(1, 2L, 3); + return proceed(); + } + + Object around() : execution(* ataspectj.AroundInlineMungerTest2.target()) { + aroundCount++; + // all those field access will be wrapped + int li = i; + i = li; + int lI = I; + I = lI; + return proceed(); + } + + // -- some private member for which access will be wrapped so that around advice can be inlined + + private void priv(int i, long j, int k) { + long l = i + j + k; + } + + private static class Inner { + private Inner() {} + private void priv() {}; + } + } + +} diff --git a/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml b/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml new file mode 100644 index 000000000..3f7de3cd3 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest2.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java index 214d0cb96..d2bc160e0 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java @@ -63,5 +63,8 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase { runTest("AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable"); } + public void testAjcLTWAroundInlineMungerTest2() { + runTest("AjcLTW AroundInlineMungerTest2"); + } } diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java index 7e0921f40..264c46930 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java @@ -84,4 +84,7 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase { runTest("AroundInlineMunger"); } + public void testAroundInlineMunger2() { + runTest("AroundInlineMunger2"); + } } \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml index 1f430a861..5a770808a 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml @@ -69,4 +69,13 @@ + + + + + \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml index 594f736de..055567d30 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml @@ -95,4 +95,9 @@ + + + + + \ No newline at end of file -- 2.39.5