]> source.dussan.org Git - aspectj.git/commitdiff
fixes for 120363 : from matthew (include/exclude problems for LTW)
authoraclement <aclement>
Mon, 12 Dec 2005 15:42:19 +0000 (15:42 +0000)
committeraclement <aclement>
Mon, 12 Dec 2005 15:42:19 +0000 (15:42 +0000)
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
tests/java5/ataspectj/ataspectj/Test$$EnhancerByCGLIB$$12345.java [deleted file]
tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml
tests/java5/ataspectj/com/foo/bar/Test$$EnhancerByCGLIB$$12345.java [new file with mode: 0644]
tests/java5/ataspectj/com/foo/bar/Test.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml

index f2c628a3542de28fa188870012c4c47e25d38829..35a5688581cb4eed131eae3073ce20f83e9ad7d4 100644 (file)
@@ -465,16 +465,21 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
                 return false;
             }
         }
-        boolean fastAccept = false;//defaults to false if no fast include
-        for (int i = 0; i < m_includeStartsWith.size(); i++) {
-            fastAccept = fastClassName.startsWith((String)m_includeStartsWith.get(i));
-            if (fastAccept) {
-                break;
+        
+        /* 
+         * Bug 120363
+         * If we have an exclude pattern that cannot be matched using "starts with"
+         * then we cannot fast accept
+         */ 
+        if (m_excludeTypePattern.isEmpty()) {
+            boolean fastAccept = false;//defaults to false if no fast include
+            for (int i = 0; i < m_includeStartsWith.size(); i++) {
+                fastAccept = fastClassName.startsWith((String)m_includeStartsWith.get(i));
+                if (fastAccept) {
+                    break;
+                }
             }
         }
-        if (fastAccept) {
-            return true;
-        }
 
         // needs further analysis
         // TODO AV - needs refactoring
diff --git a/tests/java5/ataspectj/ataspectj/Test$$EnhancerByCGLIB$$12345.java b/tests/java5/ataspectj/ataspectj/Test$$EnhancerByCGLIB$$12345.java
deleted file mode 100644 (file)
index 78df5f1..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- * 
- * Contributors:
- *     Matthew Webster - initial implementation
- *******************************************************************************/
-package ataspectj;
-
-public class Test$$EnhancerByCGLIB$$12345 {
-
-       public static void main(String[] args) {
-               System.out.println("Test$$EnhancerByCGLIB$$12345.main()");
-       }
-
-}
index 487d5dd62126e2a723008e841246fc3baa832b79..43b74905300447e7e8b1694e9ab0e582c510e243 100644 (file)
@@ -1,6 +1,8 @@
 <?xml version="1.0"?>
 <aspectj>
-    <weaver options="-verbose">
-        <dump within="ataspectj..*" beforeandafter="true"/> 
-    </weaver>
+    <weaver options="-XlazyTjp -verbose">
+        <dump within="com.foo.bar..*" beforeandafter="true"/> 
+        <include within="com.foo..*"/>
+        <exclude within="com.foo.bar..*CGLIB*"/>
+       </weaver>
 </aspectj>
diff --git a/tests/java5/ataspectj/com/foo/bar/Test$$EnhancerByCGLIB$$12345.java b/tests/java5/ataspectj/com/foo/bar/Test$$EnhancerByCGLIB$$12345.java
new file mode 100644 (file)
index 0000000..3640800
--- /dev/null
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package com.foo.bar;
+
+public class Test$$EnhancerByCGLIB$$12345 {
+
+       public static void main(String[] args) {
+               System.out.println("Test$$EnhancerByCGLIB$$12345.main()");
+               Test.main(args);
+       }
+
+}
diff --git a/tests/java5/ataspectj/com/foo/bar/Test.java b/tests/java5/ataspectj/com/foo/bar/Test.java
new file mode 100644 (file)
index 0000000..a1629a7
--- /dev/null
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     Matthew Webster - initial implementation
+ *******************************************************************************/
+package com.foo.bar;
+
+public class Test {
+
+       public static void main(String[] args) {
+               System.out.println("Test.main()");
+       }
+
+}
index 7c2e52978f15a2a3db5e74479d49e43e6e93b7ff..eb4ad7445d8834563d2eda4b4a50f889225aab50 100644 (file)
@@ -97,11 +97,18 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {
 
     public void testLTWDumpBeforeAndAfter() {
         runTest("LTW DumpTest before and after");
+        
+        // before
+        File f = new File("_ajdump/_before/com/foo/bar");
+        CountingFilenameFilter cff = new CountingFilenameFilter();
+        f.listFiles(cff);
+        assertEquals("Expected dump file in " + f.getAbsolutePath(),1,cff.getCount());
 
-        File f = new File("_ajdump/_before/ataspectj/Test$$EnhancerByCGLIB$$12345.class");
-        assertTrue(f.exists());
-        f = new File("_ajdump/ataspectj/Test$$EnhancerByCGLIB$$12345.class");
-        assertTrue(f.exists());
+        // after
+        f = new File("_ajdump/com/foo/bar");
+        cff = new CountingFilenameFilter();
+        f.listFiles(cff);
+        assertEquals("Expected dump file in " + f.getAbsolutePath(),1,cff.getCount());
         
         // tidy up...
         f = new File("_ajdump");
@@ -127,12 +134,10 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {
         // The working directory is different because this test must be forked
         File dir = new File("../tests/java5/ataspectj");
         File f = new File(dir,"_ajdump/_before");
-        System.out.println("AtAjLTWTests.testLTWDumpProxy() f=" + f.getAbsolutePath());
         CountingFilenameFilter cff = new CountingFilenameFilter();
         f.listFiles(cff);
         assertEquals("Expected dump file in " + f.getAbsolutePath(),1,cff.getCount());
         f = new File(dir,"_ajdump");
-        System.out.println("AtAjLTWTests.testLTWDumpProxy() f=" + f.getAbsolutePath());
         cff = new CountingFilenameFilter();
         f.listFiles(cff);
         assertEquals(1,cff.getCount());
index 6b7f3598777aeaf299946968be366965453e12af..6cf87b52c6d11ecc35209a2ccf2f3d719048d715 100644 (file)
                 options="-1.5"/>
         <run class="ataspectj.DumpTest" ltw="ataspectj/aop-dump.xml"/>
     </ajc-test>
-
+    
     <ajc-test dir="java5/ataspectj" title="LTW DumpTest before and after">
         <compile
-                files="ataspectj/Test$$EnhancerByCGLIB$$12345.java"
+                files="com/foo/bar/Test.java, com/foo/bar/Test$$EnhancerByCGLIB$$12345.java"
                 options="-1.5"/>
-        <run class="ataspectj.Test$$EnhancerByCGLIB$$12345" ltw="ataspectj/aop-dumpbeforeandafter.xml"/>
+        <run class="com.foo.bar.Test$$EnhancerByCGLIB$$12345" ltw="ataspectj/aop-dumpbeforeandafter.xml">
+               <stdout>
+                       <line text="Test$$EnhancerByCGLIB$$12345.main()"/>
+                       <line text="Test.main()"/>
+            </stdout>
+               <stderr>
+                       <line text="info weaving 'com.foo.bar.Test'"/>
+            </stderr>
+        </run>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="LTW DumpTest closure">