]> source.dussan.org Git - aspectj.git/commitdiff
Fix and tests for Bugzilla Bug 62227
authoraclement <aclement>
Fri, 14 May 2004 12:51:52 +0000 (12:51 +0000)
committeraclement <aclement>
Fri, 14 May 2004 12:51:52 +0000 (12:51 +0000)
   Load Time Weaving aborts on any kind of warning (declare/xlint)

org.aspectj.ajdt.core/testdata/src1/LTWDeclareError.aj [new file with mode: 0644]
org.aspectj.ajdt.core/testdata/src1/LTWDeclareWarning.aj [new file with mode: 0644]
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java
weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java
weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java
weaver/testdata/ltw-deaspects.jar [new file with mode: 0644]
weaver/testdata/ltw-dwaspects.jar [new file with mode: 0644]
weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java

diff --git a/org.aspectj.ajdt.core/testdata/src1/LTWDeclareError.aj b/org.aspectj.ajdt.core/testdata/src1/LTWDeclareError.aj
new file mode 100644 (file)
index 0000000..4010ef2
--- /dev/null
@@ -0,0 +1,9 @@
+public aspect LTWDeclareError {\r
+       \r
+       pointcut method () :\r
+               execution(* LTWHelloWorld.println(..));\r
+       \r
+       declare error : method () :\r
+               "LTWDeclareError.println()";\r
+\r
+}\r
diff --git a/org.aspectj.ajdt.core/testdata/src1/LTWDeclareWarning.aj b/org.aspectj.ajdt.core/testdata/src1/LTWDeclareWarning.aj
new file mode 100644 (file)
index 0000000..2d85d33
--- /dev/null
@@ -0,0 +1,9 @@
+public aspect LTWDeclareWarning {\r
+       \r
+       pointcut method () :\r
+               execution(* LTWHelloWorld.println(..));\r
+       \r
+       declare warning : method () :\r
+               "LTWDeclareWarning.println()";\r
+\r
+}\r
index 98c9ea984d7083dc258e09f00a07e6d6b2414f32..40e81eedac998e9ae6560997d948b65362c99f97 100644 (file)
@@ -231,6 +231,30 @@ public class BcweaverJarMaker {
                args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/LTWAspect.aj");
                CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
 
+               /*
+                * Declare warning advice
+                */
+               args = new ArrayList();
+               args.add("-classpath"); 
+               args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar;../weaver/testdata/ltw-classes.jar" +
+                  File.pathSeparator + System.getProperty("aspectjrt.path"));
+               args.add("-outjar");
+               args.add("../weaver/testdata/ltw-dwaspects.jar");
+               args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/LTWDeclareWarning.aj");
+               CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
+
+               /*
+                * Declare error advice
+                */
+               args = new ArrayList();
+               args.add("-classpath"); 
+               args.add("../lib/test/aspectjrt.jar;../lib/test/testing-client.jar;../weaver/testdata/ltw-classes.jar" +
+                  File.pathSeparator + System.getProperty("aspectjrt.path"));
+               args.add("-outjar");
+               args.add("../weaver/testdata/ltw-deaspects.jar");
+               args.add(AjdtAjcTests.TESTDATA_PATH + "/src1/LTWDeclareError.aj");
+               CommandTestCase.runCompiler(args, CommandTestCase.NO_ERRORS);
+
                /*
                 * Around closure advice
                 */
index c01f188121fd804b819ea8cd8006cae2630bc03e..347cb104c8de351c5d5b10328781e9143ade06da 100644 (file)
@@ -17,10 +17,6 @@ import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-import java.net.URLStreamHandlerFactory;
 import java.security.CodeSource;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -28,8 +24,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
 
-import org.aspectj.util.UtilClassLoader;
-import org.aspectj.weaver.tools.*;
+import org.aspectj.weaver.tools.WeavingAdaptor;
+import org.aspectj.weaver.tools.WeavingClassLoader;
 
 public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements WeavingClassLoader {
 
index a7cd1ed74fad105fbbc5c1129d04b3829098db2a..f89dbb5334c6d087cc93fb3eb808ba364688246b 100644 (file)
@@ -18,32 +18,23 @@ import java.io.IOException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Enumeration;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
 
 import org.aspectj.bridge.AbortException;
 import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.IMessageHandler;
-import org.aspectj.bridge.MessageHandler;
 import org.aspectj.bridge.IMessage.Kind;
 import org.aspectj.util.FileUtil;
 import org.aspectj.weaver.IClassFileProvider;
 import org.aspectj.weaver.IWeaveRequestor;
 import org.aspectj.weaver.ResolvedTypeX;
-import org.aspectj.weaver.bcel.BcelObjectType;
 import org.aspectj.weaver.bcel.BcelWeaver;
 import org.aspectj.weaver.bcel.BcelWorld;
-import org.aspectj.weaver.bcel.LazyClassGen;
 import org.aspectj.weaver.bcel.UnwovenClassFile;
 
 /**
@@ -271,14 +262,15 @@ public class WeavingAdaptor {
 
                public boolean handleMessage(IMessage message) throws AbortException {
                        if (!isIgnoring(message.getKind())) {
-                               if (verbose) System.err.println(message.getMessage());
-                               throw new AbortException(message);
+                               System.err.println(message.getSourceLocation()+": "+message.getKind()+" "+message.getMessage());
+                               if (message.getKind() == IMessage.ERROR) throw new AbortException(message);
                        }
                        return true;
                }
 
                public boolean isIgnoring(Kind kind) {
-                       return ((kind == IMessage.INFO) || (kind == IMessage.DEBUG));
+                       if (verbose) return false;
+                       else         return ((kind == IMessage.INFO) || (kind == IMessage.DEBUG));
                }
        }
 
diff --git a/weaver/testdata/ltw-deaspects.jar b/weaver/testdata/ltw-deaspects.jar
new file mode 100644 (file)
index 0000000..982c609
Binary files /dev/null and b/weaver/testdata/ltw-deaspects.jar differ
diff --git a/weaver/testdata/ltw-dwaspects.jar b/weaver/testdata/ltw-dwaspects.jar
new file mode 100644 (file)
index 0000000..d3cbc67
Binary files /dev/null and b/weaver/testdata/ltw-dwaspects.jar differ
index d3f940e4d93406cf522b7837df5c9e9cf1b0936a..4035ed278fdf4093cb9fb35ed7e918e3feb24db4 100644 (file)
@@ -35,6 +35,8 @@ public class WeavingURLClassLoaderTest extends TestCase {
        private final static String WOVEN_JAR = BcweaverTests.TESTDATA_PATH + "/ltw-woven.jar";
        private final static String JUNK_JAR = BcweaverTests.TESTDATA_PATH + "/ltw-junk.jar";
        private final static String ADVICE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-aspects.jar";
+       private final static String DW_ADVICE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-dwaspects.jar";
+       private final static String DE_ADVICE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-deaspects.jar";
        private final static String AROUNDCLOSURE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-acaspects.jar";
        private final static String ITD_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-itdaspects.jar";
        private final static String PER_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-peraspects.jar";
@@ -117,6 +119,35 @@ public class WeavingURLClassLoaderTest extends TestCase {
                }
        }
 
+       public void testWeaveDeclareWarningAdvice () {
+               System.setProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH,DW_ADVICE_ASPECTS);
+               System.setProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH,DW_ADVICE_ASPECTS + File.pathSeparator + CLASSES_JAR);
+               WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
+
+               try {
+                       Class clazz = loader.loadClass("LTWHelloWorld");
+                       invokeMain(clazz,new String[] {} ); 
+               }
+               catch (Exception ex) {
+                       fail(ex.toString());
+               }
+       }
+
+       public void testWeaveDeclareErrorAdvice () {
+               System.setProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH,DE_ADVICE_ASPECTS);
+               System.setProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH,DE_ADVICE_ASPECTS + File.pathSeparator + CLASSES_JAR);
+               WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
+
+               try {
+                       Class clazz = loader.loadClass("LTWHelloWorld");
+                       invokeMain(clazz,new String[] {} ); 
+                       fail("Expecting org.aspectj.bridge.AbortException");
+               }
+               catch (Exception ex) {
+                       assertTrue("Expecting org.aspectj.bridge.AbortException caught " + ex,(ex instanceof AbortException));
+               }
+       }
+
        public void testWeaveAroundClosure () {
                System.setProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH,AROUNDCLOSURE_ASPECTS);
                System.setProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH,AROUNDCLOSURE_ASPECTS + File.pathSeparator + CLASSES_JAR);