]> source.dussan.org Git - aspectj.git/commitdiff
aspects are reweavable by default, fixed issue in (AJC + LTW + Inlining + @AJ)
authoravasseur <avasseur>
Tue, 17 May 2005 08:29:18 +0000 (08:29 +0000)
committeravasseur <avasseur>
Tue, 17 May 2005 08:29:18 +0000 (08:29 +0000)
25 files changed:
loadtime/src/org/aspectj/weaver/loadtime/Aj.java
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
loadtime/src/org/aspectj/weaver/loadtime/Options.java
org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java
tests/java5/ataspectj/ajc-ant.xml
tests/java5/ataspectj/ataspectj/AroundInlineMungerTest.java
tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects.java [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/TestHelper.java
tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest.xml [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/aop.xml
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjSyntaxTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml
weaver/src/org/aspectj/weaver/bcel/BcelAccessForInlineMunger.java
weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
weaver/src/org/aspectj/weaver/patterns/PerCflow.java
weaver/src/org/aspectj/weaver/patterns/PerObject.java
weaver/src/org/aspectj/weaver/patterns/PerSingleton.java
weaver/src/org/aspectj/weaver/patterns/PerTypeWithin.java

index a087c5c8136c76e98b8f19f25e235463284ef706..0962fefbef6608759ae10cdcd0d637a98c6b1c76 100644 (file)
@@ -14,6 +14,7 @@ package org.aspectj.weaver.loadtime;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Map;
 import java.util.WeakHashMap;
 
@@ -99,8 +100,14 @@ public class Aj implements ClassPreProcessor {
                         new Integer(bytes.length)
                     }
             );
-        } catch (Throwable t) {
-            t.printStackTrace();
+        } catch (InvocationTargetException e) {
+            if (e.getTargetException() instanceof LinkageError) {
+                ;//is already defined (happens for X$ajcMightHaveAspect interfaces since aspects are reweaved)
+            } else {
+                e.printStackTrace();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
     }
 
index a08847a6d27acd199a679f92777c3ddd7459518e..f410413324d6292e34016b4e40978f9eba096a65 100644 (file)
@@ -121,6 +121,9 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
                 URL xml = (URL) xmls.nextElement();
                 definitions.add(DocumentParser.parse(xml));
             }
+            
+            // still go thru if definitions is empty since we will configure
+            // the default message handler in there
             registerOptions(weaver, loader, definitions);
             registerAspectExclude(weaver, loader, definitions);
             registerAspects(weaver, loader, definitions);
index 387eca2bfe015c2d72d5221cdd128ac638dad5a4..5ab7d5e9dc3d46bd5ca71210899431ff6fa3b730 100644 (file)
@@ -44,13 +44,14 @@ public class Options {
     //FIXME dump option - dump what - dump before/after ?
 
     public static WeaverOption parse(String options, ClassLoader laoder) {
+        if (LangUtil.isEmpty(options)) {
+            return new WeaverOption();
+        }
         // the first option wins
         List flags = LangUtil.anySplit(options, " ");
         Collections.reverse(flags);
 
         WeaverOption weaverOption = new WeaverOption();
-        weaverOption.messageHandler = new DefaultMessageHandler();//default
-
 
         // do a first round on the message handler since it will report the options themselves
         for (Iterator iterator = flags.iterator(); iterator.hasNext();) {
@@ -99,7 +100,7 @@ public class Options {
             } else {
                 weaverOption.messageHandler.handleMessage(
                         new Message(
-                                "Cannot configure weaver with option " + arg + ": unknown option",
+                                "Cannot configure weaver with option '" + arg + "': unknown option",
                                 IMessage.WARNING,
                                 null,
                                 null
@@ -132,5 +133,13 @@ public class Options {
         boolean noInline;
         boolean showWeaveInfo;
         IMessageHandler messageHandler;
+
+        public WeaverOption() {
+            messageHandler = new DefaultMessageHandler();//default
+
+            //temp alex
+            messageHandler.dontIgnore(IMessage.WEAVEINFO);
+            messageHandler.dontIgnore(IMessage.INFO);
+        }
     }
 }
index 41bb20bc3ef4fa60824c4c2c31f0da3344cac0e3..8e372c05ea5e8c6712b9e547d6d236dac2a14703 100644 (file)
@@ -576,7 +576,7 @@ public class AjcTestCase extends TestCase {
                        fail("main method in class " + className + " is not public");
                } catch (InvocationTargetException invTgt) {
                        // the main method threw an exception...
-                       fail("Exception thrown by " + className + ".main(String[]) :" + invTgt.getTargetException());
+            fail("Exception thrown by " + className + ".main(String[]) :" + invTgt.getTargetException());
                } finally {
                        System.setOut(systemOut);
                        System.setErr(systemErr);
index a83b21bfd40768f96140a9288e46c9f9d7dea47f..d6034f2a77f5532d5906cf1364ee58c05a7a0e35 100644 (file)
@@ -34,7 +34,7 @@
         <java fork="yes" classname="ataspectj.AroundInlineMungerTest" failonerror="yes">
             <classpath refid="aj.path"/>
             <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
-            <jvmarg value="-Daj5.def=ataspectj/aop.xml"/>
+            <jvmarg value="-Daj5.def=ataspectj/aop-aroundinlinemungertest.xml"/>
         </java>
     </target>
 
index 8be6217b4c6fa7f565fd7fc91bc08d7dc918de90..0f8b3539f7c67579e0761da5a0bc33ceb5d8aceb 100644 (file)
@@ -32,77 +32,10 @@ public class AroundInlineMungerTest extends TestCase {
 
     public void testAccessNonPublicFromAroundAdvice() {
         target();
-        assertEquals(3, Open.aroundCount);
-        assertEquals(6, Open.beforeCount);
+        assertEquals(3, AroundInlineMungerTestAspects.Open.aroundCount);
+        assertEquals(6, AroundInlineMungerTestAspects.Open.beforeCount);
     }
 
     public void target() {}
 
-    public static class OpenBase {
-        protected void superMethod() {}
-    }
-
-    public static class OpenSubBase extends OpenBase {}
-
-    // aspect will be prepared for inlining
-    @Aspect
-    public static class Open extends OpenSubBase {
-
-        public static int aroundCount = 0;
-        public static int beforeCount = 0;
-
-        private int i;
-        private static int I;
-
-        @Around("execution(* ataspectj.AroundInlineMungerTest.target())")
-        public Object around1(ProceedingJoinPoint jp) throws Throwable {
-            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 jp.proceed();
-        }
-
-        // this advice to test around advice body call/get/set advising
-        @Before("(call(* ataspectj.AroundInlineMungerTest.Open.priv(..))" +
-                "  || get(int ataspectj.AroundInlineMungerTest.Open.i)" +
-                "  || set(int ataspectj.AroundInlineMungerTest.Open.i)" +
-                "  || get(int ataspectj.AroundInlineMungerTest.Open.I)" +
-                "  || set(int ataspectj.AroundInlineMungerTest.Open.I)" +
-                " )&& this(ataspectj.AroundInlineMungerTest.Open)")
-        public void before1() {
-            beforeCount++;
-        }
-
-        @Around("execution(* ataspectj.AroundInlineMungerTest.target())")
-        public Object around2(ProceedingJoinPoint jp) throws Throwable {
-            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 jp.proceed();
-        }
-
-        @Around("execution(* ataspectj.AroundInlineMungerTest.target())")
-        public Object around3(ProceedingJoinPoint jp) throws Throwable {
-            aroundCount++;
-            // all those field access will be wrapped
-            int li = i;
-            i = li;
-            int lI = I;
-            I = lI;
-            return jp.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/AroundInlineMungerTestAspects.java b/tests/java5/ataspectj/ataspectj/AroundInlineMungerTestAspects.java
new file mode 100644 (file)
index 0000000..109f296
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * 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 <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class AroundInlineMungerTestAspects {
+
+    public static class OpenBase {
+        protected void superMethod() {}
+    }
+
+    public static class OpenSubBase extends OpenBase {}
+
+    // aspect will be prepared for inlining
+    @Aspect
+    public static class Open extends OpenSubBase {
+
+        public static int aroundCount = 0;
+        public static int beforeCount = 0;
+
+        private int i;
+        private static int I;
+
+        @Around("execution(* ataspectj.AroundInlineMungerTest.target())")
+        public Object around1(ProceedingJoinPoint jp) throws Throwable {
+            aroundCount++;
+            priv(1, 2L, 3);
+            super.superMethod();
+            new Open.Inner().priv();//fails to be wrapped so this advice will not be inlined but previous call were still prepared
+            return jp.proceed();
+        }
+
+        // this advice to test around advice body call/get/set advising
+        @Before("(call(* ataspectj.AroundInlineMungerTestAspects.Open.priv(..))" +
+                "  || get(int ataspectj.AroundInlineMungerTestAspects.Open.i)" +
+                "  || set(int ataspectj.AroundInlineMungerTestAspects.Open.i)" +
+                "  || get(int ataspectj.AroundInlineMungerTestAspects.Open.I)" +
+                "  || set(int ataspectj.AroundInlineMungerTestAspects.Open.I)" +
+                " )&& this(ataspectj.AroundInlineMungerTestAspects.Open)")
+        public void before1() {
+            beforeCount++;
+        }
+
+        @Around("execution(* ataspectj.AroundInlineMungerTest.target())")
+        public Object around2(ProceedingJoinPoint jp) throws Throwable {
+            aroundCount++;
+            super.superMethod();
+            new Open.Inner().priv();//fails to be wrapped so next calls won't be prepared but previous was
+            priv(1, 2L, 3);
+            return jp.proceed();
+        }
+
+        @Around("execution(* ataspectj.AroundInlineMungerTest.target())")
+        public Object around3(ProceedingJoinPoint jp) throws Throwable {
+            aroundCount++;
+            // all those field access will be wrapped
+            int li = i;
+            i = li;
+            int lI = I;
+            I = lI;
+            return jp.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() {};
+        }
+    }
+
+}
index 10855a5db2e96bd81a3ad4c8a60d74f7a9778d85..378f5936dda0e2a12b6a645b80808b8b0bcdcd9d 100644 (file)
@@ -40,13 +40,15 @@ public class TestHelper extends DefaultMessageHandler {
             Enumeration e = rr.failures();
             while (e.hasMoreElements()) {
                 sb.append("JUnit Failure: ");
-                sb.append(((TestFailure)e.nextElement()).thrownException().toString());
+                TestFailure failure = (TestFailure)e.nextElement();
+                sb.append(failure.thrownException().toString());
                 sb.append("\n");
             }
             e = rr.errors();
             while (e.hasMoreElements()) {
                 sb.append("JUnit Error: ");
-                sb.append(((TestFailure)e.nextElement()).thrownException().toString());
+                TestFailure failure = (TestFailure)e.nextElement();
+                sb.append(failure.thrownException().toString());
                 sb.append("\n");
             }
             throw new RuntimeException(sb.toString());
diff --git a/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest.xml b/tests/java5/ataspectj/ataspectj/aop-aroundinlinemungertest.xml
new file mode 100644 (file)
index 0000000..ce025ce
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<aspectj>
+    <weaver options="-XmessageHolderClass:ataspectj.TestHelper"/>
+    <aspects>
+        <aspect name="ataspectj.AroundInlineMungerTestAspects.Open"/>
+    </aspects>
+</aspectj>
index efe556127ef97f4744872b2d242ed895d21ee319..365cd5d178acc5b31e8e167846b7c84d079853b7 100644 (file)
@@ -21,6 +21,6 @@
         <aspect name="ataspectj.PerClauseTestAspects.TestAspectPerCflow"/>
         <aspect name="ataspectj.PerClauseTestAspects.TestAspectPTW"/>
 
-        <aspect name="ataspectj.AroundInlineMungerTest.Open"/>
+        <aspect name="ataspectj.AroundInlineMungerTestAspects.Open"/>
     </aspects>
 </aspectj>
index a4ba644a377b75fde413780762fc8ca4089c7432..214d0cb965a30daa3a37774a99c98422ecf28945 100644 (file)
@@ -29,15 +29,39 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {
          return new File("../tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml");
        }
 
-       public void testRunThemAllWithJavacCompiledAndLTW() {
-               runTest("RunThemAllWithJavacCompiledAndLTW");
-       }
 
-       public void testAjcLTWPerClauseTest_XnoWeave() {
-               runTest("AjcLTW PerClauseTest -XnoWeave");
-       }
+    //FIXME AV - those all 4 depends on #75442...
+//     public void testRunThemAllWithJavacCompiledAndLTW() {
+//             runTest("RunThemAllWithJavacCompiledAndLTW");
+//     }
+//
+//     public void testAjcLTWPerClauseTest_XnoWeave() {
+//             runTest("AjcLTW PerClauseTest -XnoWeave");
+//     }
+//
+//     public void testAjcLTWPerClauseTest_Xreweavable() {
+//             runTest("AjcLTW PerClauseTest -Xreweavable");
+//     }
+//
+//    public void testJavaCAjcLTWPerClauseTest() {
+//        runTest("JavaCAjcLTW PerClauseTest");
+//    }
+
+    public void testAjcLTWAroundInlineMungerTest_XnoWeave() {
+        runTest("AjcLTW AroundInlineMungerTest -XnoWeave");
+    }
+
+    public void testAjcLTWAroundInlineMungerTest_Xreweavable() {
+        runTest("AjcLTW AroundInlineMungerTest -Xreweavable");
+    }
+
+    public void testAjcLTWAroundInlineMungerTest() {
+        runTest("AjcLTW AroundInlineMungerTest");
+    }
+
+    public void testAjcLTWAroundInlineMungerTest_XnoInline_Xreweavable() {
+        runTest("AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable");
+    }
+
 
-       public void testAjcLTWPerClauseTest_Xreweavable() {
-               runTest("AjcLTW PerClauseTest -Xreweavable");
-       }
 }
index a23806e06aa8e15e08bd0cfd676ea1daa54416eb..7e0921f40a9cbffc50d97ce0672d0bdfabc8c60d 100644 (file)
@@ -32,7 +32,6 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase {
          return new File("../tests/src/org/aspectj/systemtest/ajc150/ataspectj/syntax.xml");
        }
 
-
     public void testSimpleBefore() {
         runTest("SimpleBefore");
     }
@@ -77,6 +76,10 @@ public class AtAjSyntaxTests extends XMLBasedAjcTestCase {
         runTest("PerClause");
     }
 
+    public void testAroundInlineMunger_XnoInline() {
+        runTest("AroundInlineMunger -XnoInline");
+    }
+
     public void testAroundInlineMunger() {
         runTest("AroundInlineMunger");
     }
index e44aef3f9e622c2673f9d205e80d9792de09b92f..1f430a8617e6f324d922cf600de9a624d88ee9bc 100644 (file)
         <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/>
     </ajc-test>
 
-<!--    FIXME AV: todo by Andy-->
-<!--    <ajc-test dir="java5/ataspectj" title="JavaCAjcLTW PerClauseTest">-->
-<!--        <compile-->
-<!--            files="ataspectj/PerClauseTest.java,ataspectj/TestHelper.java"-->
-<!--            options="-1.5 -XnoWeave"/>-->
-<!--        <comment>-->
-<!--        aspectOf methods will be pushed in, ignore warning for adviceDidNotMatch but still do the logic for them-->
-<!--        since such just added methods are an interesting case (percflow ajc$perCflowStack advice)-->
-<!--        </comment>-->
-<!--        <compile-->
-<!--            files="ataspectj/PerClauseTestAspects.java"-->
-<!--            options="-1.5 -Xdev:NoAtAspectJProcessing">-->
-<!--                <message kind="warning"/>-->
-<!--            </compile>-->
-<!--        <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/>-->
-<!--    </ajc-test>-->
+    <ajc-test dir="java5/ataspectj" title="JavaCAjcLTW PerClauseTest">
+        <compile
+            files="ataspectj/PerClauseTest.java,ataspectj/TestHelper.java,ataspectj/PerClauseTestAspects.java"
+            options="-1.5 -XnoWeave"/>
+        <comment>
+        aspectOf methods will be pushed in, ignore warning for adviceDidNotMatch but still do the logic for them
+        since such just added methods are an interesting case (percflow ajc$perCflowStack advice)
+        </comment>
+        <compile
+            files="ataspectj/PerClauseTestAspects.java"
+            options="-1.5 -Xdev:NoAtAspectJProcessing">
+                <message kind="warning"/>
+        </compile>
+        <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/>
+    </ajc-test>
+
+    <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -XnoWeave">
+        <compile
+            files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java"
+            options="-1.5 -XnoWeave"/>
+        <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
+    </ajc-test>
+
+    <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -Xreweavable">
+        <compile
+            files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java"
+            options="-1.5 -Xreweavable"/>
+        <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
+    </ajc-test>
+
+    <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest">
+        <compile
+            files="ataspectj/AroundInlineMungerTestAspects.java"
+            options="-1.5 -Xlint:ignore"/>
+        <compile
+            files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java"
+            options="-1.5 -Xreweavable"/>
+        <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
+    </ajc-test>
+
+    <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable">
+        <compile
+            files="ataspectj/AroundInlineMungerTestAspects.java"
+            options="-1.5 -Xlint:ignore -XnoInline -Xreweavable"/>
+        <compile
+            files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java"
+            options="-1.5 -Xreweavable -XnoInline"/>
+        <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
+    </ajc-test>
 
 </suite>
\ No newline at end of file
index 2cf179be8bdd6ec6d2efc24cf7f6d18afdead78e..594f736deb4e63226a37fc73455fbe505c621d8c 100644 (file)
         <run class="ataspectj.PerClauseTest"/>
     </ajc-test>
 
-    <ajc-test dir="java5/ataspectj" title="AroundInlineMunger">
-        <compile files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline -Xdev:NoAtAspectJProcessing -Xlint:ignore"/>
-        <run class="ataspectj.AroundInlineMungerTest"/>
-        <compile files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing -Xlint:ignore"/>
+    <ajc-test dir="java5/ataspectj" title="AroundInlineMunger -XnoInline">
+        <compile files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java" options="-1.5 -XnoInline -Xdev:NoAtAspectJProcessing -Xlint:ignore"/>
         <run class="ataspectj.AroundInlineMungerTest"/>
     </ajc-test>
 
+    <ajc-test dir="java5/ataspectj" title="AroundInlineMunger">
+        <compile files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java" options="-1.5 -Xdev:NoAtAspectJProcessing -Xlint:ignore"/>
+        <run class="ataspectj.AroundInlineMungerTest"/>
+    </ajc-test>
 </suite>
\ No newline at end of file
index c174ee3cd79d155845263f7b61e1dacf9f0f4187..a4727a460c5502e65639f9b17ff6985db052e07e 100644 (file)
@@ -48,6 +48,9 @@ import java.util.List;
  * Specific state and logic is kept in the munger ala ITD so that call/get/set pointcuts can still be matched
  * on the wrapped member thanks to the EffectiveSignature attribute.
  *
+ * FIXME AV - this whole one should be skept when -XnoInline is used
+ * (add breakpoint on lazyMethodGen.setCanInline to see where things happening)
+ *
  * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
  */
 public class BcelAccessForInlineMunger extends BcelTypeMunger {
@@ -219,6 +222,13 @@ public class BcelAccessForInlineMunger extends BcelTypeMunger {
 
             curr = next;
         }
+
+        // no reason for not inlining this advice
+        // since it is used for @AJ advice that cannot be inlined by defauilt
+        // make sure we set inline to true since we have done this analysis
+        if (!realizedCannotInline) {
+            aroundAdvice.setCanInline(true);
+        }
     }
 
     /**
index d28034fededf2fa4ba674e25279c796533e9554c..1fa87d1b0091d77c19016dd00043ba33e00788ad 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Collections;
 import org.aspectj.apache.bcel.generic.InstructionFactory;
 import org.aspectj.apache.bcel.generic.InstructionHandle;
 import org.aspectj.apache.bcel.generic.InstructionList;
+import org.aspectj.apache.bcel.generic.ReferenceType;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.Message;
 import org.aspectj.weaver.Advice;
@@ -367,6 +368,13 @@ public class BcelAdvice extends Advice {
                     // ATAJ: for @AJ aspects, handle implicit binding of xxJoinPoint
                        if (getKind() == AdviceKind.Around) {
                            il.append(closureInstantiation);
+                        //
+//                        if (canInline(shadow)) {
+//                            //FIXME ALEX? passin a boolean instead of checking there
+//                            il.append(fact.createCheckCast(
+//                                    (ReferenceType) BcelWorld.makeBcelType(TypeX.forName("org.aspectj.lang.ProceedingJoinPoint"))
+//                            ));
+//                        }
                            continue;
                        } else if ("Lorg/aspectj/lang/JoinPoint$StaticPart;".equals(getSignature().getParameterTypes()[i].getSignature())) {
                            if ((getExtraParameterFlags() & ThisJoinPointStaticPart) != 0) {
index 305bdcf235aeab2091731c2d3b6224cea9dfd03b..eab392a1753a4e242099d0ef65a967c92a132c3e 100644 (file)
@@ -327,7 +327,7 @@ class BcelClassWeaver implements IClassWeaver {
        
 
         Set aspectsAffectingType = null;
-        if (inReweavableMode) aspectsAffectingType = new HashSet();
+        if (inReweavableMode || clazz.getType().isAspect()) aspectsAffectingType = new HashSet();
         
         boolean isChanged = false;
         
@@ -345,7 +345,7 @@ class BcelClassWeaver implements IClassWeaver {
                boolean typeMungerAffectedType = munger.munge(this);
                if (typeMungerAffectedType) {
                        isChanged = true;
-                       if (inReweavableMode) aspectsAffectingType.add(munger.getAspectType().getName());
+                       if (inReweavableMode || clazz.getType().isAspect()) aspectsAffectingType.add(munger.getAspectType().getName());
                }
         }
 
@@ -378,7 +378,7 @@ class BcelClassWeaver implements IClassWeaver {
                        boolean shadowMungerMatched = match(mg);
                        if (shadowMungerMatched) {
                                // For matching mungers, add their declaring aspects to the list that affected this type
-                               if (inReweavableMode) aspectsAffectingType.addAll(findAspectsForMungers(mg));
+                               if (inReweavableMode || clazz.getType().isAspect()) aspectsAffectingType.addAll(findAspectsForMungers(mg));
               isChanged = true;
                        }
         }
@@ -415,7 +415,7 @@ class BcelClassWeaver implements IClassWeaver {
                     boolean typeMungerAffectedType = munger.munge(this);
                     if (typeMungerAffectedType) {
                         isChanged = true;
-                        if (inReweavableMode) aspectsAffectingType.add(munger.getAspectType().getName());
+                        if (inReweavableMode || clazz.getType().isAspect()) aspectsAffectingType.add(munger.getAspectType().getName());
                     }
                 }
             }
@@ -429,7 +429,7 @@ class BcelClassWeaver implements IClassWeaver {
                        weaveInAddedMethods(); // FIXME asc are these potentially affected by declare annotation?
         }
         
-        if (inReweavableMode) {
+        if (inReweavableMode || clazz.getType().isAspect()) {
                WeaverStateInfo wsi = clazz.getOrCreateWeaverStateInfo();
                wsi.addAspectsAffectingType(aspectsAffectingType);
                wsi.setUnwovenClassFileData(ty.getJavaClass().getBytes());
index 8f80c719540a77d134de28ad7be5aafcc8652ea0..f41cce9658fb588c5e0290c31c38350206bc6da8 100644 (file)
@@ -52,6 +52,7 @@ import org.aspectj.apache.bcel.generic.SWAP;
 import org.aspectj.apache.bcel.generic.StoreInstruction;
 import org.aspectj.apache.bcel.generic.TargetLostException;
 import org.aspectj.apache.bcel.generic.Type;
+import org.aspectj.apache.bcel.generic.ReferenceType;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.ISourceLocation;
 import org.aspectj.bridge.Message;
@@ -1933,8 +1934,7 @@ public class BcelShadow extends Shadow {
         BcelObjectType ot = BcelWorld.getBcelObjectType(declaringType); 
         
                LazyMethodGen adviceMethod = ot.getLazyClassGen().getLazyMethodGen(mungerSig);
-               if (!adviceMethod.getCanInline())
-               {
+               if (!adviceMethod.getCanInline()) {
                        weaveAroundClosure(munger, hasDynamicTest);
                        return;
                }
@@ -2357,6 +2357,14 @@ public class BcelShadow extends Shadow {
                 ResolvedTypeX stateTypeX = BcelWorld.fromBcel(stateType).resolve(world);
                 if ("Lorg/aspectj/lang/JoinPoint;".equals(stateType.getSignature())) {
                     ret.append(new ALOAD(localJp));// from localAdvice signature
+//                } else if ("Lorg/aspectj/lang/ProceedingJoinPoint;".equals(stateType.getSignature())) {
+//                    //FIXME ALEX?
+//                        ret.append(new ALOAD(localJp));// from localAdvice signature
+////                        ret.append(fact.createCheckCast(
+////                                (ReferenceType) BcelWorld.makeBcelType(stateTypeX)
+////                    ));
+//                        // cast ?
+//
                 } else {
                     ret.append(InstructionFactory.createLoad(stateType, i));
                 }
@@ -2452,10 +2460,7 @@ public class BcelShadow extends Shadow {
 //        return ret;
     }
 
-    public void weaveAroundClosure(
-        BcelAdvice munger, 
-        boolean hasDynamicTest) 
-    {
+    public void weaveAroundClosure(BcelAdvice munger, boolean hasDynamicTest) {
        InstructionFactory fact = getFactory();
 
                enclosingMethod.setCanInline(false);
@@ -2938,6 +2943,8 @@ public class BcelShadow extends Shadow {
         // join point, it is unnecessary to accept (and pass) tjp.
         if (thisJoinPointVar != null) {
                parameterTypes = addTypeToEnd(LazyClassGen.tjpType, parameterTypes);
+            //FIXME ALEX? which one            
+            //parameterTypes = addTypeToEnd(LazyClassGen.proceedingTjpType, parameterTypes);
         }
         
         TypeX returnType;
index c41201142bbcff684473618604012dba1a81a367..0b67d4b55f8e2650c58755f860d8d179aec5e87b 100644 (file)
@@ -162,6 +162,8 @@ public class BcelWeaver implements IWeaver {
 
        //System.out.println("type: " + type + " for " + aspectName);
                if (type.isAspect()) {
+            //TODO AV - happens to reach that a lot of time: for each type flagged reweavable X for each aspect in the weaverstate
+            //=> mainly for nothing for LTW - pbly for something in incremental build...
                        xcutSet.addOrReplaceAspect(type);
                } else {
             // FIXME : Alex: better warning upon no such aspect from aop.xml
@@ -945,7 +947,19 @@ public class BcelWeaver implements IWeaver {
                    BcelObjectType classType = getClassType(className);                             
                        processReweavableStateIfPresent(className, classType);
                }
-                                                               
+
+        // register all aspect that have been extracted from reweavable state for LTW
+        // note: when doing AJC, the missing aspect is already catch in the previous state thru Type.MISSING
+        if (alreadyConfirmedReweavableState != null) {
+            for (Iterator iterator = alreadyConfirmedReweavableState.iterator(); iterator.hasNext();) {
+                String aspectClassName = (String) iterator.next();
+                addLibraryAspect(aspectClassName);
+            }
+            // refresh all the stuff... perhaps too much here...
+            if (!alreadyConfirmedReweavableState.isEmpty())
+                prepareForWeave();
+        }
+
                requestor.addingTypeMungers();
         
         // We process type mungers in two groups, first mungers that change the type
@@ -1062,7 +1076,8 @@ public class BcelWeaver implements IWeaver {
                        world.showMessage(IMessage.INFO,
                                        WeaverMessages.format(WeaverMessages.REWEAVABLE_MODE),
                                        null, null);
-                       
+
+        //TODO AV - can't we avoid this creation (LTW = happens for each class load!)
        alreadyConfirmedReweavableState = new HashSet();
     }
     
index 9c5524b819916bff09a1dcdf016cd86c76949aa7..653da49a0a8f42862b58c96f5c1de5135d61e831 100644 (file)
@@ -639,7 +639,7 @@ public final class LazyClassGen {
        
        public boolean isReweavable() {
                if (myType.getWeaverState()==null) return false;
-               return myType.getWeaverState().isReweavable();
+        return myType.getWeaverState().isReweavable();
        }
        
        public Set getAspectsAffectingType() {
@@ -700,7 +700,9 @@ public final class LazyClassGen {
     
     // reflective thisJoinPoint support
     Map/*BcelShadow, Field*/ tjpFields = new HashMap();
-    public static final ObjectType tjpType = 
+    public static final ObjectType proceedingTjpType =
+       new ObjectType("org.aspectj.lang.ProceedingJoinPoint");
+    public static final ObjectType tjpType =
        new ObjectType("org.aspectj.lang.JoinPoint");
     public static final ObjectType staticTjpType = 
        new ObjectType("org.aspectj.lang.JoinPoint$StaticPart");
index 65db2076931c3831dfffd7c301192d438e0f80bc..344c4c2d87673aa7db26fb1c746d59e813848dd1 100644 (file)
@@ -100,7 +100,7 @@ public final class LazyMethodGen {
 
     private int             maxLocals; 
     
-    private boolean canInline = true;
+    private boolean canInline = true;//FIXME AV - ALEX? shouldn't that default to false or unknown?
     private boolean hasExceptionHandlers;
     
     private boolean isSynthetic = false;
@@ -140,6 +140,18 @@ public final class LazyMethodGen {
         this.attributes = new Attribute[0];
         this.enclosingClass = enclosingClass;
         assertGoodBody();
+
+        // @AJ advice are not inlined by default since requires further analysis
+        // and weaving ordering control
+        // TODO AV - improve - note: no room for improvement as long as aspects are reweavable
+        // since the inlined version with wrappers and an to be done annotation to keep
+        // inline state will be garbaged due to reweavable impl
+        if (memberView != null && isAdviceMethod()) {
+            if (enclosingClass.getType().isAnnotationStyleAspect()) {
+                //TODO we could check for @Around advice as well
+                this.canInline = false;
+            }
+        }
     }
        
     private int calculateMaxLocals() {
@@ -167,6 +179,18 @@ public final class LazyMethodGen {
         
                this.accessFlags = m.getAccessFlags();
                this.name = m.getName();
+
+        // @AJ advice are not inlined by default since requires further analysis
+        // and weaving ordering control
+        // TODO AV - improve - note: no room for improvement as long as aspects are reweavable
+        // since the inlined version with wrappers and an to be done annotation to keep
+        // inline state will be garbaged due to reweavable impl
+        if (memberView != null && isAdviceMethod()) {
+            if (enclosingClass.getType().isAnnotationStyleAspect()) {
+                //TODO we could check for @Around advice as well
+                this.canInline = false;
+            }
+        }
     }
     
     public boolean hasDeclaredLineNumberInfo() {
index 76a2fc345fb4c7f6be4e2ac810f53a1d481f8998..f9d97a936f6a6a208723d648dfdab250b5b64c68 100644 (file)
@@ -105,9 +105,9 @@ public class PerCflow extends PerClause {
             );
         }
 
-        //ATAJ inline around advice support
+        //ATAJ inline around advice support - don't use a late munger to allow around inling for itself
         if (Ajc5MemberMaker.isAnnotationStyleAspect(inAspect)) {
-            inAspect.crosscuttingMembers.addLateTypeMunger(new BcelAccessForInlineMunger(inAspect));
+            inAspect.crosscuttingMembers.addTypeMunger(new BcelAccessForInlineMunger(inAspect));
         }
 
                return ret;
index aec9f7f4daa8a66efaff284328553c9525edd43c..3ec3addebe7da924bc6a85a8f5002409667112b3 100644 (file)
@@ -118,9 +118,9 @@ public class PerObject extends PerClause {
             );
         }
 
-        //ATAJ inline around advice support
+        //ATAJ inline around advice support - don't use a late munger to allow around inling for itself
         if (Ajc5MemberMaker.isAnnotationStyleAspect(inAspect)) {
-            inAspect.crosscuttingMembers.addLateTypeMunger(new BcelAccessForInlineMunger(inAspect));
+            inAspect.crosscuttingMembers.addTypeMunger(new BcelAccessForInlineMunger(inAspect));
         }
 
                return ret;
index ad780fc02a315e44ab05732eed3f2a0cafc05a3c..bf390fa6e67c858118ff6477b94759999febedc4 100644 (file)
@@ -107,7 +107,7 @@ public class PerSingleton extends PerClause {
 
         //ATAJ inline around advice support
         if (Ajc5MemberMaker.isAnnotationStyleAspect(inAspect)) {
-            inAspect.crosscuttingMembers.addLateTypeMunger(new BcelAccessForInlineMunger(inAspect));
+            inAspect.crosscuttingMembers.addTypeMunger(new BcelAccessForInlineMunger(inAspect));
         }
 
         return ret;
index 1971fa83bc6ed241c133671a8a26e18916e9132c..59c4169b7a87fc8b9994c6c67eb8a1e3dcaeee9b 100644 (file)
@@ -155,9 +155,9 @@ public class PerTypeWithin extends PerClause {
             );
         }
 
-        //ATAJ inline around advice support
+        //ATAJ inline around advice support - don't use a late munger to allow around inling for itself
         if (Ajc5MemberMaker.isAnnotationStyleAspect(inAspect)) {
-            inAspect.crosscuttingMembers.addLateTypeMunger(new BcelAccessForInlineMunger(inAspect));
+            inAspect.crosscuttingMembers.addTypeMunger(new BcelAccessForInlineMunger(inAspect));
         }
 
                return ret;