]> source.dussan.org Git - aspectj.git/commitdiff
merging changes from head for LTW.
authoracolyer <acolyer>
Mon, 19 Dec 2005 21:56:13 +0000 (21:56 +0000)
committeracolyer <acolyer>
Mon, 19 Dec 2005 21:56:13 +0000 (21:56 +0000)
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml
weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java

index 35a5688581cb4eed131eae3073ce20f83e9ad7d4..9c888fccf206a5e8ee90d92af066c7dc24b02de4 100644 (file)
@@ -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);
index 6cf87b52c6d11ecc35209a2ccf2f3d719048d715..d355d866fd17c3116596df24b9a2a28e6d07b747 100644 (file)
                        <line text="Test.main()"/>
             </stdout>
                <stderr>
+                <line text="info AspectJ Weaver Version"/>
+                <line text="info register classloader"/>
+                <line text="info using"/>
                        <line text="info weaving 'com.foo.bar.Test'"/>
             </stderr>
         </run>
                                <line text="execution(Main.target())"/>
             </stdout>
                <stderr>
+                <line text="info AspectJ Weaver Version"/>
+                <line text="info register classloader"/>
+                <line text="info using"/>
                                <line text="info register aspect ataspectj.ltwlog.Aspect1"/>
                                <line text="info weaving 'ataspectj.ltwlog.Main'"/>
                                <line text="info weaving 'ataspectj.ltwlog.Aspect1'"/>
                                <line text="execution(Main.target())"/>
             </stdout>
                <stderr>
+                <line text="info AspectJ Weaver Version"/>
+                <line text="info register classloader"/>
+                <line text="info using"/>
                                <line text="info register aspect ataspectj.ltwlog.Aspect1"/>
                                <line text="info weaving 'ataspectj.ltwlog.Main'"/>
                                <line text="weaveinfo Join point 'method-execution(void ataspectj.ltwlog.Main.target())' in Type 'ataspectj.ltwlog.Main' (Main.java:22) advised by before advice from 'ataspectj.ltwlog.Aspect1' (Aspect1.java)"/>
index 94f16616ada0a8b4b77b61bad9208fea1ca564b4..8e6233fca4251d29a5f3bf9291cb2c0d682defb4 100644 (file)
                 <line text="Main.test2"/>
             </stdout>
                <stderr>
+                <line text="info AspectJ Weaver Version"/>
+                <line text="info register classloader"/>
+                <line text="info using"/>
                 <line text="info generating class 'ConcreteAspect'"/>
                 <line text="info weaving 'Main'"/>
                 <line text="AbstractSuperAspect.before_test1"/>
         </compile>     
         <run class="Main" ltw="aop-nomatch.xml">
                <stderr>
+                <line text="info AspectJ Weaver Version"/>
+                <line text="info register classloader"/>
+                <line text="info using"/>
                        <line text="info register aspect Aspect3"/>
                        <line text="info weaving 'Main'"/>
                </stderr>
         </compile>     
         <run class="Main" ltw="aop-nomatchxlintfile.xml" xlintfile="Xlint-nomatch.properties">
                <stderr>
+                <line text="info AspectJ Weaver Version"/>
+                <line text="info register classloader"/>
+                <line text="info using"/>
                        <line text="info register aspect Aspect3"/>
                        <line text="info weaving 'Main'"/>
                        <line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
         </compile>     
         <run class="Main" ltw="aop-nomatchxlint.xml">
                <stderr>
+                <line text="info AspectJ Weaver Version"/>
+                <line text="info register classloader"/>
+                <line text="info using"/>
                        <line text="info register aspect Aspect3"/>
                        <line text="info weaving 'Main'"/>
                        <line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
         </compile>     
         <run class="Main" ltw="aop-nomatchxlint.xml">
                <stderr>
+                <line text="info AspectJ Weaver Version"/>
+                <line text="info register classloader"/>
+                <line text="info using"/>
                        <line text="info register aspect Aspect3"/>
                        <line text="info weaving 'Main'"/>
                        <line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
index e47022a9a709627006cda9c272d01d849c32e644..2934e6c6ff11611a8a46a0b94423ee39631d9c01 100644 (file)
@@ -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 {