From cea5fc1169f1052878f40da0bdc24fd02b02258a Mon Sep 17 00:00:00 2001 From: wisberg Date: Fri, 4 Nov 2005 09:02:09 +0000 Subject: bug 102479 example for getting messages from ajc programmatically --- docs/devGuideDB/ajc.xml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'docs/devGuideDB/ajc.xml') 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. To access compiler messages programmatically, use the methods setHolder(IMessageHolder holder) and/or run(String[] args, IMessageHolder holder). + ajc reports each message to the holder + using IMessageHolder.handleMessage(..). + If you just want to collect the messages, use + MessageHandler as your + IMessageHolder. + For example, compile and run the following with + aspectjtools.jar on the classpath: - + +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)); + } +} + -- cgit v1.2.3