aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorwisberg <wisberg>2005-11-04 09:02:09 +0000
committerwisberg <wisberg>2005-11-04 09:02:09 +0000
commitcea5fc1169f1052878f40da0bdc24fd02b02258a (patch)
treee5ac95a8ccf2391394de2393f478bd284da8b8e1 /docs
parent7d4cb8192230085a1b7ea8015a0379198d55e3ab (diff)
downloadaspectj-cea5fc1169f1052878f40da0bdc24fd02b02258a.tar.gz
aspectj-cea5fc1169f1052878f40da0bdc24fd02b02258a.zip
bug 102479 example for getting messages from ajc programmatically
Diffstat (limited to 'docs')
-rw-r--r--docs/devGuideDB/ajc.xml23
1 files changed, 22 insertions, 1 deletions
diff --git a/docs/devGuideDB/ajc.xml b/docs/devGuideDB/ajc.xml
index 95b096649..ea2cab2da 100644
--- a/docs/devGuideDB/ajc.xml
+++ b/docs/devGuideDB/ajc.xml
@@ -652,8 +652,29 @@ commands to your environment as needed.
<para>To access compiler messages programmatically, use the methods
<literal>setHolder(IMessageHolder holder)</literal> and/or
<literal>run(String[] args, IMessageHolder holder)</literal>.
+ <literal>ajc</literal> reports each message to the holder
+ using <literal>IMessageHolder.handleMessage(..)</literal>.
+ If you just want to collect the messages, use
+ <literal>MessageHandler</literal> as your
+ <literal>IMessageHolder</literal>.
+ For example, compile and run the following with
+ <literal>aspectjtools.jar</literal> on the classpath:
</para>
-
+ <programlisting>
+import org.aspectj.bridge.*;
+import org.aspectj.tools.ajc.Main;
+import java.util.Arrays;
+
+public class WrapAjc {
+ public static void main(String[] args) {
+ Main compiler = new Main();
+ MessageHandler m = new MessageHandler();
+ compiler.run(args, m);
+ IMessage[] ms = m.getMessages(null, true);
+ System.out.println("messages: " + Arrays.asList(ms));
+ }
+}
+ </programlisting>
</refsect2>
<refsect2>