From: aclement Date: Mon, 19 Dec 2005 21:20:03 +0000 (+0000) Subject: matthews message accumulation changes for ltw X-Git-Tag: POST_MEMORY_CHANGES~206 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=10b88f0c2342124f35425a8c3cac54fad32fa8aa;p=aspectj.git matthews message accumulation changes for ltw --- diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 35a568858..9c888fccf 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -105,7 +105,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { } bcelWorld = new BcelWorld( - loader, messageHandler, new ICrossReferenceHandler() { + loader, getMessageHandler(), new ICrossReferenceHandler() { public void addCrossReference(ISourceLocation from, ISourceLocation to, IRelationship.Kind kind, boolean runtimeTest) { ;// for tools only } @@ -121,7 +121,6 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { // register the definitions registerDefinitions(weaver, loader, definitions); - messageHandler = bcelWorld.getMessageHandler(); //bcelWorld.setResolutionLoader(loader.getParent());//(ClassLoader)null);// @@ -207,12 +206,12 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { allOptions.append(definition.getWeaverOptions()).append(' '); } - Options.WeaverOption weaverOption = Options.parse(allOptions.toString(), loader, messageHandler); + Options.WeaverOption weaverOption = Options.parse(allOptions.toString(), loader, getMessageHandler()); // configure the weaver and world // AV - code duplicates AspectJBuilder.initWorldAndWeaver() World world = weaver.getWorld(); - world.setMessageHandler(weaverOption.messageHandler); + setMessageHandler(weaverOption.messageHandler); world.setXlazyTjp(weaverOption.lazyTjp); world.setXHasMemberSupportEnabled(weaverOption.hasMember); world.setPinpointMode(weaverOption.pinpoint); diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml index 6cf87b52c..d355d866f 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml @@ -103,6 +103,9 @@ + + + @@ -164,6 +167,9 @@ + + + @@ -186,6 +192,9 @@ + + + diff --git a/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml b/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml index 94f16616a..8e6233fca 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml @@ -133,6 +133,9 @@ + + + @@ -259,6 +262,9 @@ + + + @@ -278,6 +284,9 @@ + + + @@ -298,6 +307,9 @@ + + + @@ -318,6 +330,9 @@ + + + diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java index e47022a9a..2934e6c6f 100644 --- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -69,9 +69,10 @@ public class WeavingAdaptor { protected boolean enabled = true; protected boolean verbose = getVerbose(); - protected BcelWorld bcelWorld = null; - protected BcelWeaver weaver = null; - protected IMessageHandler/*WeavingAdaptorMessageHandler*/ messageHandler = null; + protected BcelWorld bcelWorld; + protected BcelWeaver weaver; + private IMessageHandler messageHandler; + private WeavingAdaptorMessageHandler messageHolder; protected GeneratedClassHandler generatedClassHandler; protected Map generatedClasses = new HashMap(); /* String -> UnwovenClassFile */ @@ -159,14 +160,27 @@ public class WeavingAdaptor { registerAspectLibraries(aspectPath); } - private void createMessageHandler() { - messageHandler = new WeavingAdaptorMessageHandler(new PrintWriter(System.err)); + messageHolder = new WeavingAdaptorMessageHandler(new PrintWriter(System.err)); + messageHandler = messageHolder; if (verbose) messageHandler.dontIgnore(IMessage.INFO); if (Boolean.getBoolean(SHOW_WEAVE_INFO_PROPERTY)) messageHandler.dontIgnore(IMessage.WEAVEINFO); info("AspectJ Weaver Version " + Version.text + " built on " + Version.time_text); //$NON-NLS-1$ } + protected IMessageHandler getMessageHandler () { + return messageHandler; + } + + protected void setMessageHandler (IMessageHandler mh) { + if (messageHolder != null) { + messageHolder.flushMessages(); + messageHolder = null; + } + messageHandler = mh; + bcelWorld.setMessageHandler(mh); + } + /** * Appends URL to path used by the WeavingAdptor to resolve classes * @param url to be appended to search path @@ -381,6 +395,8 @@ public class WeavingAdaptor { private Set ignoring = new HashSet(); private IMessage.Kind failKind; + private boolean accumulating = true; + private List messages = new ArrayList(); public WeavingAdaptorMessageHandler (PrintWriter writer) { super(writer,true); @@ -388,10 +404,10 @@ public class WeavingAdaptor { ignore(IMessage.WEAVEINFO); ignore(IMessage.INFO); this.failKind = IMessage.ERROR; - } public boolean handleMessage(IMessage message) throws AbortException { + addMessage(message); boolean result = super.handleMessage(message); if (0 <= message.getKind().compareTo(failKind)) { throw new AbortException(message); @@ -418,8 +434,24 @@ public class WeavingAdaptor { public void dontIgnore (IMessage.Kind kind) { if (null != kind) { ignoring.remove(kind); + if (kind.equals(IMessage.INFO)) accumulating = false; + } + } + + private void addMessage (IMessage message) { + if (accumulating && isIgnoring(message.getKind())) { + messages.add(message); } } + + public void flushMessages () { + for (Iterator iter = messages.iterator(); iter.hasNext();) { + IMessage message = (IMessage)iter.next(); + super.handleMessage(message); + } + accumulating = false; + messages.clear(); + } } private class WeavingClassFileProvider implements IClassFileProvider {