diff options
author | aclement <aclement> | 2004-05-14 12:51:52 +0000 |
---|---|---|
committer | aclement <aclement> | 2004-05-14 12:51:52 +0000 |
commit | 9ebfc84930fde3f56a0166a5abb671029d457ea4 (patch) | |
tree | caecc64856e88fcc1beaaeddd1229e37a621343e | |
parent | 7051338a0064c3a43223e26e3ace8b64258200d7 (diff) | |
download | aspectj-9ebfc84930fde3f56a0166a5abb671029d457ea4.tar.gz aspectj-9ebfc84930fde3f56a0166a5abb671029d457ea4.zip |
Fix and tests for Bugzilla Bug 62227
Load Time Weaving aborts on any kind of warning (declare/xlint)
-rw-r--r-- | org.aspectj.ajdt.core/testdata/src1/LTWDeclareError.aj | 9 | ||||
-rw-r--r-- | org.aspectj.ajdt.core/testdata/src1/LTWDeclareWarning.aj | 9 | ||||
-rw-r--r-- | org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java | 24 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java | 8 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java | 16 | ||||
-rw-r--r-- | weaver/testdata/ltw-deaspects.jar | bin | 0 -> 1096 bytes | |||
-rw-r--r-- | weaver/testdata/ltw-dwaspects.jar | bin | 0 -> 1100 bytes | |||
-rw-r--r-- | weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java | 31 |
8 files changed, 79 insertions, 18 deletions
diff --git a/org.aspectj.ajdt.core/testdata/src1/LTWDeclareError.aj b/org.aspectj.ajdt.core/testdata/src1/LTWDeclareError.aj new file mode 100644 index 000000000..4010ef2cd --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/LTWDeclareError.aj @@ -0,0 +1,9 @@ +public aspect LTWDeclareError {
+
+ pointcut method () :
+ execution(* LTWHelloWorld.println(..));
+
+ declare error : method () :
+ "LTWDeclareError.println()";
+
+}
diff --git a/org.aspectj.ajdt.core/testdata/src1/LTWDeclareWarning.aj b/org.aspectj.ajdt.core/testdata/src1/LTWDeclareWarning.aj new file mode 100644 index 000000000..2d85d3310 --- /dev/null +++ b/org.aspectj.ajdt.core/testdata/src1/LTWDeclareWarning.aj @@ -0,0 +1,9 @@ +public aspect LTWDeclareWarning {
+
+ pointcut method () :
+ execution(* LTWHelloWorld.println(..));
+
+ declare warning : method () :
+ "LTWDeclareWarning.println()";
+
+}
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java index 98c9ea984..40e81eeda 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/compiler/batch/BcweaverJarMaker.java @@ -232,6 +232,30 @@ public class BcweaverJarMaker { 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 */ args = new ArrayList(); diff --git a/weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java b/weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java index c01f18812..347cb104c 100644 --- a/weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java +++ b/weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java @@ -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 { diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java index a7cd1ed74..f89dbb533 100644 --- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -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 Binary files differnew file mode 100644 index 000000000..982c609ad --- /dev/null +++ b/weaver/testdata/ltw-deaspects.jar diff --git a/weaver/testdata/ltw-dwaspects.jar b/weaver/testdata/ltw-dwaspects.jar Binary files differnew file mode 100644 index 000000000..d3cbc6728 --- /dev/null +++ b/weaver/testdata/ltw-dwaspects.jar diff --git a/weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java b/weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java index d3f940e4d..4035ed278 100644 --- a/weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java +++ b/weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java @@ -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); |