]> source.dussan.org Git - aspectj.git/commitdiff
Bug 150271 "Allow multiple levels of LTW information" (make weaving/not weaving messa...
authormwebster <mwebster>
Wed, 23 Aug 2006 11:52:22 +0000 (11:52 +0000)
committermwebster <mwebster>
Wed, 23 Aug 2006 11:52:22 +0000 (11:52 +0000)
17 files changed:
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
loadtime/src/org/aspectj/weaver/loadtime/DefaultMessageHandler.java
loadtime/src/org/aspectj/weaver/loadtime/Options.java
tests/java5/ataspectj/ajc-ant.xml
tests/java5/ataspectj/ataspectj/TestHelper.java
tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml
tests/java5/ataspectj/ataspectj/ltwlog/aop-verbose.xml
tests/java5/ataspectj/ataspectj/ltwlog/aop-verboseandshow.xml
tests/ltw/aop-defineaspect.xml
tests/ltw/aop-emptytests.xml
tests/ltw/aop-nomatch.xml
tests/ltw/aop-nomatchxlint.xml
tests/ltw/aop-nomatchxlintfile.xml
tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml
tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java

index d43034c90e20f09b3afbd6d00da3ed8e1bd08ee7..20d57f3e7decc1b26020bd5274f1157a3d08f172 100644 (file)
@@ -673,7 +673,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
        private void defineClass(ClassLoader loader, String name, byte[] bytes) {
        if (trace.isTraceEnabled()) trace.enter("defineClass",this,new Object[] {loader,name,bytes});
        Object clazz = null;
-               info("generating class '" + name + "'");
+               debug("generating class '" + name + "'");
                
                try {
                        //TODO av protection domain, and optimize
index 80d6e23e3c82bc13964c5e6c25d3cf2b87e4419d..c9b4a6d9f568dcc43d2f1576d0f42f2773d6314f 100644 (file)
@@ -21,6 +21,7 @@ import org.aspectj.bridge.AbortException;
 public class DefaultMessageHandler implements IMessageHandler {
 
     boolean isVerbose = false;
+    boolean isDebug = false;
     boolean showWeaveInfo = false;
     boolean showWarn = true;
 
@@ -43,6 +44,9 @@ public class DefaultMessageHandler implements IMessageHandler {
         if (kind.isSameOrLessThan(IMessage.INFO)) {
             return !isVerbose;
         }
+        if (kind.isSameOrLessThan(IMessage.DEBUG)) {
+            return !isDebug;
+        }
         return !showWarn;
     }
 
index 67265343fe8baa21a2d1bda4cc2347e807fd587d..be01cb7ec49344896ecb5faa4fbf896c1bcb524c 100644 (file)
@@ -35,6 +35,7 @@ public class Options {
     private final static String OPTION_noWarnNone = "-warn:none";
     private final static String OPTION_proceedOnError = "-proceedOnError";
     private final static String OPTION_verbose = "-verbose";
+    private final static String OPTION_debug = "-debug";
     private final static String OPTION_reweavable = "-Xreweavable";//notReweavable is default for LTW
     private final static String OPTION_noinline = "-Xnoinline";
     private final static String OPTION_addSerialVersionUID = "-XaddSerialVersionUID";
@@ -106,6 +107,8 @@ public class Options {
                weaverOption.optionalJoinpoints = arg.substring(OPTIONVALUED_joinpoints.length()).trim();
             }  else if (arg.equalsIgnoreCase(OPTION_verbose)) {
                 weaverOption.verbose = true;
+            }  else if (arg.equalsIgnoreCase(OPTION_debug)) {
+                weaverOption.debug = true;
             } else if (arg.equalsIgnoreCase(OPTION_pinpoint)) {
                 weaverOption.pinpoint = true;
             } else if (arg.startsWith(OPTIONVALUED_messageHandler)) {
@@ -141,6 +144,9 @@ public class Options {
         if (weaverOption.verbose) {
             weaverOption.messageHandler.dontIgnore(IMessage.INFO);
         }
+        if (weaverOption.debug) {
+            weaverOption.messageHandler.dontIgnore(IMessage.DEBUG);
+        }
         if (weaverOption.showWeaveInfo) {
             weaverOption.messageHandler.dontIgnore(IMessage.WEAVEINFO);
         }
@@ -156,6 +162,7 @@ public class Options {
         boolean noWarn;
         boolean proceedOnError;
         boolean verbose;
+        boolean debug;
         boolean notReWeavable = true;//default to notReweavable for LTW (faster)
         boolean noInline;
         boolean addSerialVersionUID;
index 8dccebac7e1711c4f0ac7b3de0ae4658c48351df..12df7d64c39d81260b05adb4dafa7f140d14f59d 100644 (file)
@@ -1,11 +1,13 @@
 <!-- ajc-ant script, not to be used from Ant commant line - see AntSpec -->
-<project name="ltw" default="javac.ltw">
+<project name="ltw" default="RunThemAllWithJavacCompiledAndLTW">
 
     <!-- using this we can debug the forked VM -->
     <property
         name="jdwp"
         value="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/>
 
+    <target name="RunThemAllWithJavacCompiledAndLTW" depends="compile:javac, ltw"/>
+
     <target name="compile:javac">
         <!-- compile only javac compilable stuff, exclude the one that needs other dependencies -->
         <javac destdir="${aj.sandbox}" classpathref="aj.path"
@@ -68,8 +70,6 @@
         </java>
     </target>
 
-    <target name="javac.ltw" depends="compile:javac, ltw"/>
-
     <target name="ltw.Aspect2MainTest">
         <!-- javac Aspect2 -->
         <javac destdir="${aj.sandbox}" classpathref="aj.path"
         </java>
     </target>
 
-    <target name="ltw.oldAspectsDeclared">
+    <target name="Compile time aspects declared to ltw weaver">
         <!--Aspects woven at compile time must be declared in an aop.xml file.
         If they are not declared, then they will be lost during reweaving-->
 
index 378f5936dda0e2a12b6a645b80808b8b0bcdcd9d..f53956193013e0061c0381db9e482a01b6e3080f 100644 (file)
@@ -57,9 +57,9 @@ public class TestHelper extends DefaultMessageHandler {
 
     public boolean handleMessage(IMessage message) throws AbortException {
         boolean ret = super.handleMessage(message);
-        if (message.getKind().isSameOrLessThan(IMessage.INFO)) {
-            ;
-        else {
+        if (message.getKind().isSameOrLessThan(IMessage.INFO));
+        if (message.getKind().isSameOrLessThan(IMessage.DEBUG));
+        else {
             // we do exit here since Assert.fail will only trigger a runtime exception that might
             // be catched by the weaver anyway
             System.err.println("*** Exiting - got a warning/fail/error/abort IMessage");
index 8f0ef772d3db055ac33cc653c142935b50eef3f2..cf94484e7d5f7cacd6d262d4a62374dfd7b2b21b 100644 (file)
@@ -3,7 +3,7 @@
        <aspects>
                <aspect name="ataspectj.EmptyAspect"/>
        </aspects>
-    <weaver options="-XlazyTjp -verbose">
+    <weaver options="-XlazyTjp -verbose -debug">
         <dump within="com.foo.bar..*" beforeandafter="true"/> 
         <include within="com.foo..*"/>
         <exclude within="com.foo.bar..*CGLIB*"/>
index 7cd1b4629d299617e2f61bb71a6a50981ddcc191..edaa71777925cfe4f83d134a9d387cc9c511c93d 100644 (file)
@@ -1,5 +1,5 @@
 <aspectj>
-    <weaver options="-verbose"/>
+    <weaver options="-verbose -debug"/>
     <aspects>
         <aspect name="ataspectj.ltwlog.Aspect1"/>
     </aspects>
index 557ad27a502b735dc7fc22a5aba029e946a7c987..8f1d70406c5bdf12c9c45b7d4566ed878a53ba81 100644 (file)
@@ -1,5 +1,5 @@
 <aspectj>
-    <weaver options="-showWeaveInfo -verbose"/>
+    <weaver options="-showWeaveInfo -verbose -debug"/>
     <aspects>
         <aspect name="ataspectj.ltwlog.Aspect1"/>
     </aspects>
index f40bff2c453462cfc6767b6974c9668d6669997d..2fe76caa5987adf1c31cdc84ea8974e3c65b0b5b 100644 (file)
@@ -4,6 +4,6 @@
                        <pointcut name="scope" expression="within(Main)"/>
         </concrete-aspect>
        </aspects>
-       <weaver options="-verbose"/>
+       <weaver options="-verbose -debug"/>
 </aspectj>
        
index da7bd5e2ab8a1a0791e053706bdffa1c88d5cc68..f686bb484627a9501f99621f40dd372610c57b62 100644 (file)
@@ -2,7 +2,7 @@
        <aspects>
                <aspect name="EmptyAspect"/>
        </aspects>
-       <weaver options="-verbose">
+       <weaver options="-verbose -debug">
                <include within="*1"/>
        </weaver>
 </aspectj>
\ No newline at end of file
index 620a4c77e8ec55beb4cf5aa2124e23437d724ce4..ac82b6014d765c20bba87e63e79ae4f0075195f9 100644 (file)
@@ -3,5 +3,5 @@
            <aspect name="Aspect3"/>
        </aspects>
     
-    <weaver options="-verbose -showWeaveInfo"/>
+    <weaver options="-verbose -debug -showWeaveInfo"/>
 </aspectj>
index 4271e394dbf6d344741c9c6158ee42a796fcbff4..46c38ca75e86a4dbc86516b37bf87dbcda959665 100644 (file)
@@ -3,5 +3,5 @@
            <aspect name="Aspect3"/>
        </aspects>
     
-    <weaver options="-verbose -showWeaveInfo -Xlint:warning"/>
+    <weaver options="-verbose -debug -showWeaveInfo -Xlint:warning"/>
 </aspectj>
index 35ce126e3fc7634dee0584aa624cfbd2ab8719c8..1bfabf16994521d4a769e27a0358a7ec72bfb8c3 100644 (file)
@@ -3,5 +3,5 @@
            <aspect name="Aspect3"/>
        </aspects>
     
-    <weaver options="-verbose -showWeaveInfo -Xlintfile:Xlint-nomatch.properties"/>
+    <weaver options="-verbose -debug -showWeaveInfo -Xlintfile:Xlint-nomatch.properties"/>
 </aspectj>
index a74d17edebef6ae425eb93a3b7c62258df67421f..a27ecd482c2bff30a445cef0ec1b6eb494d84e6c 100644 (file)
@@ -2,7 +2,7 @@
 <suite>
 
     <ajc-test dir="java5/ataspectj" title="RunThemAllWithJavacCompiledAndLTW">
-        <ant file="ajc-ant.xml" target="javac.ltw" verbose="true"/>
+        <ant file="ajc-ant.xml" target="RunThemAllWithJavacCompiledAndLTW" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="AjcLTW PerClauseTest -XterminateAfterCompilation">
                 <line text="info register classloader"/>
                 <line text="info using"/>
                                <line text="info register aspect ataspectj.EmptyAspect"/>
-                       <line text="info not weaving 'com.foo.bar.Test$$EnhancerByCGLIB$$12345'"/>
-                       <line text="info weaving 'com.foo.bar.Test'"/>
+                       <line text="debug not weaving 'com.foo.bar.Test$$EnhancerByCGLIB$$12345'"/>
+                       <line text="debug weaving 'com.foo.bar.Test'"/>
             </stderr>
         </run>
     </ajc-test>
                 <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="debug weaving 'ataspectj.ltwlog.Main'"/>
+                               <line text="debug weaving 'ataspectj.ltwlog.Aspect1'"/>
             </stderr>
         </run>
     </ajc-test>
                 <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="debug 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)"/>
-                               <line text="info weaving 'ataspectj.ltwlog.Aspect1'"/>
+                               <line text="debug weaving 'ataspectj.ltwlog.Aspect1'"/>
             </stderr>
         </run>
     </ajc-test>
                 files="ataspectj/ltwlog/MessageHolder.java,ataspectj/ltwreweavable/MainReweavableLogging.java,ataspectj/ltwreweavable/AspectReweavableLogging.java,ataspectj/ltwreweavable/Advisable.java,ataspectj/ltwreweavable/EmptyAtAspect.java"
                 options="-1.5"
                 outjar="main1.jar"/>
-        <ant file="ajc-ant.xml" target="ltw.oldAspectsDeclared" verbose="true"/>
+        <ant file="ajc-ant.xml" target="Compile time aspects declared to ltw weaver" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="Concrete@Aspect">
index 14bf511c5b1ccbd3919b05d8b7726f63b649278a..816ff27b26f26679747140639f2f97211bdd1857 100644 (file)
@@ -6,7 +6,7 @@
         <compile
                files="Main.java, Aspect1.aj"
                        outjar="main1.jar"
-            options="-showWeaveInfo"
+            options="-showWeaveInfo -verbose"
         >
                <message kind="weave" text="method-execution(void Main.test1())' in Type 'Main' (Main.java:17) advised by before advice from 'Aspect1' (Aspect1.aj:16)"/>
         </compile>     
@@ -14,7 +14,7 @@
                classpath="main1.jar"
                files="Aspect2.aj"
                outjar="aspect2.jar"
-            options="-showWeaveInfo"
+            options="-showWeaveInfo -verbose"
         >
         </compile>     
         <run class="Main" ltw="aop-ltwreweavable.xml">
                 <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="debug generating class 'ConcreteAspect'"/>
+                <line text="debug weaving 'Main'"/>
                 <line text="AbstractSuperAspect.before_test1"/>
             </stderr>
         </run>
                 <line text="info register classloader"/>
                 <line text="info using"/>
                        <line text="info register aspect Aspect3"/>
-                       <line text="info weaving 'Main'"/>
+                       <line text="debug weaving 'Main'"/>
                </stderr>
         </run>
     </ajc-test>
                 <line text="info using"/>
                        <line text="info register aspect Aspect3"/>
                        <line text="can not build thisJoinPoint lazily for this advice"/>
-                       <line text="info weaving 'Main'"/>
+                       <line text="debug weaving 'Main'"/>
                </stderr>
         </run>
     </ajc-test>
                 <line text="info using"/>
                        <line text="info register aspect Aspect3"/>
                        <line text="can not build thisJoinPoint lazily for this advice"/>
-                       <line text="info weaving 'Main'"/>
+                       <line text="debug weaving 'Main'"/>
                </stderr>
         </run>
     </ajc-test>
                 <line text="info using"/>
                        <line text="info register aspect Aspect3"/>
                        <line text="can not build thisJoinPoint lazily for this advice"/>
-                       <line text="info weaving 'Main'"/>
+                       <line text="debug weaving 'Main'"/>
                </stderr>
         </run>
     </ajc-test>
index 39bb0146aefa4060307a0ab4807128a3e8ba9764..812d15830739931666833f4833d19ea7da5b44ff 100644 (file)
                        <line text="info register classloader org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
                        <line text="info using configuration"/>
                        <line text="info register aspect EmptyAspect"/>
-          <line text="info weaving"/>
-          <line text="info not weaving"/>
+                       <line text="debug weaving"/>
+            <line text="debug not weaving"/>
         </stderr>
       </run>
     </ajc-test>
index 3d80b9901be070ee86c24966c9baa38be17582b6..b1adcfb8f050eee76fad577d6ef365a36c6dad0f 100644 (file)
@@ -233,17 +233,17 @@ public class WeavingAdaptor implements IMessageContext {
                                    // a valid aspectOf()/hasAspect() generated in them.  However - if they are excluded
                                    // (via include/exclude in aop.xml) they really should only get aspectOf()/hasAspect()
                                    // and not be included in the full set of aspects being applied by 'this' weaver
-                                               info("weaving '" + name + "'");
+                                               debug("weaving '" + name + "'");
                                                bytes = getWovenBytes(name, bytes);
                                        } else if (shouldWeaveAnnotationStyleAspect(name, bytes)) {
                                    // an @AspectJ aspect needs to be at least munged by the aspectOf munger
-                                   info("weaving '" + name + "'");
+                                   debug("weaving '" + name + "'");
                                    bytes = getAtAspectJAspectBytes(name, bytes);
                                        } else {
-                                               info("not weaving '" + name + "'");
+                                               debug("not weaving '" + name + "'");
                                        }
                        } else {
-                                       info("cannot weave '" + name + "'");
+                                       debug("cannot weave '" + name + "'");
                                }
        
                                if (trace.isTraceEnabled()) trace.exit("weaveClass",bytes);
@@ -392,6 +392,10 @@ public class WeavingAdaptor implements IMessageContext {
                return ret;
        }
        
+       protected boolean debug (String message) {
+               return MessageUtil.debug(messageHandler,message);
+       }
+       
        protected boolean info (String message) {
                return MessageUtil.info(messageHandler,message);
        }
@@ -542,6 +546,7 @@ public class WeavingAdaptor implements IMessageContext {
                        super(writer,true);
                        
                        ignore(IMessage.WEAVEINFO);
+            ignore(IMessage.DEBUG);
             ignore(IMessage.INFO);
                        this.failKind = IMessage.ERROR;
                }