]> source.dussan.org Git - aspectj.git/commitdiff
fixes for 118715 from Matthew.
authoraclement <aclement>
Tue, 6 Dec 2005 13:02:38 +0000 (13:02 +0000)
committeraclement <aclement>
Tue, 6 Dec 2005 13:02:38 +0000 (13:02 +0000)
15 files changed:
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
testing/newsrc/org/aspectj/testing/OutputSpec.java
testing/newsrc/org/aspectj/testing/RunSpec.java
testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java
tests/ltw/Aspect3.aj [new file with mode: 0644]
tests/ltw/Xlint-empty.properties [new file with mode: 0644]
tests/ltw/Xlint-nomatch.properties [new file with mode: 0644]
tests/ltw/aop-nomatch.xml [new file with mode: 0644]
tests/ltw/aop-nomatchxlint.xml [new file with mode: 0644]
tests/ltw/aop-nomatchxlintfile.xml [new file with mode: 0644]
tests/ltw/aop-xlintfile.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
weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java

index b17392d0505d210ea7b3459e0787409a3e0465e6..d889fbdc0c55bd20633424f538a1513e58cf2ee7 100644 (file)
@@ -25,9 +25,7 @@ import java.util.Properties;
 import java.util.StringTokenizer;
 
 import org.aspectj.asm.IRelationship;
-import org.aspectj.bridge.IMessage;
 import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.bridge.Message;
 import org.aspectj.util.LangUtil;
 import org.aspectj.weaver.ICrossReferenceHandler;
 import org.aspectj.weaver.Lint;
@@ -220,7 +218,14 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
         world.setXnoInline(weaverOption.noInline);
         // AMC - autodetect as per line below, needed for AtAjLTWTests.testLTWUnweavable
         world.setBehaveInJava5Way(LangUtil.is15VMOrGreater());
-        //-Xlintfile: first so that lint wins
+
+        /* First load defaults */
+               bcelWorld.getLint().loadDefaultProperties();
+               
+               /* Second overlay LTW defaults */
+               bcelWorld.getLint().adviceDidNotMatch.setKind(null);
+        
+        /* Third load user file using -Xlintfile so that -Xlint wins */
         if (weaverOption.lintFile != null) {
             InputStream resource = null;
             try {
@@ -236,20 +241,20 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
                     }
                 }
                 if (failure != null || resource == null) {
-                    world.getMessageHandler().handleMessage(new Message(
-                            "Cannot access resource for -Xlintfile:"+weaverOption.lintFile,
-                            IMessage.WARNING,
-                            failure,
-                            null));
+                       warn("Cannot access resource for -Xlintfile:"+weaverOption.lintFile,failure);
+//                    world.getMessageHandler().handleMessage(new Message(
+//                            "Cannot access resource for -Xlintfile:"+weaverOption.lintFile,
+//                            IMessage.WARNING,
+//                            failure,
+//                            null));
                 }
             } finally {
                 try { resource.close(); } catch (Throwable t) {;}
             }
-        }
-        if (weaverOption.lint == null) {
-                       bcelWorld.getLint().loadDefaultProperties();
-                       bcelWorld.getLint().adviceDidNotMatch.setKind(IMessage.INFO);
-        } else {
+       } 
+        
+       /* Fourth override with -Xlint */
+       if (weaverOption.lint != null) {
             if (weaverOption.lint.equals("default")) {//FIXME should be AjBuildConfig.AJLINT_DEFAULT but yetanother deps..
                 bcelWorld.getLint().loadDefaultProperties();
             } else {
index be869bfbbc999c5de44fbf700f70b942b3d0ec89..45a7a02d685c1f4045655007bce008dac16448a8 100644 (file)
@@ -35,7 +35,8 @@ public class OutputSpec {
                                String line = (String) iter.next();
                                lineNo++;
                                String outputLine = strTok.nextToken().trim();
-                               if (!line.equals(outputLine)) {
+                               /* Avoid trying to match on ajSandbox source names that appear in messages */
+                               if (outputLine.indexOf(line) == -1) {
                                        matches = false;
                                        break;
                                }
index 166c2d89e7822d8c04724af5f148573ca633a22f..b879c95a208e677eeda49aad31e09c9d448f5ffc 100644 (file)
@@ -37,6 +37,7 @@ public class RunSpec implements ITestStep {
        private OutputSpec stdErrSpec;
        private OutputSpec stdOutSpec;
        private String ltwFile;
+       private String xlintFile;
        
        public RunSpec() {
        }
@@ -51,6 +52,7 @@ public class RunSpec implements ITestStep {
                String[] args = buildArgs();
 //             System.err.println("? execute() inTestCase='" + inTestCase + "', ltwFile=" + ltwFile);
                boolean useLtw = copyLtwFile(inTestCase.getSandboxDirectory());
+               copyXlintFile(inTestCase.getSandboxDirectory());
                AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(),args,getClasspath(),useLtw);
                if (stdErrSpec != null) {
                        stdErrSpec.matchAgainst(rr.getStdErr());
@@ -147,4 +149,25 @@ public class RunSpec implements ITestStep {
                
                return useLtw;
        }
+
+       public String getXlintFile() {
+               return xlintFile;
+       }
+
+       public void setXlintFile(String xlintFile) {
+               this.xlintFile = xlintFile;
+       }
+
+       private void copyXlintFile (File sandboxDirectory) {
+               if (xlintFile != null) {
+                       File from = new File(baseDir,xlintFile);
+                       File to = new File(sandboxDirectory, File.separator + xlintFile);
+                       try {
+                               FileUtil.copyFile(from,to);
+                       }
+                       catch (IOException ex) {
+                               AjcTestCase.fail(ex.toString());
+                       }
+               }
+       }
 }
index 58a5f0d33038b318a96fe69b7315378056f150fe..fbefbccb224c8218f9ce2bf9edc13bb56dd63507 100644 (file)
@@ -167,6 +167,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
                digester.addObjectCreate("suite/ajc-test/run",RunSpec.class);
                digester.addSetProperties("suite/ajc-test/run","class","classToRun");
                digester.addSetProperties("suite/ajc-test/run","ltw","ltwFile");
+               digester.addSetProperties("suite/ajc-test/run","xlintfile","xlintFile");
                digester.addSetNext("suite/ajc-test/run","addTestStep","org.aspectj.testing.ITestStep");
                digester.addObjectCreate("*/message",ExpectedMessageSpec.class);
                digester.addSetProperties("*/message");
diff --git a/tests/ltw/Aspect3.aj b/tests/ltw/Aspect3.aj
new file mode 100644 (file)
index 0000000..c27d9e1
--- /dev/null
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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 org.aspectj.lang.JoinPoint;
+
+public aspect Aspect3 {
+       
+       before () : execution(void Main.test999()) {
+               System.err.println("Aspect1.before_" + thisJoinPoint.getSignature().getName());
+       }
+}
diff --git a/tests/ltw/Xlint-empty.properties b/tests/ltw/Xlint-empty.properties
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/ltw/Xlint-nomatch.properties b/tests/ltw/Xlint-nomatch.properties
new file mode 100644 (file)
index 0000000..00f96a1
--- /dev/null
@@ -0,0 +1 @@
+adviceDidNotMatch = warning
diff --git a/tests/ltw/aop-nomatch.xml b/tests/ltw/aop-nomatch.xml
new file mode 100644 (file)
index 0000000..620a4c7
--- /dev/null
@@ -0,0 +1,7 @@
+<aspectj>
+       <aspects>
+           <aspect name="Aspect3"/>
+       </aspects>
+    
+    <weaver options="-verbose -showWeaveInfo"/>
+</aspectj>
diff --git a/tests/ltw/aop-nomatchxlint.xml b/tests/ltw/aop-nomatchxlint.xml
new file mode 100644 (file)
index 0000000..4271e39
--- /dev/null
@@ -0,0 +1,7 @@
+<aspectj>
+       <aspects>
+           <aspect name="Aspect3"/>
+       </aspects>
+    
+    <weaver options="-verbose -showWeaveInfo -Xlint:warning"/>
+</aspectj>
diff --git a/tests/ltw/aop-nomatchxlintfile.xml b/tests/ltw/aop-nomatchxlintfile.xml
new file mode 100644 (file)
index 0000000..35ce126
--- /dev/null
@@ -0,0 +1,7 @@
+<aspectj>
+       <aspects>
+           <aspect name="Aspect3"/>
+       </aspects>
+    
+    <weaver options="-verbose -showWeaveInfo -Xlintfile:Xlint-nomatch.properties"/>
+</aspectj>
diff --git a/tests/ltw/aop-xlintfile.xml b/tests/ltw/aop-xlintfile.xml
new file mode 100644 (file)
index 0000000..31d7bad
--- /dev/null
@@ -0,0 +1,3 @@
+<aspectj>
+       <weaver options="-Xlintfile:Xlint-empty.properties"/>
+</aspectj>
index ffb52a905ef35214433699f86b9cd310464e9549..57ca498104fd84552a998dc5242ac0b6afd521cc 100644 (file)
@@ -65,6 +65,30 @@ public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase {
                runTest("Ensure weaver lint warning issued when an aspect is not used for weaving");
        }
 
+       public void testXlintfileEmpty () {
+               runTest("Empty Xlint.properties file");
+       }
+
+       public void testXlintfileMissing () {
+               runTest("Warning with missing Xlint.properties file");
+       }
+
+       public void testXlintWarningAdviceDidNotMatchSuppressed () {
+               runTest("Warning when advice doesn't match suppressed for LTW");
+       }
+
+       public void testXlintfile () {
+               runTest("Override suppressing of warning when advice doesn't match using -Xlintfile");
+       }
+
+       public void testXlintDefault () {
+               runTest("Warning when advice doesn't match using -Xlint:default");
+       }
+
+       public void testXlintWarning () {
+               runTest("Override suppressing of warning when advice doesn't match using -Xlint:warning");
+       }
+       
        /*
         * Allow system properties to be set and restored
         * TODO maw move to XMLBasedAjcTestCase or RunSpec
index 69eff31ee6961d9d1b821a040eef11b3d9347452..284357e42231f553b35286e9404fb80054a4111d 100644 (file)
@@ -1,3 +1,4 @@
+
 <!-- Load-time weaving tests -->
 
        <ajc-test dir="ltw"
         </run>
     </ajc-test>
     
+       <ajc-test dir="ltw"
+      title="Empty Xlint.properties file"
+      keywords="xlint, ltw">
+        <compile
+               files="Main.java"
+        >
+        </compile>     
+        <run class="Main" ltw="aop-xlintfile.xml" xlintfile="Xlint-empty.properties">
+               <stderr>
+               </stderr>
+        </run>
+    </ajc-test>
+    
+       <ajc-test dir="ltw"
+      title="Warning with missing Xlint.properties file"
+      keywords="xlint, ltw">
+        <compile
+               files="Main.java"
+        >
+        </compile>     
+        <run class="Main" ltw="aop-xlintfile.xml">
+               <stderr>
+                       <line text="warning Cannot access resource for -Xlintfile:Xlint-empty.properties"/>
+               </stderr>
+        </run>
+    </ajc-test>
+    
+       <ajc-test dir="ltw"
+      title="Warning when advice doesn't match suppressed for LTW"
+      keywords="xlint, ltw">
+        <compile
+               files="Main.java"
+        >
+        </compile>     
+        <compile
+               files="Aspect3.aj"
+        >
+        </compile>     
+        <run class="Main" ltw="aop-nomatch.xml">
+               <stderr>
+                       <line text="info register aspect Aspect3"/>
+                       <line text="info weaving 'Main'"/>
+               </stderr>
+        </run>
+    </ajc-test>
+    
+       <ajc-test dir="ltw"
+      title="Override suppressing of warning when advice doesn't match using -Xlintfile"
+      keywords="xlint, ltw">
+        <compile
+               files="Main.java"
+        >
+        </compile>     
+        <compile
+               files="Aspect3.aj"
+        >
+        </compile>     
+        <run class="Main" ltw="aop-nomatchxlintfile.xml" xlintfile="Xlint-nomatch.properties">
+               <stderr>
+                       <line text="info register aspect Aspect3"/>
+                       <line text="info weaving 'Main'"/>
+                       <line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
+               </stderr>
+        </run>
+    </ajc-test>
+    
+       <ajc-test dir="ltw"
+      title="Warning when advice doesn't match using -Xlint:default"
+      keywords="xlint, ltw">
+        <compile
+               files="Main.java"
+        >
+        </compile>     
+        <compile
+               files="Aspect3.aj"
+        >
+        </compile>     
+        <run class="Main" ltw="aop-nomatchxlint.xml">
+               <stderr>
+                       <line text="info register aspect Aspect3"/>
+                       <line text="info weaving 'Main'"/>
+                       <line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
+               </stderr>
+        </run>
+    </ajc-test>
+    
+       <ajc-test dir="ltw"
+      title="Override suppressing of warning when advice doesn't match using -Xlint:warning"
+      keywords="xlint, ltw">
+        <compile
+               files="Main.java"
+        >
+        </compile>     
+        <compile
+               files="Aspect3.aj"
+        >
+        </compile>     
+        <run class="Main" ltw="aop-nomatchxlint.xml">
+               <stderr>
+                       <line text="info register aspect Aspect3"/>
+                       <line text="info weaving 'Main'"/>
+                       <line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
+               </stderr>
+        </run>
+    </ajc-test>
+    
index 398a0b4f3c7caa4a963116c54b47ba893f531321..3aeaa7f70f785cadf400ab98e78d9a426088422f 100644 (file)
@@ -332,7 +332,7 @@ public class WeavingAdaptor {
        }
        
        protected boolean warn (String message, Throwable th) {
-        return messageHandler.handleMessage(new Message("Register definition failed", IMessage.WARNING, th, null));
+        return messageHandler.handleMessage(new Message(message, IMessage.WARNING, th, null));
        }
        
        protected boolean error (String message) {
index 502dd80fbbac6432cd5775e488a314bfd9643259..d153ccdc75548b728d2a4c92d6aec2495331a45e 100644 (file)
@@ -15,25 +15,18 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
-import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.lang.reflect.WildcardType;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.reflect.AjType;
 import org.aspectj.lang.reflect.AjTypeSystem;
 import org.aspectj.lang.reflect.Pointcut;
 import org.aspectj.weaver.AnnotationX;
-import org.aspectj.weaver.BoundedReferenceType;
 import org.aspectj.weaver.ReferenceType;
 import org.aspectj.weaver.ResolvedMember;
 import org.aspectj.weaver.ResolvedPointcutDefinition;
 import org.aspectj.weaver.ResolvedType;
-import org.aspectj.weaver.TypeFactory;
 import org.aspectj.weaver.TypeVariable;
 import org.aspectj.weaver.TypeVariableReferenceType;
 import org.aspectj.weaver.UnresolvedType;