]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for 156904: missing type warning then it matches anyway
authoraclement <aclement>
Tue, 3 Oct 2006 15:00:34 +0000 (15:00 +0000)
committeraclement <aclement>
Tue, 3 Oct 2006 15:00:34 +0000 (15:00 +0000)
tests/bugs153/pr156904/inDiffPkgAndImport/A.aj [new file with mode: 0644]
tests/bugs153/pr156904/inDiffPkgAndImport/Outer.java [new file with mode: 0644]
tests/bugs153/pr156904/inDiffPkgWithoutImport/A.aj [new file with mode: 0644]
tests/bugs153/pr156904/inDiffPkgWithoutImport/Outer.java [new file with mode: 0644]
tests/bugs153/pr156904/inSameFile/A.aj [new file with mode: 0644]
tests/bugs153/pr156904/inSamePkg/A.aj [new file with mode: 0644]
tests/bugs153/pr156904/inSamePkg/Outer.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc153/Ajc153Tests.java
tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
weaver/src/org/aspectj/weaver/patterns/WildTypePattern.java

diff --git a/tests/bugs153/pr156904/inDiffPkgAndImport/A.aj b/tests/bugs153/pr156904/inDiffPkgAndImport/A.aj
new file mode 100644 (file)
index 0000000..99fa658
--- /dev/null
@@ -0,0 +1,12 @@
+package pkg;
+
+import pkg1.*;
+
+public aspect A {
+
+       pointcut innerpointcut() : execution( * Outer.myMethod() );
+
+       before() : innerpointcut() {
+          System.out.println( "executing!" );
+       }
+}
diff --git a/tests/bugs153/pr156904/inDiffPkgAndImport/Outer.java b/tests/bugs153/pr156904/inDiffPkgAndImport/Outer.java
new file mode 100644 (file)
index 0000000..df7256a
--- /dev/null
@@ -0,0 +1,8 @@
+package pkg1;
+
+class Outer {
+
+       private void myMethod(){
+       }
+       
+}
diff --git a/tests/bugs153/pr156904/inDiffPkgWithoutImport/A.aj b/tests/bugs153/pr156904/inDiffPkgWithoutImport/A.aj
new file mode 100644 (file)
index 0000000..bb158a5
--- /dev/null
@@ -0,0 +1,10 @@
+package pkg;
+
+public aspect A {
+
+       pointcut innerpointcut() : execution( * Outer.myMethod() );
+
+       before() : innerpointcut() {
+          System.out.println( "executing!" );
+       }
+}
diff --git a/tests/bugs153/pr156904/inDiffPkgWithoutImport/Outer.java b/tests/bugs153/pr156904/inDiffPkgWithoutImport/Outer.java
new file mode 100644 (file)
index 0000000..df7256a
--- /dev/null
@@ -0,0 +1,8 @@
+package pkg1;
+
+class Outer {
+
+       private void myMethod(){
+       }
+       
+}
diff --git a/tests/bugs153/pr156904/inSameFile/A.aj b/tests/bugs153/pr156904/inSameFile/A.aj
new file mode 100644 (file)
index 0000000..ab04620
--- /dev/null
@@ -0,0 +1,19 @@
+package pkg;
+
+public aspect A {
+
+       pointcut innerpointcut() : execution( * Outer.Inner.myMethod() );
+
+       before() : innerpointcut() {
+          System.out.println( "executing!" );
+       }
+
+}
+
+class Outer {
+       
+    private class Inner{
+       private void myMethod(){
+       }
+    }
+}
diff --git a/tests/bugs153/pr156904/inSamePkg/A.aj b/tests/bugs153/pr156904/inSamePkg/A.aj
new file mode 100644 (file)
index 0000000..cff99d7
--- /dev/null
@@ -0,0 +1,11 @@
+package pkg;
+
+public aspect A {
+
+       pointcut innerpointcut() : execution( * Outer.Inner.myMethod() );
+
+       before() : innerpointcut() {
+          System.out.println( "executing!" );
+       }
+       
+}
diff --git a/tests/bugs153/pr156904/inSamePkg/Outer.java b/tests/bugs153/pr156904/inSamePkg/Outer.java
new file mode 100644 (file)
index 0000000..0991393
--- /dev/null
@@ -0,0 +1,10 @@
+package pkg;
+
+class Outer {
+
+    private class Inner{
+       private void myMethod(){
+       }
+    }
+       
+}
index ee11353fb87a99bb1555e0eea017c7122edab0cd..9f2ff8775488fccd67437afc6e4935e7a8c13bc5 100644 (file)
@@ -134,7 +134,13 @@ public class Ajc153Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          runTest("NPE with custom agent");
   }
   
-    /////////////////////////////////////////
+  public void testNoInvalidAbsoluteTypeNameWarning_pr156904_1() {runTest("ensure no invalidAbsoluteTypeName when do match - 1");}
+  public void testNoInvalidAbsoluteTypeNameWarning_pr156904_2() {runTest("ensure no invalidAbsoluteTypeName when do match - 2");}
+  public void testNoInvalidAbsoluteTypeNameWarning_pr156904_3() {runTest("ensure no invalidAbsoluteTypeName when do match - 3");}
+  public void testNoInvalidAbsoluteTypeNameWarning_pr156904_4() {runTest("ensure no invalidAbsoluteTypeName when do match - 4");}
+
+  
+  /////////////////////////////////////////
   public static Test suite() {
     return XMLBasedAjcTestCase.loadSuite(Ajc153Tests.class);
   }
index ea791e8d06887f489ed20b1915f2fb39668501d5..c2d54e4d1e61564831ce52125e3341e63c5fb1fe 100644 (file)
       <compile files="SampleTest.java"/>
     </ajc-test>
 
+    <ajc-test dir="bugs153/pr156904/inSameFile" title="ensure no invalidAbsoluteTypeName when do match - 1">
+      <compile files="A.aj"/>
+    </ajc-test>
+
+    <ajc-test dir="bugs153/pr156904/inDiffPkgAndImport" title="ensure no invalidAbsoluteTypeName when do match - 2">
+      <compile files="A.aj,Outer.java"/>
+    </ajc-test>
+
+    <ajc-test dir="bugs153/pr156904/inSamePkg" title="ensure no invalidAbsoluteTypeName when do match - 3">
+      <compile files="A.aj,Outer.java"/>
+    </ajc-test>
+
+    <ajc-test dir="bugs153/pr156904/inDiffPkgWithoutImport" title="ensure no invalidAbsoluteTypeName when do match - 4">
+      <compile files="A.aj,Outer.java">
+               <message kind="warning" line="5" text="no match for this type name: Outer [Xlint:invalidAbsoluteTypeName]"/>
+         </compile>
+    </ajc-test>
+
        <ajc-test dir="ltw" title="NPE with custom agent" keywords="ltw">
         <compile files="java/net/URLClassLoader.java"/>
         <compile files="HelloWorld.java" options="-outjar hello.jar"/>
index 8eb3cdf2c972a08fb82d4454e73f19b8a4a00b8f..48f429274c499363cf91d5075181654c88db3353 100644 (file)
@@ -687,7 +687,8 @@ public class WildTypePattern extends TypePattern {
                
                //System.out.println("resolve: " + cleanName);
                //??? this loop has too many inefficiencies to count
-               resolvedTypeInTheWorld = lookupTypeInWorld(scope.getWorld(), fullyQualifiedName);
+               resolvedTypeInTheWorld = lookupTypeInWorldIncludingPrefixes(scope.getWorld(), fullyQualifiedName, scope.getImportedPrefixes());
+
                if (resolvedTypeInTheWorld.isGenericWildcard()) {
                        type = resolvedTypeInTheWorld;
                } else {
@@ -712,6 +713,27 @@ public class WildTypePattern extends TypePattern {
                return type;
        }
        
+       /**
+        * Searches the world for the ResolvedType with the given typeName. If one 
+        * isn't found then for each of the supplied prefixes, it prepends the typeName
+        * with the prefix and searches the world for the ResolvedType with this new name.
+        * If one still isn't found then a MissingResolvedTypeWithKnownSignature is 
+        * returned with the originally requested typeName (this ensures the typeName
+        * makes sense).
+        */
+       private ResolvedType lookupTypeInWorldIncludingPrefixes(World world, String typeName, String[] prefixes) {
+               ResolvedType ret = lookupTypeInWorld(world, typeName);
+               if (!ret.isMissing()) return ret; 
+               ResolvedType retWithPrefix = ret;
+               int counter = 0;
+               while (retWithPrefix.isMissing() && (counter < prefixes.length)) {
+                       retWithPrefix = lookupTypeInWorld(world,prefixes[counter] + typeName);
+                       counter++;
+               }
+               if (!retWithPrefix.isMissing()) return retWithPrefix;
+               return ret;
+       }
+       
        private ResolvedType lookupTypeInWorld(World world, String typeName) {
                ResolvedType ret = world.resolve(UnresolvedType.forName(typeName),true);
                while (ret.isMissing()) {