]> source.dussan.org Git - aspectj.git/commitdiff
Matthews patches from 95529
authoraclement <aclement>
Fri, 11 Nov 2005 13:51:57 +0000 (13:51 +0000)
committeraclement <aclement>
Fri, 11 Nov 2005 13:51:57 +0000 (13:51 +0000)
18 files changed:
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
loadtime/src/org/aspectj/weaver/loadtime/DefaultWeavingContext.java
loadtime/src/org/aspectj/weaver/loadtime/IWeavingContext.java
loadtime/src/org/aspectj/weaver/loadtime/Options.java
loadtime/src/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java
loadtime/testsrc/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java
org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java
testing/newsrc/org/aspectj/testing/RunSpec.java
tests/ltw/AbstractAspect.aj [new file with mode: 0644]
tests/ltw/AbstractSuperAspect.aj [new file with mode: 0644]
tests/ltw/Main.java
tests/ltw/TestITDMethod.java [new file with mode: 0644]
tests/ltw/TestMain.java [new file with mode: 0644]
tests/ltw/aop-abstractaspect.xml [new file with mode: 0644]
tests/ltw/aop-defineaspect.xml [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java
tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml
weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java

index dca1baab9c25f17022fdc1b82999c8a8768bdceb..3ca6d69cfed48281f670d5dfb17ba980abb6eecb 100644 (file)
@@ -66,7 +66,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
     private IWeavingContext weavingContext;
 
     public ClassLoaderWeavingAdaptor(final ClassLoader loader, IWeavingContext wContext) {
-        super(null);
+       this.weavingContext = wContext;
     }
 
     void initialize(final ClassLoader loader, IWeavingContext wContext) {
@@ -132,7 +132,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
      */
     private void registerDefinitions(final BcelWeaver weaver, final ClassLoader loader) {
         try {
-            MessageUtil.info(messageHandler, "register classloader " + ((loader!=null)?loader.getClass().getName()+"@"+loader.hashCode():"null"));
+            MessageUtil.info(messageHandler, "register classloader " + getClassLoaderName(loader));
             //TODO av underoptimized: we will parse each XML once per CL that see it
             List definitions = new ArrayList();
 
@@ -172,6 +172,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
                 registerDump(weaver, loader, definitions);
             } else {
                 enabled = false;// will allow very fast skip in shouldWeave()
+                       info("no configuration found. Disabling weaver for class loader " + getClassLoaderName(loader));
             }
         } catch (Exception e) {
             weaver.getWorld().getMessageHandler().handleMessage(
@@ -180,6 +181,10 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
         }
     }
 
+    private String getClassLoaderName (ClassLoader loader) {
+       return weavingContext.getClassLoaderName();
+       }
+    
     /**
      * Configure the weaver according to the option directives
      * TODO av - don't know if it is that good to reuse, since we only allow a small subset of options in LTW
@@ -195,7 +200,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
             allOptions.append(definition.getWeaverOptions()).append(' ');
         }
 
-        Options.WeaverOption weaverOption = Options.parse(allOptions.toString(), loader);
+        Options.WeaverOption weaverOption = Options.parse(allOptions.toString(), loader, messageHandler);
 
         // configure the weaver and world
         // AV - code duplicates AspectJBuilder.initWorldAndWeaver()
@@ -297,13 +302,9 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
             for (Iterator aspects = definition.getAspectClassNames().iterator(); aspects.hasNext();) {
                 String aspectClassName = (String) aspects.next();
                 if (acceptAspect(aspectClassName)) {
+                       info("register aspect " + aspectClassName);
                     ResolvedType aspect = weaver.addLibraryAspect(aspectClassName);
-                    if (aspect.isAbstract()) {
-                        // this is a warning
-                        weaver.getWorld().getMessageHandler().handleMessage(
-                                new Message("Abstract aspect registered in aop.xml, use a <concrete-aspect> element instead", IMessage.WARNING, null, null)
-                        );
-                    }
+
                     //generate key for SC
                     if(namespace==null){
                        namespace=new StringBuffer(aspectClassName);
@@ -323,9 +324,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
                 if (acceptAspect(concreteAspect.name)) {
                     ConcreteAspectCodeGen gen = new ConcreteAspectCodeGen(concreteAspect, weaver.getWorld());
                     if (!gen.validate()) {
-                        weaver.getWorld().getMessageHandler().handleMessage(
-                                new Message("Concrete-aspect '"+concreteAspect.name+"' could not be registered", IMessage.ERROR, null, null)
-                        );
+                        error("Concrete-aspect '"+concreteAspect.name+"' could not be registered");
                         break;
                     }
                     this.generatedClassHandler.acceptClass(
index 7110e0c544fc8c090e0b86c71a87e571740cdfae..092eddb7e317f4c4996c65f6cc854c1c13934227 100644 (file)
@@ -22,7 +22,7 @@ import java.util.Enumeration;
  */
 public class DefaultWeavingContext implements IWeavingContext {
        
-       private ClassLoader loader;
+       protected ClassLoader loader;
        
        public DefaultWeavingContext(){
                loader = getClass().getClassLoader();
@@ -51,4 +51,11 @@ public class DefaultWeavingContext implements IWeavingContext {
                return null;
        }
 
+       /**
+        * @return classname@hashcode
+        */
+       public String getClassLoaderName() {
+       return ((loader!=null)?loader.getClass().getName()+"@"+loader.hashCode():"null");
+       }
+
 }
index 285fc81dc9eb542d1ad138c1c3d4601d8679603c..f634cabc0b8c5367726a45ea8a9ed645394cad01 100644 (file)
@@ -41,5 +41,12 @@ public interface IWeavingContext {
         * @return
         */
        public String getBundleIdFromURL(URL url);
+       
+       /**
+        * In an environment with multiple class loaders allows each to be
+        * identified using something safer and than toString
+        * @return name of the associated class loader
+        */
+       public String getClassLoaderName ();
 
 }
index 5bc469470345d408cad18fcbe252f334592e47bf..d96f45cb134850f83194c1724d165269eb3ffd15 100644 (file)
@@ -45,16 +45,16 @@ public class Options {
     private static final String OPTIONVALUED_Xlint = "-Xlint:";
 
 
-    public static WeaverOption parse(String options, ClassLoader laoder) {
+    public static WeaverOption parse(String options, ClassLoader laoder, IMessageHandler imh) {
+        WeaverOption weaverOption = new WeaverOption(imh);
+
         if (LangUtil.isEmpty(options)) {
-            return new WeaverOption();
+            return weaverOption;
         }
         // the first option wins
         List flags = LangUtil.anySplit(options, " ");
         Collections.reverse(flags);
 
-        WeaverOption weaverOption = new WeaverOption();
-
         // do a first round on the message handler since it will report the options themselves
         for (Iterator iterator = flags.iterator(); iterator.hasNext();) {
             String arg = (String) iterator.next();
@@ -152,8 +152,9 @@ public class Options {
         String lint;
         String lintFile;
 
-        public WeaverOption() {
-            messageHandler = new DefaultMessageHandler();//default
+        public WeaverOption(IMessageHandler imh) {
+//            messageHandler = new DefaultMessageHandler();//default
+            this.messageHandler = imh;
         }
     }
 }
index 8c7035b5e016c039412a9181c54223c6307de844..4fe476eb16374f447c5ec09b7c18fbc4d706cf02 100644 (file)
@@ -34,7 +34,8 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
        public static final String WEAVING_ASPECT_PATH = "aj.aspect.path"; 
        
        private URL[] aspectURLs;
-       private WeavingAdaptor adaptor; 
+       private WeavingAdaptor adaptor;
+       private boolean initializingAdaptor;
        private Map generatedClasses = new HashMap(); /* String -> byte[] */ 
 
        /*
@@ -99,15 +100,30 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
         */
        protected Class defineClass(String name, byte[] b, CodeSource cs) throws IOException {
 //             System.err.println("? WeavingURLClassLoader.defineClass(" + name + ", [" + b.length + "])");
-               
-               /* Need to defer creation because of possible recursion during constructor execution */
-               if (adaptor == null) {
-                       ClassLoaderWeavingAdaptor clwAdaptor = new ClassLoaderWeavingAdaptor(this,null);
-                       clwAdaptor.initialize(this,null);
-                       adaptor = clwAdaptor;
+
+               /* Avoid recursion during adaptor initialization */
+               if (!initializingAdaptor) {
+                       
+                       /* Need to defer creation because of possible recursion during constructor execution */
+                       if (adaptor == null && !initializingAdaptor) {
+                               DefaultWeavingContext weavingContext = new DefaultWeavingContext (this) {
+
+                                       /* Ensures consistent LTW messages for testing */
+                                       public String getClassLoaderName() {
+                                               return loader.getClass().getName();
+                                       }
+                                       
+                               };
+                               
+                               ClassLoaderWeavingAdaptor clwAdaptor = new ClassLoaderWeavingAdaptor(this,weavingContext);
+                               initializingAdaptor = true;
+                               clwAdaptor.initialize(this,weavingContext);
+                               initializingAdaptor = false;
+                               adaptor = clwAdaptor;
+                       }
+                       
+                       b = adaptor.weaveClass(name,b);
                }
-               
-               b = adaptor.weaveClass(name,b);
                return super.defineClass(name, b, cs);
        }
 
index fe31393140b68da844db191f9ca88960187ed6e4..093a0125a481773a9a0a19e34e1a54fbc4016595 100644 (file)
@@ -69,6 +69,11 @@ public class WeavingURLClassLoaderTest extends TestCase {
                }
        }
 
+       /*
+        * We won't get an exception because the aspect path is empty and there is 
+        * no aop.xml file so the weaver will be disabled and no reweaving will 
+        * take place 
+        */
        public void testLoadWovenClass () {
                setSystemProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH,"");
                setSystemProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH,WOVEN_JAR);
@@ -83,6 +88,9 @@ public class WeavingURLClassLoaderTest extends TestCase {
                }
        }
 
+       /*
+        * We get an exception because the class was not built reweavable
+        */
        public void testWeaveWovenClass () {
                setSystemProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH,ADVICE_ASPECTS);
                setSystemProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH,ADVICE_ASPECTS + File.pathSeparator + WOVEN_JAR);
@@ -345,6 +353,7 @@ public class WeavingURLClassLoaderTest extends TestCase {
                        fail("Expecting java.lang.NoClassDefFoundError");
                }
                catch (Exception ex) {
+                       assertTrue("Expecting java.lang.NoClassDefFoundError but caught " + ex,ex.getMessage().contains("java.lang.NoClassDefFoundError"));
                }
        }
 
@@ -463,7 +472,9 @@ public class WeavingURLClassLoaderTest extends TestCase {
                        method.invoke(null,params);
                }
                catch (InvocationTargetException ex) {
-                       throw new RuntimeException(ex.getTargetException().toString());
+                       Throwable targetException = ex.getTargetException();
+                       if (targetException instanceof RuntimeException) throw (RuntimeException)ex.getTargetException();
+                       else throw new RuntimeException(ex.getTargetException().toString());
                }
                catch (Exception ex) {
                        throw new RuntimeException(ex.toString());
index a6b109301e644429792a6d41787b8dde228c6e21..961079f859129f567816b01403f096451c67bc4a 100644 (file)
@@ -578,7 +578,8 @@ public class AjcTestCase extends TestCase {
                
                URLClassLoader cLoader;
                if (useLTW) {
-                       cLoader = new WeavingURLClassLoader(urls,null);
+                       ClassLoader parent = getClass().getClassLoader();
+                       cLoader = new WeavingURLClassLoader(urls,parent);
                }
                else {
                        cLoader = new URLClassLoader(urls,null);
@@ -592,10 +593,10 @@ public class AjcTestCase extends TestCase {
                        } catch (Exception ex) {
                                fail ("Unable to prepare org.aspectj.testing.Tester for test run: " + ex);
                        }
-                       Class toRun = cLoader.loadClass(className);
-                       Method mainMethod = toRun.getMethod("main",new Class[] {String[].class});
                        System.setOut(new PrintStream(baosOut));
                        System.setErr(new PrintStream(baosErr));
+                       Class toRun = cLoader.loadClass(className);
+                       Method mainMethod = toRun.getMethod("main",new Class[] {String[].class});
                        mainMethod.invoke(null,new Object[] {args});
                        lastRunResult = new RunResult(command.toString(),new String(baosOut.toByteArray()),new String(baosErr.toByteArray()));
                } catch(ClassNotFoundException cnf) {
index 891600dbf57081e4f791c0619541915ba4c79060..166c2d89e7822d8c04724af5f148573ca633a22f 100644 (file)
@@ -141,7 +141,7 @@ public class RunSpec implements ITestStep {
                                useLtw = true;
                        }
                        catch (IOException ex) {
-                               ex.printStackTrace();
+                               AjcTestCase.fail(ex.toString());
                        }
                }
                
diff --git a/tests/ltw/AbstractAspect.aj b/tests/ltw/AbstractAspect.aj
new file mode 100644 (file)
index 0000000..6a735f2
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Matthew Webster         initial implementation
+ *******************************************************************************/
+import java.lang.reflect.*;
+
+public abstract aspect AbstractAspect {
+
+       /*
+        * These should not take effect unless a concrete sub-aspect is defined
+        */
+       declare parents : TestITDMethod implements Runnable;
+       
+       declare soft : InvocationTargetException : execution(public void TestITDMethod.*());
+
+       declare warning : execution(public void main(..)) :
+               "AbstractAspect_main";
+       
+       /*
+        * This should always take effect
+        */
+       public void TestITDMethod.test () {
+               System.err.println("AbstractAspect_TestITDMethod.test");
+       }
+}
diff --git a/tests/ltw/AbstractSuperAspect.aj b/tests/ltw/AbstractSuperAspect.aj
new file mode 100644 (file)
index 0000000..7050858
--- /dev/null
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Matthew Webster         initial implementation
+ *******************************************************************************/
+
+public abstract aspect AbstractSuperAspect {
+       
+               protected abstract pointcut scope ();
+       
+               before () : execution(void test1()) && scope() {
+                       System.err.println("AbstractSuperAspect.before_" + thisJoinPoint.getSignature().getName());
+               }
+}
index fca018ac92254da2819f29c32ad698e528881106..9e53bfb4de6aa333e8b4c9ab21681137c52f28b5 100644 (file)
@@ -9,6 +9,8 @@
  * Contributors:
  *   Matthew Webster         initial implementation
  *******************************************************************************/
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 
 public class Main {
 
@@ -20,7 +22,18 @@ public class Main {
                System.out.println("Main.test2");
        }
 
-       public static void main (String[] args) {
+       public void invokeDeclaredMethods () throws Exception {
+               Method[] methods = getClass().getDeclaredMethods();
+               for (int i = 0; i < methods.length; i++) {
+                       Method method = methods[i];
+                       int modifiers = method.getModifiers();
+                       if (!Modifier.isStatic(modifiers) && !method.getName().equals("invokeDeclaredMethods")) {
+                               method.invoke(this,new Object[] {});
+                       }
+               }
+       }
+       
+       public static void main (String[] args) throws Exception {
                System.out.println("Main.main");
                new Main().test1();
                new Main().test2();
diff --git a/tests/ltw/TestITDMethod.java b/tests/ltw/TestITDMethod.java
new file mode 100644 (file)
index 0000000..8f8d622
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Matthew Webster         initial implementation
+ *******************************************************************************/
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+public class TestITDMethod {
+
+       public void invokeDeclaredMethods (String[] names) throws Exception {
+               for (int i = 0; i < names.length; i++) {
+                       Method method = getClass().getDeclaredMethod(names[i],new Class[] {});
+                       method.invoke(this,new Object[] {});
+               }
+       }
+       
+       public static void main (String[] args) throws Exception {
+               System.out.println("TestITDMethod.main");
+               new TestITDMethod().invokeDeclaredMethods(args);
+       }
+}
diff --git a/tests/ltw/TestMain.java b/tests/ltw/TestMain.java
new file mode 100644 (file)
index 0000000..b55e943
--- /dev/null
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Matthew Webster         initial implementation
+ *******************************************************************************/
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+public class TestMain {
+       
+       public static void main (String[] args) throws Exception {
+               Main.main(args);
+       }
+}
diff --git a/tests/ltw/aop-abstractaspect.xml b/tests/ltw/aop-abstractaspect.xml
new file mode 100644 (file)
index 0000000..abd54cc
--- /dev/null
@@ -0,0 +1,8 @@
+<aspectj>
+       <aspects>
+           <aspect name="AbstractAspect"/>
+       </aspects>
+    
+    <weaver options="-showWeaveInfo -verbose"/>
+</aspectj>
+       
diff --git a/tests/ltw/aop-defineaspect.xml b/tests/ltw/aop-defineaspect.xml
new file mode 100644 (file)
index 0000000..5fdc064
--- /dev/null
@@ -0,0 +1,8 @@
+<aspectj>
+       <aspects>
+               <concrete-aspect name="ConcreteAspect" extends="AbstractSuperAspect">
+                       <pointcut name="scope" expression="within(Main)"/>
+        </concrete-aspect>
+       </aspects>
+</aspectj>
+       
index 3b489cf07a496d5c7a68c6c9141f6627b182d6c3..66eb92c68d41fb91e5a5cce9403b224ec1fa942a 100644 (file)
 package org.aspectj.systemtest.ajc150.ltw;
 
 import java.io.File;
+import java.util.Enumeration;
+import java.util.Properties;
 
 import junit.framework.Test;
 
 import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.weaver.tools.WeavingAdaptor;
 
 public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
@@ -38,5 +41,57 @@ public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase {
        public void testOutxmlJar (){
            runTest("Ensure valid aop.xml is generated for -outjar");
        }
+       
+       public void testNoAopxml(){
+               setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true");
+               runTest("Ensure no weaving without visible aop.xml");
+       }
+
+       public void testDefineConcreteAspect(){
+               runTest("Define concrete sub-aspect using aop.xml");
+       }
+
+       public void testDeclareAbstractAspect(){
+//             setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true");
+//             setSystemProperty(WeavingAdaptor.SHOW_WEAVE_INFO_PROPERTY,"true");
+               runTest("Use abstract aspect for ITD using aop.xml");
+       }
+
+       /*
+        * Allow system properties to be set and restored
+        * TODO maw move to XMLBasedAjcTestCase or RunSpec
+        */
+       private final static String NULL = "null";
+
+       private Properties savedProperties;
+       
+       protected void setSystemProperty (String key, String value) {
+               Properties systemProperties = System.getProperties();
+               copyProperty(key,systemProperties,savedProperties);
+               systemProperties.setProperty(key,value);
+       }
+       
+       private static void copyProperty (String key, Properties from, Properties to) {
+               String value = from.getProperty(key,NULL);
+               to.setProperty(key,value);
+       }
+
+       protected void setUp() throws Exception {
+               super.setUp();
+               savedProperties = new Properties();
+       }
+
+       protected void tearDown() throws Exception {
+               super.tearDown();
+               
+               /* Restore system properties */
+               Properties systemProperties = System.getProperties();
+               for (Enumeration enu = savedProperties.keys(); enu.hasMoreElements(); ) {
+                       String key = (String)enu.nextElement();
+                       String value = savedProperties.getProperty(key);
+                       if (value == NULL) systemProperties.remove(key);
+                       else systemProperties.setProperty(key,value);
+               }
+       }
 }
 
index 34f2f3dab8d8a8f298222c9c6cdc1ac49b93b615..6a8fe18812cf6984c0fcb2191a68f56dc820887c 100644 (file)
@@ -8,7 +8,7 @@
                        outjar="main1.jar"
             options="-showWeaveInfo"
         >
-               <message kind="weave" text="method-execution(void Main.test1())' in Type 'Main' (Main.java:15) advised by before advice from 'Aspect1' (Aspect1.aj:16)"/>
+               <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>     
         <compile
                classpath="main1.jar"
@@ -24,6 +24,8 @@
                 <line text="Main.test2"/>
             </stdout>
                <stderr>
+                       <line text="weaveinfo Join point 'method-execution(void Main.test1())' in Type 'Main' (Main.java:17) advised by before advice from 'Aspect1' (Aspect1.aj:16)"/>
+                               <line text="weaveinfo Join point 'method-execution(void Main.test2())' in Type 'Main' (Main.java:21) advised by before advice from 'Aspect2' (Aspect2.aj:16)"/>
                 <line text="Aspect1.before_test1"/>
                 <line text="Aspect2.before_test2"/>
             </stderr>
         </run>
     </ajc-test>
 
+       <ajc-test dir="ltw"
+      title="Ensure no weaving without visible aop.xml"
+      keywords="reweavable">
+        <compile
+               files="TestMain.java, Main.java"
+        >
+        </compile>     
+        <run class="TestMain" ltw="">
+               <stdout>
+                <line text="Main.main"/>
+                <line text="Main.test1"/>
+                <line text="Main.test2"/>
+            </stdout>
+               <stderr>
+                               <line text="info register classloader org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
+                               <line text="info no configuration found. Disabling weaver for class loader org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
+            </stderr>
+        </run>
+    </ajc-test>
+
+
+       <ajc-test dir="ltw"
+      title="Define concrete sub-aspect using aop.xml"
+      keywords="aop.xml">
+        <compile
+               files="Main.java"
+                       outjar="main.jar"
+        >
+        </compile>     
+        <compile
+               classpath="main1.jar"
+               files="AbstractSuperAspect.aj"
+               outjar="aspect.jar"
+        >
+        </compile>     
+        <run class="Main" ltw="aop-defineaspect.xml">
+               <stdout>
+                <line text="Main.main"/>
+                <line text="Main.test1"/>
+                <line text="Main.test2"/>
+            </stdout>
+               <stderr>
+                <line text="AbstractSuperAspect.before_test1"/>
+            </stderr>
+        </run>
+    </ajc-test>
+
+       <ajc-test dir="ltw"
+      title="Use abstract aspect for ITD using aop.xml"
+      keywords="abstract aspect, ITD">
+        <compile
+               files="TestITDMethod.java"
+        >
+        </compile>     
+        <compile
+               files="AbstractAspect.aj"
+        >
+               <message kind="warning" text="this affected type is not exposed to the weaver: TestITDMethod"/>
+        </compile>     
+        <run class="TestITDMethod" options="test" ltw="aop-abstractaspect.xml">
+               <stdout>
+                <line text="TestITDMethod.main"/>
+            </stdout>
+               <stderr>
+                       <line text="weaveinfo Type 'TestITDMethod' (TestITDMethod.java) has intertyped method from 'AbstractAspect' (AbstractAspect.aj:'void TestITDMethod.test()')"/>
+                <line text="AbstractAspect_TestITDMethod.test"/>
+            </stderr>
+        </run>
+    </ajc-test>
     
index 1019ca617dfd3c78b54cd180c856b02155d5ea87..b59ec5564fd8788268727886c5e4e757a528e4c9 100644 (file)
@@ -72,6 +72,11 @@ public class WeavingAdaptor {
        protected GeneratedClassHandler generatedClassHandler;
        protected Map generatedClasses = new HashMap(); /* String -> UnwovenClassFile */
 
+       protected WeavingAdaptor () {
+               createMessageHandler();
+       }
+       
+       
        /**
         * Construct a WeavingAdaptor with a reference to a weaving class loader. The
         * adaptor will automatically search the class loader hierarchy to resolve
@@ -135,9 +140,7 @@ public class WeavingAdaptor {
        }
        
        private void init(List classPath, List aspectPath) {
-               messageHandler = new WeavingAdaptorMessageHandler(new PrintWriter(System.err));
-               if (verbose) messageHandler.dontIgnore(IMessage.INFO);
-               if (Boolean.getBoolean(SHOW_WEAVE_INFO_PROPERTY)) messageHandler.dontIgnore(IMessage.WEAVEINFO);
+               createMessageHandler();
                
                info("using classpath: " + classPath); 
                info("using aspectpath: " + aspectPath); 
@@ -152,6 +155,13 @@ public class WeavingAdaptor {
                weaver = new BcelWeaver(bcelWorld);
                registerAspectLibraries(aspectPath);
        }
+
+
+       private void createMessageHandler() {
+               messageHandler = new WeavingAdaptorMessageHandler(new PrintWriter(System.err));
+               if (verbose) messageHandler.dontIgnore(IMessage.INFO);
+               if (Boolean.getBoolean(SHOW_WEAVE_INFO_PROPERTY)) messageHandler.dontIgnore(IMessage.WEAVEINFO);
+       }
        
        /**
         * Appends URL to path used by the WeavingAdptor to resolve classes
@@ -309,15 +319,15 @@ public class WeavingAdaptor {
                return ret;
        }
        
-       private boolean info (String message) {
+       protected boolean info (String message) {
                return MessageUtil.info(messageHandler,message);
        }
        
-       private boolean warn (String message) {
+       protected boolean warn (String message) {
                return MessageUtil.warn(messageHandler,message);
        }
        
-       private boolean error (String message) {
+       protected boolean error (String message) {
                return MessageUtil.error(messageHandler,message);
        }