aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/adk15ProgGuideDB/ltw.xml6
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/DefaultMessageHandler.java12
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/Options.java4
-rw-r--r--tests/java5/ataspectj/ajc-ant.xml22
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwlog/Aspect1.java28
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwlog/MainSilent.java33
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwlog/MainVerbose.java35
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwlog/MainVerboseAndShow.java36
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwlog/MessageHolder.java67
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwlog/aop-silent.xml6
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwlog/aop-verbose.xml6
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwlog/aop-verboseandshow.xml6
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml7
14 files changed, 262 insertions, 10 deletions
diff --git a/docs/adk15ProgGuideDB/ltw.xml b/docs/adk15ProgGuideDB/ltw.xml
index cbbdef913..27d55b746 100644
--- a/docs/adk15ProgGuideDB/ltw.xml
+++ b/docs/adk15ProgGuideDB/ltw.xml
@@ -353,7 +353,11 @@
<literal>org.aspectj.bridge.IMessageHandler</literal>
and that is visible from where the <literal>aop.xml</literal> is packed.
If more than one such options are used,
- the first occurence only is taken into account.</entry>
+ the first occurence only is taken into account.
+ You must also be very cautious about using a custom handler since it is likely that it will be invoked
+ (as well as all its third parties) while the weaving is done, which means that f.e. it cannot be weaved
+ by the aspects that are configured within the same deployment unit.
+ </entry>
</row>
</tbody>
</tgroup>
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/DefaultMessageHandler.java b/loadtime/src/org/aspectj/weaver/loadtime/DefaultMessageHandler.java
index e099dee7c..80d6e23e3 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/DefaultMessageHandler.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/DefaultMessageHandler.java
@@ -25,10 +25,14 @@ public class DefaultMessageHandler implements IMessageHandler {
boolean showWarn = true;
public boolean handleMessage(IMessage message) throws AbortException {
- if (message.getKind().isSameOrLessThan(IMessage.INFO)) {
- return SYSTEM_OUT.handleMessage(message);
- } else {
- return SYSTEM_ERR.handleMessage(message);
+ if (isIgnoring(message.getKind())) {
+ return false;
+ } else {
+ if (message.getKind().isSameOrLessThan(IMessage.INFO)) {
+ return SYSTEM_OUT.handleMessage(message);
+ } else {
+ return SYSTEM_ERR.handleMessage(message);
+ }
}
}
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/Options.java b/loadtime/src/org/aspectj/weaver/loadtime/Options.java
index e6c502d10..507afe990 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/Options.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/Options.java
@@ -133,10 +133,6 @@ public class Options {
public WeaverOption() {
messageHandler = new DefaultMessageHandler();//default
-
- //temp alex
- messageHandler.dontIgnore(IMessage.WEAVEINFO);
- messageHandler.dontIgnore(IMessage.INFO);
}
}
}
diff --git a/tests/java5/ataspectj/ajc-ant.xml b/tests/java5/ataspectj/ajc-ant.xml
index 5cdd58ebe..8381b6135 100644
--- a/tests/java5/ataspectj/ajc-ant.xml
+++ b/tests/java5/ataspectj/ajc-ant.xml
@@ -77,6 +77,28 @@
<jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
<jvmarg value="-Daj5.def=ataspectj/ltwreweavable/aop-ltwreweavable.xml"/>
</java>
+ </target>
+ <target name="ltwlog.LTWLog">
+ <javac destdir="${aj.sandbox}" classpathref="aj.path"
+ srcdir="${basedir}"
+ includes="ataspectj/ltwlog/*"
+ debug="true">
+ </javac>
+ <java fork="yes" classname="ataspectj.ltwlog.MainSilent" failonerror="yes">
+ <classpath refid="aj.path"/>
+ <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+ <jvmarg value="-Daj5.def=ataspectj/ltwlog/aop-silent.xml"/>
+ </java>
+ <java fork="yes" classname="ataspectj.ltwlog.MainVerbose" failonerror="yes">
+ <classpath refid="aj.path"/>
+ <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+ <jvmarg value="-Daj5.def=ataspectj/ltwlog/aop-verbose.xml"/>
+ </java>
+ <java fork="yes" classname="ataspectj.ltwlog.MainVerboseAndShow" failonerror="yes">
+ <classpath refid="aj.path"/>
+ <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+ <jvmarg value="-Daj5.def=ataspectj/ltwlog/aop-verboseandshow.xml"/>
+ </java>
</target>
</project> \ No newline at end of file
diff --git a/tests/java5/ataspectj/ataspectj/ltwlog/Aspect1.java b/tests/java5/ataspectj/ataspectj/ltwlog/Aspect1.java
new file mode 100644
index 000000000..6accd8624
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ltwlog/Aspect1.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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.ltwlog;
+
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.JoinPoint;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+@Aspect
+public class Aspect1 {
+
+ @Before("execution(* ataspectj.ltwlog.Main*.target())")
+ public void before(JoinPoint jp) {
+ System.out.println(jp.toShortString());
+ }
+}
diff --git a/tests/java5/ataspectj/ataspectj/ltwlog/MainSilent.java b/tests/java5/ataspectj/ataspectj/ltwlog/MainSilent.java
new file mode 100644
index 000000000..ecf404e66
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ltwlog/MainSilent.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.ltwlog;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class MainSilent {
+
+ void target() {};
+
+ public static void main(String args[]) throws Throwable {
+ new MainSilent().target();
+ if (!MessageHolder.startsAs(Arrays.asList(new String[]{})) || MessageHolder.size()>0) {
+ MessageHolder.dump();
+ throw new RuntimeException("failed");
+ }
+ }
+
+
+}
diff --git a/tests/java5/ataspectj/ataspectj/ltwlog/MainVerbose.java b/tests/java5/ataspectj/ataspectj/ltwlog/MainVerbose.java
new file mode 100644
index 000000000..feda514ff
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ltwlog/MainVerbose.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.ltwlog;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class MainVerbose {
+
+ void target() {};
+
+ public static void main(String args[]) throws Throwable {
+ new MainVerbose().target();
+ if (!MessageHolder.startsAs(Arrays.asList(new String[]{
+ "info weaving 'ataspectj/ltwlog/MainVerbose'",
+ "info weaving 'ataspectj/ltwlog/Aspect1'"}))) {
+ MessageHolder.dump();
+ throw new RuntimeException("failed");
+ }
+ }
+
+
+}
diff --git a/tests/java5/ataspectj/ataspectj/ltwlog/MainVerboseAndShow.java b/tests/java5/ataspectj/ataspectj/ltwlog/MainVerboseAndShow.java
new file mode 100644
index 000000000..232f1ab31
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ltwlog/MainVerboseAndShow.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.ltwlog;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class MainVerboseAndShow {
+
+ void target() {};
+
+ public static void main(String args[]) throws Throwable {
+ new MainVerboseAndShow().target();
+ if (!MessageHolder.startsAs(Arrays.asList(new String[]{
+ "info weaving 'ataspectj/ltwlog/MainVerboseAndShow'",
+ "weaveinfo Type 'ataspectj.ltwlog.MainVerboseAndShow' (MainVerboseAndShow.java:22) advised by before advice from 'ataspectj.ltwlog.Aspect1' (Aspect1.java)",
+ "info weaving 'ataspectj/ltwlog/Aspect1'"}))) {
+ MessageHolder.dump();
+ throw new RuntimeException("failed");
+ }
+ }
+
+
+}
diff --git a/tests/java5/ataspectj/ataspectj/ltwlog/MessageHolder.java b/tests/java5/ataspectj/ataspectj/ltwlog/MessageHolder.java
new file mode 100644
index 000000000..4f245ab35
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ltwlog/MessageHolder.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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.ltwlog;
+
+import org.aspectj.bridge.IMessageHolder;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.AbortException;
+import org.aspectj.weaver.loadtime.DefaultMessageHandler;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class MessageHolder extends DefaultMessageHandler {
+
+ static List s_messages = new ArrayList();
+
+ public MessageHolder() {
+ }
+
+ public boolean handleMessage(IMessage message) throws AbortException {
+ if (isIgnoring(message.getKind())) {
+ return false;
+ } else {
+ s_messages.add(message.toString());
+ return true;
+ }
+ }
+
+ public static boolean startsAs(List messages) {
+ if (s_messages.size() < messages.size())
+ return false;
+
+ int i = 0;
+ for (Iterator iterator = messages.iterator(); iterator.hasNext();) {
+ String s = (String) iterator.next();
+ if (!((String)s_messages.get(i)).startsWith(s)) {
+ return false;
+ }
+ i++;
+ }
+ return true;
+ }
+
+ public static int size() {
+ return s_messages.size();
+ }
+
+ public static void dump() {
+ for (Iterator iterator = s_messages.iterator(); iterator.hasNext();) {
+ String s = (String) iterator.next();
+ System.err.println("Holds:" + s);
+ }
+ }
+}
diff --git a/tests/java5/ataspectj/ataspectj/ltwlog/aop-silent.xml b/tests/java5/ataspectj/ataspectj/ltwlog/aop-silent.xml
new file mode 100644
index 000000000..6e320f1d2
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ltwlog/aop-silent.xml
@@ -0,0 +1,6 @@
+<aspectj>
+ <weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/>
+ <aspects>
+ <aspect name="ataspectj.ltwlog.Aspect1"/>
+ </aspects>
+</aspectj> \ No newline at end of file
diff --git a/tests/java5/ataspectj/ataspectj/ltwlog/aop-verbose.xml b/tests/java5/ataspectj/ataspectj/ltwlog/aop-verbose.xml
new file mode 100644
index 000000000..c7756c8e5
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ltwlog/aop-verbose.xml
@@ -0,0 +1,6 @@
+<aspectj>
+ <weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder -verbose"/>
+ <aspects>
+ <aspect name="ataspectj.ltwlog.Aspect1"/>
+ </aspects>
+</aspectj> \ No newline at end of file
diff --git a/tests/java5/ataspectj/ataspectj/ltwlog/aop-verboseandshow.xml b/tests/java5/ataspectj/ataspectj/ltwlog/aop-verboseandshow.xml
new file mode 100644
index 000000000..11ace2a93
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ltwlog/aop-verboseandshow.xml
@@ -0,0 +1,6 @@
+<aspectj>
+ <weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder -showWeaveInfo -verbose"/>
+ <aspects>
+ <aspect name="ataspectj.ltwlog.Aspect1"/>
+ </aspects>
+</aspectj> \ No newline at end of file
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
index 5b8a25982..e414c63b4 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
@@ -74,4 +74,8 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {
runTest("Ajc Aspect1 LTW Aspect2 -Xreweavable");
}
+ public void testLTWLog() {
+ runTest("LTW Log");
+ }
+
}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
index 7749ae32b..af74f5b81 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
@@ -93,5 +93,10 @@
outjar="main1.jar"/>
<ant file="ajc-ant.xml" target="ltw.Aspect2MainTest" verbose="true"/>
</ajc-test>
-
+
+ <ajc-test dir="java5/ataspectj" title="LTW Log">
+ <ant file="ajc-ant.xml" target="ltwlog.LTWLog" verbose="true"/>
+ </ajc-test>
+
+
</suite> \ No newline at end of file