]> source.dussan.org Git - aspectj.git/commitdiff
Bug 152982 "org.aspectj Restructure - Phase 2: Move tests" (move Java 5 dependedent...
authormwebster <mwebster>
Mon, 7 Aug 2006 16:41:05 +0000 (16:41 +0000)
committermwebster <mwebster>
Mon, 7 Aug 2006 16:41:05 +0000 (16:41 +0000)
22 files changed:
run-all-junit-tests/testsrc/AllTests.java
weaver/testsrc/org/aspectj/weaver/BcweaverModuleTests15.java [deleted file]
weaver/testsrc/org/aspectj/weaver/bcel/AsmDelegateTests.java
weaver/testsrc/org/aspectj/weaver/tools/PointcutExpressionTest.java
weaver/testsrc/org/aspectj/weaver/tools/ToolsTests.java
weaver5/java5-testsrc/AllWeaver5Tests.java [deleted file]
weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java
weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/BcweaverModuleTests15.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/BoundedReferenceTypeTestCase.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java
weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/bcel/AsmDelegateTests5.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java [new file with mode: 0644]
weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java [new file with mode: 0644]
weaver5/testsrc/org/aspectj/weaver/Weaver5ModuleTests.java
weaver5/testsrc/org/aspectj/weaver/tools/PointcutExpressionTest.java [deleted file]

index bac614eb2141b8f4ed358f9e5a45f7e9ce727940..6ef81a518daea9fbc12446670e1e32f8381687bf 100644 (file)
  * ******************************************************************/
 
 // default package
-import org.aspectj.util.LangUtil;
-import org.aspectj.util.UtilModuleTests;
-import org.aspectj.weaver.BcweaverModuleTests;
-import org.aspectj.weaver.BcweaverModuleTests15;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
 import org.aspectj.ajde.AjdeModuleTests;
 import org.aspectj.ajdt.EajcModuleTests;
 import org.aspectj.asm.AsmModuleTests;
@@ -30,9 +29,10 @@ import org.aspectj.testingutil.TestingUtilModuleTests;
 import org.aspectj.tools.ajbrowser.AjbrowserModuleTests;
 import org.aspectj.tools.ajdoc.AjdocModuleTests;
 import org.aspectj.tools.ant.TaskdefsModuleTests;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.aspectj.util.LangUtil;
+import org.aspectj.util.UtilModuleTests;
+import org.aspectj.weaver.BcweaverModuleTests;
+import org.aspectj.weaver.Weaver5ModuleTests;
 
 public class AllTests extends TestCase {
     public static final boolean skipSupportModules = false;
@@ -65,8 +65,7 @@ public class AllTests extends TestCase {
             TestUtil.loadTestsReflectively(suite, "org.aspectj.runtime.Aspectj5rtModuleTests", false);
             TestUtil.loadTestsReflectively(suite, "org.aspectj.loadtime.Loadtime5ModuleTests", false);
             // this next one is built normally, but needs 1.5 rt.jar to pass
-            suite.addTest(BcweaverModuleTests15.suite());
-            TestUtil.loadTestsReflectively(suite, "org.aspectj.weaver.Weaver5ModuleTests",false);
+            suite.addTest(Weaver5ModuleTests.suite());
         } else {
             suite.addTest(TestUtil.skipTest("for 1.5"));
         } 
diff --git a/weaver/testsrc/org/aspectj/weaver/BcweaverModuleTests15.java b/weaver/testsrc/org/aspectj/weaver/BcweaverModuleTests15.java
deleted file mode 100644 (file)
index 7220ea5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.aspectj.weaver;
-/* *******************************************************************
- * 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: 
- *   Adrian Colyer                     Initial implementation
- * ******************************************************************/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.aspectj.testing.util.TestUtil;
-import org.aspectj.util.LangUtil;
-import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXTestCase;
-import org.aspectj.weaver.patterns.WildTypePatternResolutionTestCase;
-
-public class BcweaverModuleTests15 extends TestCase {
-          public static Test suite() { 
-               TestSuite suite = new TestSuite(BcweaverModuleTests15.class.getName());
-               suite.addTestSuite(TypeVariableTestCase.class);
-               suite.addTestSuite(ReferenceTypeTestCase.class);
-               suite.addTestSuite(BoundedReferenceTypeTestCase.class);
-               suite.addTestSuite(TypeVariableReferenceTypeTestCase.class);
-               suite.addTestSuite(MemberTestCase15.class);
-               suite.addTestSuite(BcelGenericSignatureToTypeXTestCase.class);
-               suite.addTestSuite(WildTypePatternResolutionTestCase.class);
-               if (LangUtil.is15VMOrGreater()) {
-                   TestUtil.loadTestsReflectively(suite, "org.aspectj.weaver.tools.Java15PointcutExpressionTest", false);
-                   TestUtil.loadTestsReflectively(suite, "org.aspectj.weaver.TestJava5ReflectionBasedReferenceTypeDelegate", false);
-               }
-               return suite;
-           }
-
-           public BcweaverModuleTests15(String name) { super(name); }
-}
index 146a5ba2ba7655bbd44e576d770a884357dae311..58918b778d271da914e051ecf42bcb31b2ea638f 100644 (file)
@@ -31,7 +31,6 @@ import org.aspectj.weaver.ResolvedMemberImpl;
 import org.aspectj.weaver.ResolvedType;
 import org.aspectj.weaver.ShadowMunger;
 import org.aspectj.weaver.TypeVariable;
-import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.World;
 import org.aspectj.weaver.AjAttribute.EffectiveSignatureAttribute;
 import org.aspectj.weaver.asm.AsmDelegate;
@@ -153,105 +152,6 @@ public class AsmDelegateTests extends AbstractWorldTestCase {
         checkEquivalent("",(AbstractReferenceTypeDelegate)aComplex.getDelegate(),(AbstractReferenceTypeDelegate)bComplex.getDelegate());
     }
     
-    /**
-     * Methods are transformed according to generic signatures - this checks 
-     * that some of the generic methods in java.lang.Class appear the same 
-     * whether viewed through an ASM or a BCEL delegate.
-     */
-    public void testCompareGenericMethods() {
-        BcelWorld slowWorld = new BcelWorld();
-        slowWorld.setFastDelegateSupport(false);
-        slowWorld.setBehaveInJava5Way(true);
-        
-        BcelWorld fastWorld = new BcelWorld();
-        fastWorld.setBehaveInJava5Way(true);
-
-        ResolvedType bcelJavaLangClass = slowWorld.resolve(UnresolvedType.forName("java.lang.Class"));
-        ResolvedType  asmJavaLangClass = fastWorld.resolve(UnresolvedType.forName("java.lang.Class"));
-        
-        bcelJavaLangClass = bcelJavaLangClass.getGenericType();
-        asmJavaLangClass  = asmJavaLangClass.getGenericType();
-        
-       //if (bcelJavaLangClass == null) return;  // for < 1.5
-       
-       ResolvedMember[] bcelMethods = bcelJavaLangClass.getDeclaredMethods();
-       ResolvedMember[]  asmMethods = asmJavaLangClass.getDeclaredMethods();
-       
-       for (int i = 0; i < bcelMethods.length; i++) {
-               bcelMethods[i].setParameterNames(null); // forget them, asm delegates dont currently know them
-               String one = bcelMethods[i].toDebugString();
-               String two = asmMethods[i].toDebugString();
-               if (!one.equals(two)) {
-                       fail("These methods look different when viewed through ASM or BCEL\nBCEL='"+bcelMethods[i].toDebugString()+
-                                "'\n ASM='"+asmMethods[i].toDebugString()+"'");
-               }
-               // If one is parameterized, check the other is...
-               if (bcelMethods[i].canBeParameterized()) {
-                       assertTrue("ASM method '"+asmMethods[i].toDebugString()+"' can't be parameterized whereas its' BCEL variant could",
-                                      asmMethods[i].canBeParameterized());
-               }
-                       
-               }
-       
-       // Let's take a special look at:
-       //   public <U> Class<? extends U> asSubclass(Class<U> clazz)
-       ResolvedMember bcelSubclassMethod = null;
-       for (int i = 0; i < bcelMethods.length; i++) {
-                       if (bcelMethods[i].getName().equals("asSubclass")) { bcelSubclassMethod = bcelMethods[i]; break; }
-               }
-       ResolvedMember asmSubclassMethod = null;
-       for (int i = 0; i < asmMethods.length; i++) {
-                       if (asmMethods[i].getName().equals("asSubclass")) { asmSubclassMethod = asmMethods[i];break;    }
-               }
-       
-       TypeVariable[] tvs = bcelSubclassMethod.getTypeVariables();
-       assertTrue("should have one type variable on the bcel version but found: "+format(tvs),tvs!=null && tvs.length==1);
-        tvs = asmSubclassMethod.getTypeVariables();
-       assertTrue("should have one type variable on the asm version but found: "+format(tvs),tvs!=null && tvs.length==1);
-
-    }
-    
-    private String format(TypeVariable[] tvs) {
-       if (tvs==null) return "null";
-       StringBuffer s = new StringBuffer();
-       s.append("[");
-       for (int i = 0; i < tvs.length; i++) {
-                       s.append(tvs[i]);
-                       if ((i+1)<tvs.length) s.append(",");
-               }
-       s.append("]");
-       return s.toString();
-    }
-    
-    public void testCompareGenericFields() {
-        BcelWorld slowWorld = new BcelWorld();
-        slowWorld.setFastDelegateSupport(false);
-        slowWorld.setBehaveInJava5Way(true);
-        
-        BcelWorld fastWorld = new BcelWorld();
-        fastWorld.setBehaveInJava5Way(true);
-
-        ResolvedType bcelJavaLangClass = slowWorld.resolve(UnresolvedType.forName("java.lang.Class"));
-        ResolvedType  asmJavaLangClass = fastWorld.resolve(UnresolvedType.forName("java.lang.Class"));
-        
-        bcelJavaLangClass = bcelJavaLangClass.getGenericType();
-        asmJavaLangClass = asmJavaLangClass.getGenericType();
-        
-       if (bcelJavaLangClass == null) return;  // for < 1.5
-       
-       ResolvedMember[] bcelFields = bcelJavaLangClass.getDeclaredFields();
-       ResolvedMember[]  asmFields = asmJavaLangClass.getDeclaredFields();
-       
-       for (int i = 0; i < bcelFields.length; i++) {
-               UnresolvedType bcelFieldType = bcelFields[i].getGenericReturnType();
-               UnresolvedType asmFieldType = asmFields[i].getGenericReturnType();
-               if (!bcelFields[i].getGenericReturnType().toDebugString().equals(asmFields[i].getGenericReturnType().toDebugString())) {
-                       fail("These fields look different when viewed through ASM or BCEL\nBCEL='"+bcelFieldType.toDebugString()+
-                                "'\n ASM='"+asmFieldType.toDebugString()+"'");
-               }
-               }
-    }
-    
     public void testCompareDelegatesMonster() {
         BcelWorld slowWorld = new BcelWorld("../lib/aspectj/lib/aspectjtools.jar");slowWorld.setFastDelegateSupport(false);
         BcelWorld fastWorld = new BcelWorld("../lib/aspectj/lib/aspectjtools.jar");
index 205423c35630ca4f99498d21274a91c574ccb2d4..acd510f50d942898a9b61a68d219702456cebb95 100644 (file)
@@ -14,13 +14,12 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 
-import junit.framework.TestCase;
-
 import org.aspectj.util.LangUtil;
 
+import junit.framework.TestCase;
+
 public class PointcutExpressionTest extends TestCase {
 
-       boolean needToSkip = false;
        PointcutParser p;
        Constructor asCons;
        Constructor bsCons;
@@ -38,8 +37,6 @@ public class PointcutExpressionTest extends TestCase {
        Method bar;
        
        public void testMatchesMethodCall() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("call(* *..A.a*(..))");
                assertTrue("Should match call to A.a()",ex.matchesMethodCall(a,a).alwaysMatches());
                assertTrue("Should match call to A.aaa()",ex.matchesMethodCall(aaa,a).alwaysMatches());
@@ -89,8 +86,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesMethodExecution() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("execution(* *..A.aa(..))");
                assertTrue("Should match execution of A.aa",ex.matchesMethodExecution(aa).alwaysMatches());
                assertTrue("Should match execution of B.aa",ex.matchesMethodExecution(bsaa).alwaysMatches());
@@ -129,8 +124,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesConstructorCall() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("call(new(String))");
                assertTrue("Should match A(String)", ex.matchesConstructorCall(asCons,b).alwaysMatches());
                assertTrue("Should match B(String)", ex.matchesConstructorCall(bsStringCons,b).alwaysMatches());
@@ -166,8 +159,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesConstructorExecution() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("execution(new(String))");
                assertTrue("Should match A(String)", ex.matchesConstructorExecution(asCons).alwaysMatches());
                assertTrue("Should match B(String)", ex.matchesConstructorExecution(bsStringCons).alwaysMatches());
@@ -211,8 +202,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesAdviceExecution() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("adviceexecution()");
                assertTrue("Should match (advice) A.a",ex.matchesAdviceExecution(a).alwaysMatches());
                // test this
@@ -248,8 +237,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesHandler() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("handler(Exception)");
                assertTrue("Should match catch(Exception)",ex.matchesHandler(Exception.class,Client.class).alwaysMatches());
                assertTrue("Should not match catch(Throwable)",ex.matchesHandler(Throwable.class,Client.class).neverMatches());
@@ -281,8 +268,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesInitialization() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("initialization(new(String))");
                assertTrue("Should match A(String)",ex.matchesInitialization(asCons).alwaysMatches());
                assertTrue("Should match B(String)", ex.matchesInitialization(bsStringCons).alwaysMatches());
@@ -318,8 +303,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesPreInitialization() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("preinitialization(new(String))");
                assertTrue("Should match A(String)",ex.matchesPreInitialization(asCons).alwaysMatches());
                assertTrue("Should match B(String)", ex.matchesPreInitialization(bsStringCons).alwaysMatches());
@@ -350,8 +333,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesStaticInitialization() {
-               if (needToSkip) return;
-
                // staticinit
                PointcutExpression ex = p.parsePointcutExpression("staticinitialization(*..A+)");
                assertTrue("Matches A",ex.matchesStaticInitialization(A.class).alwaysMatches());
@@ -381,8 +362,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesFieldSet() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("set(* *..A+.*)");
                assertTrue("matches x",ex.matchesFieldSet(x,a).alwaysMatches());
                assertTrue("matches y",ex.matchesFieldSet(y,foo).alwaysMatches());
@@ -415,8 +394,6 @@ public class PointcutExpressionTest extends TestCase {
        }
 
        public void testMatchesFieldGet() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("get(* *..A+.*)");
                assertTrue("matches x",ex.matchesFieldGet(x,a).alwaysMatches());
                assertTrue("matches y",ex.matchesFieldGet(y,foo).alwaysMatches());
@@ -447,8 +424,6 @@ public class PointcutExpressionTest extends TestCase {
        }
        
        public void testArgsMatching() {
-               if (needToSkip) return;
-
                // too few args
                PointcutExpression ex = p.parsePointcutExpression("args(*,*,*,*)");
                assertTrue("Too few args",ex.matchesMethodExecution(foo).neverMatches());
@@ -526,15 +501,11 @@ public class PointcutExpressionTest extends TestCase {
 //}
 
        public void testGetPointcutExpression() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("staticinitialization(*..A+)");
                assertEquals("staticinitialization(*..A+)",ex.getPointcutExpression());
        }
        
        public void testCouldMatchJoinPointsInType() {
-               if (needToSkip) return;
-
                PointcutExpression ex = p.parsePointcutExpression("execution(* org.aspectj.weaver.tools.PointcutExpressionTest.B.*(..))");
                assertTrue("Could maybe match String (as best we know at this point)",ex.couldMatchJoinPointsInType(String.class));
                assertTrue("Will always match B",ex.couldMatchJoinPointsInType(B.class));
@@ -543,9 +514,7 @@ public class PointcutExpressionTest extends TestCase {
                assertTrue("Will always match B",ex.couldMatchJoinPointsInType(B.class));
        }
        
-       public void testMayNeedDynamicTest() {          
-               if (needToSkip) return;
-
+       public void testMayNeedDynamicTest() {
                PointcutExpression ex = p.parsePointcutExpression("execution(* org.aspectj.weaver.tools.PointcutExpressionTest.B.*(..))");
                assertFalse("No dynamic test needed",ex.mayNeedDynamicTest());
                ex = p.parsePointcutExpression("execution(* org.aspectj.weaver.tools.PointcutExpressionTest.B.*(..)) && args(org.aspectj.weaver.tools.PointcutExpressionTest.X)");
@@ -554,8 +523,6 @@ public class PointcutExpressionTest extends TestCase {
 
        protected void setUp() throws Exception {
                super.setUp();
-               needToSkip = needToSkipPointcutParserTests();
-               if (needToSkip) return;
                p = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
                asCons = A.class.getConstructor(new Class[]{String.class});
                bsCons = B.class.getConstructor(new Class[0]);
@@ -573,17 +540,6 @@ public class PointcutExpressionTest extends TestCase {
                bar = Client.class.getDeclaredMethod("bar",new Class[]{String.class,int.class,Integer.class,Number.class});
        }
        
-       /** this condition can occur on the build machine only, and is way too complex to fix right now... */
-       private boolean needToSkipPointcutParserTests() {
-               if (!LangUtil.is15VMOrGreater()) return false;
-               try {
-                       Class.forName("org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate",false,this.getClass().getClassLoader());//ReflectionBasedReferenceTypeDelegate.class.getClassLoader()); 
-               } catch (ClassNotFoundException cnfEx) {
-                       return true;
-               }
-               return false;
-       }
-       
        static class A {
          public A(String s) {}
          public void a() {}
@@ -608,4 +564,5 @@ public class PointcutExpressionTest extends TestCase {
        }
        
        static class X {}
+       
 }
index 557ec0ad7191db5314e51759e7112a3dd76e9326..636fd7a1f62a46ac6b534e609e977c0796286e14 100644 (file)
@@ -9,16 +9,23 @@
  * ******************************************************************/
 package org.aspectj.weaver.tools;
 
+import org.aspectj.testing.util.TestUtil;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 public class ToolsTests {
 
        public static Test suite() {
-               TestSuite suite = new TestSuite("Test for org.aspectj.weaver.tools");
+               TestSuite suite = new TestSuite(ToolsTests.class.getName());
                //$JUnit-BEGIN$
+               /* FIXME maw The CLASSPATH is wrong so run them in weaver5 instead */
+               if (!TestUtil.is15VMOrGreater()) {
+                       suite.addTestSuite(PointcutExpressionTest.class);
+        } else {
+            suite.addTest(TestUtil.testNamed("run from weaver5 under 1.5"));
+        }
                suite.addTestSuite(PointcutParserTest.class);
-               suite.addTestSuite(PointcutExpressionTest.class);
                suite.addTestSuite(TypePatternMatcherTest.class);
                suite.addTestSuite(PointcutDesignatorHandlerTests.class);
                //$JUnit-END$
diff --git a/weaver5/java5-testsrc/AllWeaver5Tests.java b/weaver5/java5-testsrc/AllWeaver5Tests.java
deleted file mode 100644 (file)
index f195cb9..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2005-2006 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: 
- *   Adrian Colyer          Initial implementation
- * ******************************************************************/
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.aspectj.weaver.AllTracing5Tests;
-import org.aspectj.weaver.TestJava5ReflectionBasedReferenceTypeDelegate;
-import org.aspectj.weaver.patterns.ArgsTestCase;
-import org.aspectj.weaver.patterns.ThisOrTargetTestCase;
-import org.aspectj.weaver.tools.Java15PointcutExpressionTest;
-import org.aspectj.weaver.tools.PointcutExpressionTest;
-import org.aspectj.weaver.tools.PointcutParserTest;
-import org.aspectj.weaver.tools.TypePatternMatcherTest;
-
-public class AllWeaver5Tests {
-
-       public static Test suite() {
-               TestSuite suite = new TestSuite("Test for default package");
-               //$JUnit-BEGIN$
-               suite.addTestSuite(TestJava5ReflectionBasedReferenceTypeDelegate.class);
-               suite.addTestSuite(Java15PointcutExpressionTest.class);
-               suite.addTestSuite(ArgsTestCase.class);
-               suite.addTestSuite(ThisOrTargetTestCase.class);
-               suite.addTestSuite(PointcutExpressionTest.class);
-               suite.addTestSuite(PointcutParserTest.class);
-               suite.addTestSuite(TypePatternMatcherTest.class);
-        suite.addTest(AllTracing5Tests.suite());
-               //$JUnit-END$
-               return suite;
-       }
-
-}
index bc6e594b7e19f61e8e6b014dfb5f95a48c2a65ac..bf68cb56cc6a0ebb31ad0f22dcfd610d02054093 100644 (file)
@@ -16,7 +16,7 @@ import junit.framework.TestSuite;
 public class AllTracing5Tests {
 
        public static Test suite() {
-               TestSuite suite = new TestSuite("Test for org.aspectj.weaver");
+               TestSuite suite = new TestSuite(AllTracing5Tests.class.getName());
                //$JUnit-BEGIN$
                suite.addTestSuite(Jdk14TraceFactoryTest.class);
                suite.addTestSuite(Jdk14TraceTest.class);
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java b/weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java
new file mode 100644 (file)
index 0000000..b46d840
--- /dev/null
@@ -0,0 +1,36 @@
+/* *******************************************************************
+ * Copyright (c) 2005-2006 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: 
+ *   Adrian Colyer          Initial implementation
+ *   Matthew Webster        Move from default package
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.aspectj.weaver.bcel.AsmDelegateTests5;
+import org.aspectj.weaver.reflect.ReflectionWorldTest;
+import org.aspectj.weaver.tools.PointcutExpressionTest;
+
+public class AllWeaver5Tests {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite(AllWeaver5Tests.class.getName());
+               //$JUnit-BEGIN$
+        suite.addTest(AllTracing5Tests.suite());
+        suite.addTest(AsmDelegateTests5.suite());
+        suite.addTest(BcweaverModuleTests15.suite());
+               suite.addTestSuite(PointcutExpressionTest.class);
+               suite.addTestSuite(ReflectionWorldTest.class);
+               //$JUnit-END$
+               return suite;
+       }
+
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/BcweaverModuleTests15.java b/weaver5/java5-testsrc/org/aspectj/weaver/BcweaverModuleTests15.java
new file mode 100644 (file)
index 0000000..7463640
--- /dev/null
@@ -0,0 +1,37 @@
+package org.aspectj.weaver;
+/* *******************************************************************
+ * 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: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXTestCase;
+import org.aspectj.weaver.patterns.WildTypePatternResolutionTestCase;
+import org.aspectj.weaver.tools.Java15PointcutExpressionTest;
+
+public class BcweaverModuleTests15 extends TestCase {
+          public static Test suite() { 
+               TestSuite suite = new TestSuite(BcweaverModuleTests15.class.getName());
+               suite.addTestSuite(BcelGenericSignatureToTypeXTestCase.class);
+               suite.addTestSuite(BoundedReferenceTypeTestCase.class);
+               suite.addTest(Java15PointcutExpressionTest.suite());
+               suite.addTestSuite(MemberTestCase15.class);
+               suite.addTestSuite(ReferenceTypeTestCase.class);
+               suite.addTest(TestJava5ReflectionBasedReferenceTypeDelegate.suite());
+               suite.addTestSuite(TypeVariableTestCase.class);
+               suite.addTestSuite(TypeVariableReferenceTypeTestCase.class);
+               suite.addTestSuite(WildTypePatternResolutionTestCase.class);
+               return suite;
+           }
+
+           public BcweaverModuleTests15(String name) { super(name); }
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/BoundedReferenceTypeTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/BoundedReferenceTypeTestCase.java
new file mode 100644 (file)
index 0000000..b46a5a6
--- /dev/null
@@ -0,0 +1,105 @@
+/* *******************************************************************
+ * 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: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.weaver.bcel.BcelWorld;
+
+import junit.framework.TestCase;
+
+public class BoundedReferenceTypeTestCase extends TestCase {
+
+       ReferenceType javaLangClass;
+       ReferenceType javaLangObject;
+       BoundedReferenceType extendsClass;
+       BoundedReferenceType superClass;
+       BoundedReferenceType extendsWithExtras;
+       
+       public void testSignature() {
+               String extendsSig = extendsClass.getSignature();
+               assertEquals("+Ljava/lang/Class;",extendsSig);
+               assertEquals("-Ljava/lang/Class;",superClass.getSignature());
+       }
+       
+       public void testExtendsBounds() {
+               assertFalse("has no lower bound",extendsClass.hasLowerBound());
+               assertNull("no lower bound",extendsClass.getLowerBound());
+               assertEquals(javaLangClass,extendsClass.getUpperBound());
+               assertEquals("no interface bounds",0,extendsClass.getInterfaceBounds().length);
+       }
+       
+       public void testSuperBounds() {
+               assertTrue("has lower bound",superClass.hasLowerBound());
+               assertEquals(javaLangClass,superClass.getLowerBound());
+               assertEquals("Ljava/lang/Object;",superClass.getUpperBound().getSignature());
+               assertEquals("no interface bounds",0,superClass.getInterfaceBounds().length);
+       }
+       
+       public void testIsExtends() {
+               assertTrue(extendsClass.isExtends);
+               assertFalse(superClass.isExtends);
+       }
+       
+       public void testIsSuper() {
+               assertTrue(superClass.isSuper);
+               assertFalse(extendsClass.isSuper);
+       }
+       
+       public void testGetDeclaredInterfacesNoAdditions() {
+               ResolvedType[] rt1 = extendsClass.getDeclaredInterfaces();
+               ResolvedType[] rt2 = javaLangClass.getDeclaredInterfaces();
+               assertEquals("same length",rt1.length,rt2.length);
+               for (int i = 0; i < rt2.length; i++) {
+                       assertEquals("same methods",rt1[i],rt2[i]);
+               }
+       }
+       
+       public void testGetDeclaredInterfacesWithInterfaceBounds() {
+               ResolvedType[] rt1 = extendsWithExtras.getDeclaredInterfaces();
+               ResolvedType[] rt2 = javaLangClass.getDeclaredInterfaces();
+               assertEquals("one extra interface",rt1.length,rt2.length + 1);
+               for (int i = 0; i < rt2.length; i++) {
+                       assertEquals("same methods",rt1[i],rt2[i]);
+               }
+               assertEquals("Ljava/util/List;",rt1[rt1.length-1].getSignature());
+       }
+       
+       // all other methods in signature are delegated to upper bound... 
+       // representative test
+       public void testGetDeclaredMethodsExtends() {
+               ResolvedMember[] rm1 = extendsClass.getDeclaredMethods();
+               ResolvedMember[] rm2 = javaLangClass.getDeclaredMethods();
+               assertEquals("same length",rm1.length,rm2.length);
+               for (int i = 0; i < rm2.length; i++) {
+                       assertEquals("same methods",rm1[i],rm2[i]);
+               }
+       }
+
+       public void testGetDeclaredMethodsSuper() {
+               ResolvedMember[] rm1 = superClass.getDeclaredMethods();
+               ResolvedMember[] rm2 = javaLangObject.getDeclaredMethods();
+               assertEquals("same length",rm1.length,rm2.length);
+               for (int i = 0; i < rm2.length; i++) {
+                       assertEquals("same methods",rm1[i],rm2[i]);
+               }
+       }
+
+       protected void setUp() throws Exception {
+               super.setUp();
+               BcelWorld world = new BcelWorld();
+               javaLangClass = (ReferenceType) world.resolve(UnresolvedType.forName("java/lang/Class"));
+               javaLangObject = (ReferenceType) world.resolve(UnresolvedType.OBJECT);
+               extendsClass = new BoundedReferenceType(javaLangClass,true,world);
+               superClass = new BoundedReferenceType(javaLangClass,false,world);
+               extendsWithExtras = new BoundedReferenceType(javaLangClass,true,world,
+                               new ReferenceType[] {(ReferenceType)world.resolve(UnresolvedType.forName("java/util/List"))});
+       }
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java b/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java
new file mode 100644 (file)
index 0000000..8014289
--- /dev/null
@@ -0,0 +1,81 @@
+/* *******************************************************************
+ * 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: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.weaver.bcel.BcelWorld;
+
+import junit.framework.TestCase;
+
+/**
+ * @author colyer
+ *
+ */
+public class MemberTestCase15 extends TestCase {
+
+         public void testCanBeParameterizedRegularMethod() {
+               BcelWorld world = new BcelWorld();
+               ResolvedType javaLangClass = world.resolve(UnresolvedType.forName("java/lang/Class"));
+               ResolvedMember[] methods = javaLangClass.getDeclaredMethods();
+               ResolvedMember getAnnotations = null;
+               for (int i = 0; i < methods.length; i++) {
+                               if (methods[i].getName().equals("getAnnotations")) {
+                                       getAnnotations = methods[i];
+                                       break;
+                               }
+                       }
+               if (getAnnotations != null) { // so can run on non-Java 5
+//                     System.out.println("got it");
+                       assertFalse(getAnnotations.canBeParameterized());
+               }
+           }
+           
+           public void testCanBeParameterizedGenericMethod() {
+               BcelWorld world = new BcelWorld();
+               world.setBehaveInJava5Way(true);
+               ResolvedType javaLangClass = world.resolve(UnresolvedType.forName("java.lang.Class"));
+               javaLangClass = javaLangClass.getGenericType();
+               if (javaLangClass == null) return;  // for < 1.5
+               ResolvedMember[] methods = javaLangClass.getDeclaredMethods();
+               ResolvedMember asSubclass = null;
+               for (int i = 0; i < methods.length; i++) {
+                               if (methods[i].getName().equals("asSubclass")) {
+                                       asSubclass = methods[i];
+                                       break;
+                               }
+                       }
+               if (asSubclass != null) { // so can run on non-Java 5
+//                     System.out.println("got it");
+                       assertTrue(asSubclass.canBeParameterized());
+               }       
+           }
+           
+           public void testCanBeParameterizedMethodInGenericType() {
+               BcelWorld world = new BcelWorld();
+               world.setBehaveInJava5Way(true);
+               ResolvedType javaUtilList = world.resolve(UnresolvedType.forName("java.util.List"));
+               javaUtilList = javaUtilList.getGenericType();
+               if (javaUtilList == null) return;  // for < 1.5
+               ResolvedMember[] methods = javaUtilList.getDeclaredMethods();
+               ResolvedMember add = null;
+               for (int i = 0; i < methods.length; i++) {
+                               if (methods[i].getName().equals("add")) {
+                                       add = methods[i];
+                                       break;
+                               }
+                       }
+               if (add != null) { // so can run on non-Java 5
+//                     System.out.println("got it");
+                       assertTrue(add.canBeParameterized());
+               }               
+           }
+           
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java
new file mode 100644 (file)
index 0000000..0d84c13
--- /dev/null
@@ -0,0 +1,58 @@
+/* *******************************************************************
+ * 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: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.weaver.bcel.BcelWorld;
+
+import junit.framework.TestCase;
+
+// test cases for Adrian's additions to ReferenceType
+// XXX - couldn't find any unit test cases for the rest of the ReferenceType class
+public class ReferenceTypeTestCase extends TestCase {
+
+       public void testIsRawTrue() {
+               BcelWorld world = new BcelWorld();
+               world.setBehaveInJava5Way(true);
+               UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class");
+               ResolvedType rtx = world.resolve(javaLangClass);
+               assertTrue("Resolves to reference type",(rtx instanceof ReferenceType));
+               ReferenceType rt = (ReferenceType) rtx;
+               assertTrue("java.lang.Class is raw",rt.isRawType());
+       }
+       
+       public void testIsRawFalse() {
+               BcelWorld world = new BcelWorld();
+               world.setBehaveInJava5Way(true);
+               UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object");
+               ResolvedType rtx = world.resolve(javaLangObject);
+               assertTrue("Resolves to reference type",(rtx instanceof ReferenceType));
+               ReferenceType rt = (ReferenceType) rtx;
+               assertFalse("java.lang.Object is  not raw",rt.isRawType());             
+       }
+       
+       public void testIsGenericTrue() {
+               BcelWorld world = new BcelWorld();
+               world.setBehaveInJava5Way(true);
+               UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class");
+               ResolvedType rtx = world.resolve(javaLangClass);
+               assertTrue("java.lang.Class has underpinning generic type",rtx.getGenericType().isGenericType());
+       }
+       
+       public void testIsGenericFalse() {
+               BcelWorld world = new BcelWorld();
+               world.setBehaveInJava5Way(true);
+               UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object");
+               ResolvedType rtx = world.resolve(javaLangObject);
+               assertFalse(rtx.isGenericType());
+       }
+       
+}
index decb97bea1b0e2fc9f62f3dbcf84314b181e4c04..94f13adf4206cb1edfa0570a3ee67699111457d7 100644 (file)
 
 package org.aspectj.weaver;
 
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateTest;
 
+
 public class TestJava5ReflectionBasedReferenceTypeDelegate extends ReflectionBasedReferenceTypeDelegateTest {
        
        public static Test suite() {
@@ -73,4 +75,4 @@ public class TestJava5ReflectionBasedReferenceTypeDelegate extends ReflectionBas
         assertTrue("Superclass for Map generic type should be Object but was "+rt2,rt2.equals(UnresolvedType.OBJECT));       
     }
        
-}
+}
\ No newline at end of file
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java
new file mode 100644 (file)
index 0000000..15edbae
--- /dev/null
@@ -0,0 +1,49 @@
+/* *******************************************************************
+ * 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: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.weaver.bcel.BcelWorld;
+
+import junit.framework.TestCase;
+
+/**
+ * @author colyer
+ *
+ */
+public class TypeVariableReferenceTypeTestCase extends TestCase {
+
+       ReferenceType javaLangClass;
+       ReferenceType javaLangObject;
+       BoundedReferenceType extendsClass;
+       BoundedReferenceType superClass;
+       BoundedReferenceType extendsWithExtras;
+       BcelWorld world;
+       
+       public void testConstructionByNameAndVariable() {
+               TypeVariable tv = new TypeVariable("T",javaLangClass);
+               TypeVariableReferenceType tvrt = new TypeVariableReferenceType(tv,world);
+               assertEquals("T",tvrt.getTypeVariable().getName());
+               assertEquals(javaLangClass,tvrt.getUpperBound());
+       }
+       
+       protected void setUp() throws Exception {
+               super.setUp();
+               world = new BcelWorld();
+               javaLangClass = (ReferenceType) world.resolve(UnresolvedType.forName("java/lang/Class"));
+               javaLangObject = (ReferenceType) world.resolve(UnresolvedType.OBJECT);
+               extendsClass = new BoundedReferenceType(javaLangClass,true,world);
+               superClass = new BoundedReferenceType(javaLangClass,false,world);
+               extendsWithExtras = new BoundedReferenceType(javaLangClass,true,world,
+                               new ReferenceType[] {(ReferenceType)world.resolve(UnresolvedType.forName("java/util/List"))});
+       }
+
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java
new file mode 100644 (file)
index 0000000..ec2547a
--- /dev/null
@@ -0,0 +1,125 @@
+/* *******************************************************************
+ * 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: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+import org.aspectj.weaver.bcel.BcelWorld;
+
+import junit.framework.TestCase;
+
+public class TypeVariableTestCase extends TestCase {
+       
+       private UnresolvedType javaLangNumber;
+       private UnresolvedType javaLangDouble;
+       private UnresolvedType javaUtilList;
+       private UnresolvedType javaIoSerializable;
+       private World world;
+       
+       public void testDefaultBounds() {
+               TypeVariable tv = new TypeVariable("T");
+               assertEquals("Object",UnresolvedType.OBJECT,tv.getUpperBound());
+               assertEquals("no additional bounds",0,tv.getAdditionalInterfaceBounds().length);
+               assertNull("no lower bound",tv.getLowerBound());
+       }
+       
+       public void testName() {
+               TypeVariable tv = new TypeVariable("T");
+               assertEquals("T",tv.getName());
+       }
+       
+       public void testUpperBound() {
+               TypeVariable tv = new TypeVariable("N",javaLangNumber);
+               assertEquals("java.lang.Number",javaLangNumber,tv.getUpperBound());
+       }
+       
+       public void testAdditionalUpperBounds() {
+               TypeVariable tv = new TypeVariable("E",UnresolvedType.OBJECT,new UnresolvedType[] {javaUtilList});
+               assertEquals("1 additional bound",1,tv.getAdditionalInterfaceBounds().length);
+               assertEquals("java.util.List",javaUtilList,tv.getAdditionalInterfaceBounds()[0]);
+       }
+       
+       public void testLowerBound() {
+               TypeVariable tv = new TypeVariable("X",UnresolvedType.OBJECT,new UnresolvedType[0],javaLangDouble);
+               assertEquals("java.lang.Double",javaLangDouble,tv.getLowerBound());
+       }
+       
+       public void testResolution() {
+               TypeVariable tv = new TypeVariable(
+                                       "T",
+                                       javaLangNumber,
+                                       new UnresolvedType[] {javaUtilList},
+                                       javaLangDouble
+                               );
+               tv.resolve(world);
+               assertEquals("resolved number",javaLangNumber.resolve(world),tv.getUpperBound());
+               assertEquals("resolved list",javaUtilList.resolve(world),
+                                                                       tv.getAdditionalInterfaceBounds()[0]);
+               assertEquals("resolved double",javaLangDouble.resolve(world),tv.getLowerBound());
+       }
+       
+       public void testBindWithoutResolve() {
+               TypeVariable tv = new TypeVariable("X");
+               try {
+                       tv.canBeBoundTo(null);
+                       fail ("Should throw illegal state exception");
+               } catch (IllegalStateException ex) {}
+       }
+       
+       public void testCanBindToUpperMatch() {
+               TypeVariable tv = new TypeVariable("X",javaLangNumber);
+               tv.resolve(world);
+               assertTrue(tv.canBeBoundTo(javaLangDouble.resolve(world)));
+       }
+       
+       public void testCanBindToUpperFail() {
+               TypeVariable tv = new TypeVariable("X",javaLangNumber);
+               tv.resolve(world);
+               assertFalse(tv.canBeBoundTo(UnresolvedType.OBJECT.resolve(world)));             
+       }
+       
+       public void testCanBindToInterfaceMatch() {
+               TypeVariable tv = new TypeVariable("T",javaLangNumber,new UnresolvedType[] {javaIoSerializable});
+               tv.resolve(world);
+               assertTrue(tv.canBeBoundTo(javaLangDouble.resolve(world)));
+       }
+       
+       public void testCanBindToInterfaceFail() {
+               TypeVariable tv = new TypeVariable("T",javaLangNumber,new UnresolvedType[] {javaUtilList});
+               tv.resolve(world);
+               assertFalse(tv.canBeBoundTo(javaLangDouble.resolve(world)));    
+       }
+       
+       public void testCanBindToLowerMatch() {
+               TypeVariable tv = new TypeVariable("T",javaLangNumber,new UnresolvedType[0],javaLangDouble);
+               tv.resolve(world);
+               assertTrue(tv.canBeBoundTo(javaLangNumber.resolve(world)));
+       }
+       
+       public void testCanBindToLowerFail() {
+               TypeVariable tv = new TypeVariable("T",javaLangNumber,new UnresolvedType[0],javaLangNumber);
+               tv.resolve(world);
+               assertFalse(tv.canBeBoundTo(javaLangDouble.resolve(world)));            
+       }
+       
+       protected void setUp() throws Exception {
+               super.setUp();
+               javaLangNumber = UnresolvedType.forSignature("Ljava/lang/Number;");
+               javaLangDouble = UnresolvedType.forSignature("Ljava/lang/Double;");
+               javaIoSerializable = UnresolvedType.forSignature("Ljava/io/Serializable;");
+               javaUtilList = UnresolvedType.forSignature("Ljava/util/List;");
+               world = new BcelWorld();
+       }
+
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/AsmDelegateTests5.java b/weaver5/java5-testsrc/org/aspectj/weaver/bcel/AsmDelegateTests5.java
new file mode 100644 (file)
index 0000000..f88b2c3
--- /dev/null
@@ -0,0 +1,147 @@
+/* *******************************************************************
+ * Copyright (c) 2006 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://www.eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *     Andy Clement     initial implementation 
+ *     Matthew Webster  move Java 5 tests           
+ * ******************************************************************/
+
+
+package org.aspectj.weaver.bcel;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.aspectj.weaver.AbstractWorldTestCase;
+import org.aspectj.weaver.BcweaverTests;
+import org.aspectj.weaver.ResolvedMember;
+import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.TypeVariable;
+import org.aspectj.weaver.UnresolvedType;
+import org.aspectj.weaver.World;
+
+
+/**
+ * This is a test case for the nameType parts of worlds.
+ */
+public class AsmDelegateTests5 extends AbstractWorldTestCase {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite(AsmDelegateTests5.class.getName());
+               suite.addTestSuite(AsmDelegateTests5.class);
+               return suite;
+       }
+
+    private final BcelWorld world = new BcelWorld(BcweaverTests.TESTDATA_PATH+"/forAsmDelegateTesting/stuff.jar");
+
+    public AsmDelegateTests5(String name) {
+        super(name);
+    }
+
+       protected World getWorld() {
+               return world;
+       }
+       
+       // --- testcode
+
+    /**
+     * Methods are transformed according to generic signatures - this checks 
+     * that some of the generic methods in java.lang.Class appear the same 
+     * whether viewed through an ASM or a BCEL delegate.
+     */
+    public void testCompareGenericMethods() {
+        BcelWorld slowWorld = new BcelWorld();
+        slowWorld.setFastDelegateSupport(false);
+        slowWorld.setBehaveInJava5Way(true);
+        
+        BcelWorld fastWorld = new BcelWorld();
+        fastWorld.setBehaveInJava5Way(true);
+
+        ResolvedType bcelJavaLangClass = slowWorld.resolve(UnresolvedType.forName("java.lang.Class"));
+        ResolvedType  asmJavaLangClass = fastWorld.resolve(UnresolvedType.forName("java.lang.Class"));
+        
+        bcelJavaLangClass = bcelJavaLangClass.getGenericType();
+        asmJavaLangClass  = asmJavaLangClass.getGenericType();
+       
+       ResolvedMember[] bcelMethods = bcelJavaLangClass.getDeclaredMethods();
+       ResolvedMember[]  asmMethods = asmJavaLangClass.getDeclaredMethods();
+       
+       for (int i = 0; i < bcelMethods.length; i++) {
+               bcelMethods[i].setParameterNames(null); // forget them, asm delegates dont currently know them
+               String one = bcelMethods[i].toDebugString();
+               String two = asmMethods[i].toDebugString();
+               if (!one.equals(two)) {
+                       fail("These methods look different when viewed through ASM or BCEL\nBCEL='"+bcelMethods[i].toDebugString()+
+                                "'\n ASM='"+asmMethods[i].toDebugString()+"'");
+               }
+               // If one is parameterized, check the other is...
+               if (bcelMethods[i].canBeParameterized()) {
+                       assertTrue("ASM method '"+asmMethods[i].toDebugString()+"' can't be parameterized whereas its' BCEL variant could",
+                                      asmMethods[i].canBeParameterized());
+               }
+                       
+               }
+       
+       // Let's take a special look at:
+       //   public <U> Class<? extends U> asSubclass(Class<U> clazz)
+       ResolvedMember bcelSubclassMethod = null;
+       for (int i = 0; i < bcelMethods.length; i++) {
+                       if (bcelMethods[i].getName().equals("asSubclass")) { bcelSubclassMethod = bcelMethods[i]; break; }
+               }
+       ResolvedMember asmSubclassMethod = null;
+       for (int i = 0; i < asmMethods.length; i++) {
+                       if (asmMethods[i].getName().equals("asSubclass")) { asmSubclassMethod = asmMethods[i];break;    }
+               }
+       
+       TypeVariable[] tvs = bcelSubclassMethod.getTypeVariables();
+       assertTrue("should have one type variable on the bcel version but found: "+format(tvs),tvs!=null && tvs.length==1);
+        tvs = asmSubclassMethod.getTypeVariables();
+       assertTrue("should have one type variable on the asm version but found: "+format(tvs),tvs!=null && tvs.length==1);
+
+    }
+    
+    private String format(TypeVariable[] tvs) {
+       if (tvs==null) return "null";
+       StringBuffer s = new StringBuffer();
+       s.append("[");
+       for (int i = 0; i < tvs.length; i++) {
+                       s.append(tvs[i]);
+                       if ((i+1)<tvs.length) s.append(",");
+               }
+       s.append("]");
+       return s.toString();
+    }
+    
+    public void testCompareGenericFields() {
+        BcelWorld slowWorld = new BcelWorld();
+        slowWorld.setFastDelegateSupport(false);
+        slowWorld.setBehaveInJava5Way(true);
+        
+        BcelWorld fastWorld = new BcelWorld();
+        fastWorld.setBehaveInJava5Way(true);
+
+        ResolvedType bcelJavaLangClass = slowWorld.resolve(UnresolvedType.forName("java.lang.Class"));
+        ResolvedType  asmJavaLangClass = fastWorld.resolve(UnresolvedType.forName("java.lang.Class"));
+        
+        bcelJavaLangClass = bcelJavaLangClass.getGenericType();
+        asmJavaLangClass = asmJavaLangClass.getGenericType();
+       
+       ResolvedMember[] bcelFields = bcelJavaLangClass.getDeclaredFields();
+       ResolvedMember[]  asmFields = asmJavaLangClass.getDeclaredFields();
+       
+       for (int i = 0; i < bcelFields.length; i++) {
+               UnresolvedType bcelFieldType = bcelFields[i].getGenericReturnType();
+               UnresolvedType asmFieldType = asmFields[i].getGenericReturnType();
+               if (!bcelFields[i].getGenericReturnType().toDebugString().equals(asmFields[i].getGenericReturnType().toDebugString())) {
+                       fail("These fields look different when viewed through ASM or BCEL\nBCEL='"+bcelFieldType.toDebugString()+
+                                "'\n ASM='"+asmFieldType.toDebugString()+"'");
+               }
+               }
+    }
+    
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java
new file mode 100644 (file)
index 0000000..28cf82f
--- /dev/null
@@ -0,0 +1,71 @@
+/* *******************************************************************
+ * 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: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver.bcel;
+
+import junit.framework.TestCase;
+
+import org.aspectj.apache.bcel.Repository;
+import org.aspectj.apache.bcel.classfile.GenericSignatureParser;
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.apache.bcel.classfile.Signature;
+import org.aspectj.weaver.UnresolvedType;
+
+/**
+ * @author colyer
+ *
+ */
+public class BcelGenericSignatureToTypeXTestCase extends TestCase {
+
+       public void testEnumFromHell() throws Exception {
+               BcelWorld world = new BcelWorld();
+               JavaClass javaLangEnum = Repository.lookupClass("java/lang/Enum");
+               Signature.ClassSignature cSig = javaLangEnum.getGenericClassTypeSignature();
+               UnresolvedType superclass = 
+                       BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                                       cSig.superclassSignature,
+                                       cSig.formalTypeParameters,
+                                       world
+                                       );
+               assertEquals("Ljava/lang/Object;",superclass.getSignature());
+               assertEquals("2 superinterfaces",2,cSig.superInterfaceSignatures.length);
+               UnresolvedType comparable = 
+                       BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                                       cSig.superInterfaceSignatures[0],
+                                       cSig.formalTypeParameters,
+                                       world
+                                       );              
+               assertEquals("Pjava/lang/Comparable<TE;>;",comparable.getSignature());
+               UnresolvedType serializable = 
+                       BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                                       cSig.superInterfaceSignatures[1],
+                                       cSig.formalTypeParameters,
+                                       world
+                                       );
+               assertEquals("Ljava/io/Serializable;",serializable.getSignature());
+       }
+       
+       public void testColonColon() throws Exception {
+               BcelWorld world = new BcelWorld();
+               Signature.ClassSignature cSig = new GenericSignatureParser().parseAsClassSignature("<T::Ljava/io/Serializable;>Ljava/lang/Object;Ljava/lang/Comparable<TT;>;");
+               UnresolvedType resolved = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                               cSig.superclassSignature,
+                               cSig.formalTypeParameters,
+                               world);
+               assertEquals("Ljava/lang/Object;",resolved.getSignature());
+               UnresolvedType resolvedInt = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(
+                               cSig.superInterfaceSignatures[0],
+                               cSig.formalTypeParameters,
+                               world);
+               
+       }
+       
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java
new file mode 100644 (file)
index 0000000..de3fa02
--- /dev/null
@@ -0,0 +1,471 @@
+/* *******************************************************************
+ * 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://www.eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *     Adrian Colyer     initial implementation 
+ * ******************************************************************/
+package org.aspectj.weaver.patterns;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.aspectj.weaver.BoundedReferenceType;
+import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.TypeFactory;
+import org.aspectj.weaver.UnresolvedType;
+import org.aspectj.weaver.VersionedDataInputStream;
+import org.aspectj.weaver.World;
+import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
+import org.aspectj.weaver.bcel.BcelWorld;
+
+// TODO write test cases for instanceof matching
+
+ public class WildTypePatternResolutionTestCase extends TestCase {
+
+        private World world;
+        private Bindings bindings;
+        private SimpleScope scope;
+        private ResolvedType javaUtilList;
+        private ResolvedType javaLangString;
+        private ResolvedType javaUtilListOfString;
+        private ResolvedType javaUtilListOfDouble;
+        private ResolvedType javaUtilListOfSomething;
+        
+        /**
+         * Foo where Foo exists and is generic
+         *    Parser creates WildTypePattern namePatterns={Foo}
+         *    resolveBindings resolves Foo to RT(Foo - raw)
+         *                    return ExactTypePattern(LFoo;)
+         */
+        public void testSimpleFoo() {
+                TypePattern rtp = resolveWildTypePattern("List", false);
+                
+                assertTrue("resolves to exact type",rtp instanceof ExactTypePattern);
+                UnresolvedType exactType = rtp.getExactType();
+                assertTrue(exactType.isRawType());
+                assertEquals("Ljava/util/List;",exactType.getSignature());
+                
+                ResolvedType rt = exactType.resolve(world);
+                assertEquals("Ljava/util/List;",rt.getSignature());
+                assertTrue(rt.isRawType());
+                
+                ExactTypePattern etp = (ExactTypePattern) writeAndRead((ExactTypePattern)rtp);
+                exactType = etp.getExactType();
+
+                assertEquals("Ljava/util/List;",exactType.getSignature());
+                
+                rt = exactType.resolve(world);
+                assertEquals("Ljava/util/List;",rt.getSignature());
+                assertTrue(rt.isRawType());             
+                
+                assertTrue("matches List",etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue());
+                assertTrue("matches generic List",etp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue());
+                assertTrue("matches parameterized list",etp.matches(javaUtilListOfString,TypePattern.STATIC).alwaysTrue());
+                assertTrue("does not match String",etp.matches(javaLangString,TypePattern.STATIC).alwaysFalse());
+        }
+        
+        /**
+         * Foo<String> where Foo exists and String meets the bounds
+         *    Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{String}
+         *    resolveBindings resolves typeParameters to ExactTypePattern(String)
+         *                    resolves Foo to RT(Foo)
+         *                    returns ExactTypePattern(PFoo<String>; - parameterized)
+         */
+        public void testParameterized() {
+                TypePattern rtp = resolveWildTypePattern("List<String>", false);
+                
+                assertTrue("resolves to exact type",rtp instanceof ExactTypePattern);
+                UnresolvedType exactType = rtp.getExactType();
+                assertTrue(exactType.isParameterizedType());
+                assertEquals("Pjava/util/List<Ljava/lang/String;>;",exactType.getSignature());
+                
+                ResolvedType rt = exactType.resolve(world);
+                assertEquals("Pjava/util/List<Ljava/lang/String;>;",rt.getSignature());
+                assertTrue(rt.isParameterizedType());
+
+                ExactTypePattern etp = (ExactTypePattern) writeAndRead((ExactTypePattern)rtp);
+                exactType = etp.getExactType();
+
+                assertEquals("Pjava/util/List<Ljava/lang/String;>;",rt.getSignature());
+                assertTrue(rt.isParameterizedType());
+
+                rt = exactType.resolve(world);
+                assertEquals("Pjava/util/List<Ljava/lang/String;>;",rt.getSignature());
+                assertTrue(rt.isParameterizedType());
+
+                assertFalse("does not match List",etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match generic List",etp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue());
+                assertTrue("matches parameterized list",etp.matches(javaUtilListOfString,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list of double",etp.matches(javaUtilListOfDouble,TypePattern.STATIC).alwaysTrue());
+                assertTrue("does not match String",etp.matches(javaLangString,TypePattern.STATIC).alwaysFalse());
+
+        }
+        
+        /**
+         * Foo<Str*> where Foo exists and takes one bound
+         *    Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{Str*}
+         *    resolveBindings resolves typeParameters to WTP{Str*}
+         *                    resolves Foo to RT(Foo)
+         *                    returns WildTypePattern(name = Foo, typeParameters = WTP{Str*} isGeneric=false)                    
+         */
+        public void testParameterizedWildCard() {
+                TypePattern rtp = resolveWildTypePattern("List<Str*>", false);
+                
+                assertTrue("resolves to WildTypePattern",rtp instanceof WildTypePattern);
+                assertTrue("one type parameter", rtp.typeParameters.size() == 1);
+                assertTrue("missing",ResolvedType.isMissing(rtp.getExactType()));
+                
+                WildTypePattern wtp = (WildTypePattern) writeAndRead(rtp);
+                assertTrue("one type parameter", wtp.typeParameters.size() == 1);
+                assertTrue("missing",ResolvedType.isMissing(wtp.getExactType()));
+                assertEquals("Str*",wtp.getTypeParameters().getTypePatterns()[0].toString());
+                
+                assertFalse("does not match List",wtp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match generic List",wtp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue());
+                assertTrue("matches parameterized list",wtp.matches(javaUtilListOfString,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list of double",wtp.matches(javaUtilListOfDouble,TypePattern.STATIC).alwaysTrue());
+                assertTrue("does not match String",wtp.matches(javaLangString,TypePattern.STATIC).alwaysFalse());               
+        }
+        
+        /**
+         * Fo*<String> 
+         *    Parser creates WildTypePattern namePatterns = {Fo*}, typeParameters=WTP{String}
+         *    resolveBindings resolves typeParameters to ETP{String}
+         *                    returns WildTypePattern(name = Fo*, typeParameters = ETP{String} isGeneric=false)                    
+         */
+        public void testWildcardParameterized() {
+                TypePattern rtp = resolveWildTypePattern("Li*<String>", false);
+                
+                assertTrue("resolves to WildTypePattern",rtp instanceof WildTypePattern);
+                assertTrue("one type parameter", rtp.typeParameters.size() == 1);
+                assertEquals("Ljava/lang/String;",rtp.typeParameters.getTypePatterns()[0].getExactType().getSignature());
+                
+                WildTypePattern wtp = (WildTypePattern) writeAndRead(rtp);
+                assertTrue("one type parameter", wtp.typeParameters.size() == 1);
+                assertEquals("Ljava/lang/String;",wtp.typeParameters.getTypePatterns()[0].getExactType().getSignature());
+                
+                assertFalse("does not match List",wtp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match generic List",wtp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue());
+                assertTrue("matches parameterized list",wtp.matches(javaUtilListOfString,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list of double",wtp.matches(javaUtilListOfDouble,TypePattern.STATIC).alwaysTrue());
+                assertTrue("does not match String",wtp.matches(javaLangString,TypePattern.STATIC).alwaysFalse());                                               
+        }
+        
+        /**
+         * Foo<?>
+         */
+        public void testSomething() {
+                TypePattern rtp = resolveWildTypePattern("List<?>", false);
+
+                assertTrue("resolves to exact type",rtp instanceof ExactTypePattern);
+                UnresolvedType exactType = rtp.getExactType();
+                assertTrue(exactType.isParameterizedType());
+                assertEquals("Pjava/util/List<?>;",exactType.getSignature());
+
+                ExactTypePattern etp = (ExactTypePattern) writeAndRead(rtp);
+                exactType = etp.getExactType();
+                assertTrue(exactType.isParameterizedType());
+                assertEquals("Pjava/util/List<?>;",exactType.getSignature());
+
+                assertFalse("does not match List",etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match generic List",etp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list",etp.matches(javaUtilListOfString,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list of double",etp.matches(javaUtilListOfDouble,TypePattern.STATIC).alwaysTrue());
+                assertTrue("does not match String",etp.matches(javaLangString,TypePattern.STATIC).alwaysFalse());                                               
+               
+                assertTrue("matches list of something",etp.matches(javaUtilListOfSomething,TypePattern.STATIC).alwaysTrue());
+        }
+        
+        /**
+         * Foo<? extends Number>
+         */
+        public void testSomethingExtends() {
+                TypePattern rtp = resolveWildTypePattern("List<? extends Number>", false);
+
+                assertTrue("resolves to exact type",rtp instanceof ExactTypePattern);
+                UnresolvedType exactType = rtp.getExactType();
+                assertTrue(exactType.isParameterizedType());
+                assertEquals("Pjava/util/List<+Ljava/lang/Number;>;",exactType.getSignature());
+                assertTrue("got a bounded reference type",exactType.getTypeParameters()[0] instanceof BoundedReferenceType);
+
+                ExactTypePattern etp = (ExactTypePattern) writeAndRead(rtp);
+                exactType = etp.getExactType();
+                exactType = exactType.resolve(world);
+                assertTrue(exactType.isParameterizedType());
+                assertEquals("Pjava/util/List<+Ljava/lang/Number;>;",exactType.getSignature());
+                assertTrue("got a bounded reference type",exactType.getTypeParameters()[0] instanceof BoundedReferenceType);
+
+                assertFalse("does not match List",etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match generic List",etp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list",etp.matches(javaUtilListOfString,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list of double",etp.matches(javaUtilListOfDouble,TypePattern.STATIC).alwaysTrue());
+                assertTrue("does not match String",etp.matches(javaLangString,TypePattern.STATIC).alwaysFalse());                                               
+                assertFalse("does not match list of something",etp.matches(javaUtilListOfSomething,TypePattern.STATIC).alwaysTrue());
+                
+                ResolvedType listOfNumber =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {UnresolvedType.forName("java.lang.Number").resolve(world)}, 
+                                               world);
+                
+                ResolvedType listOfDouble = 
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {UnresolvedType.forName("java.lang.Double").resolve(world)}, 
+                                               world);
+                        
+                assertFalse("does not match list of number",etp.matches(listOfNumber,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match list of double",etp.matches(listOfDouble,TypePattern.STATIC).alwaysTrue());
+
+                ResolvedType extendsNumber = TypeFactory.createTypeFromSignature("+Ljava/lang/Number;").resolve(world);
+                ResolvedType listOfExtendsNumber =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {extendsNumber}, 
+                                               world);
+
+                assertTrue("matches list of ? extends number",etp.matches(listOfExtendsNumber,TypePattern.STATIC).alwaysTrue());
+
+        }
+        
+        /** 
+         * Foo<? extends Number+>
+         */
+        public void testSomethingExtendsPattern() {
+                TypePattern rtp = resolveWildTypePattern("List<? extends Number+>", false);
+
+                assertTrue("resolves to wild type pattern",rtp instanceof WildTypePattern);
+                assertEquals("one type parameter",1,rtp.getTypeParameters().size());
+                TypePattern tp = rtp.getTypeParameters().getTypePatterns()[0];
+                assertTrue("parameter is wild",tp instanceof WildTypePattern);
+                WildTypePattern tpwtp = (WildTypePattern) tp;
+                assertEquals("?",tpwtp.getNamePatterns()[0].maybeGetSimpleName());
+                assertEquals("java.lang.Number+",tpwtp.upperBound.toString());
+                
+                
+                WildTypePattern wtp = (WildTypePattern) writeAndRead(rtp);
+                assertEquals("one type parameter",1,wtp.getTypeParameters().size());
+                tp = rtp.getTypeParameters().getTypePatterns()[0];
+                assertTrue("parameter is wild",tp instanceof WildTypePattern);
+                tpwtp = (WildTypePattern) tp;
+                assertEquals("?",tpwtp.getNamePatterns()[0].maybeGetSimpleName());
+                assertEquals("java.lang.Number+",tpwtp.upperBound.toString());
+                
+                assertFalse("does not match List",wtp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match generic List",wtp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list",wtp.matches(javaUtilListOfString,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list of double",wtp.matches(javaUtilListOfDouble,TypePattern.STATIC).alwaysTrue());
+                assertTrue("does not match String",wtp.matches(javaLangString,TypePattern.STATIC).alwaysFalse());                                               
+                assertFalse("does not match list of something",wtp.matches(javaUtilListOfSomething,TypePattern.STATIC).alwaysTrue());
+                
+                ResolvedType listOfNumber =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {UnresolvedType.forName("java.lang.Number").resolve(world)}, 
+                                               world);
+                
+                ResolvedType listOfDouble = 
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {UnresolvedType.forName("java.lang.Double").resolve(world)}, 
+                                               world);
+                        
+                assertFalse("does not match list of number",wtp.matches(listOfNumber,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match list of double",wtp.matches(listOfDouble,TypePattern.STATIC).alwaysTrue());
+
+                ResolvedType extendsNumber = TypeFactory.createTypeFromSignature("+Ljava/lang/Number;").resolve(world);
+                ResolvedType listOfExtendsNumber =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {extendsNumber}, 
+                                               world);
+
+                assertTrue("matches list of ? extends number",wtp.matches(listOfExtendsNumber,TypePattern.STATIC).alwaysTrue());                
+
+                ResolvedType extendsDouble = TypeFactory.createTypeFromSignature("+Ljava/lang/Double;").resolve(world);
+                ResolvedType listOfExtendsDouble =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {extendsDouble}, 
+                                               world);
+
+                assertTrue("matches list of ? extends double",wtp.matches(listOfExtendsDouble,TypePattern.STATIC).alwaysTrue());
+
+        }
+        
+        
+        /**
+         * Foo<? extends Num*>
+         */
+        public void testSomethingExtendsPatternv2() {
+                TypePattern rtp = resolveWildTypePattern("List<? extends Num*>", false);
+
+                assertTrue("resolves to wild type pattern",rtp instanceof WildTypePattern);
+                assertEquals("one type parameter",1,rtp.getTypeParameters().size());
+                TypePattern tp = rtp.getTypeParameters().getTypePatterns()[0];
+                assertTrue("parameter is wild",tp instanceof WildTypePattern);
+                WildTypePattern tpwtp = (WildTypePattern) tp;
+                assertEquals("?",tpwtp.getNamePatterns()[0].maybeGetSimpleName());
+                assertEquals("Num*",tpwtp.upperBound.toString());
+                
+                
+                WildTypePattern wtp = (WildTypePattern) writeAndRead(rtp);
+                assertEquals("one type parameter",1,wtp.getTypeParameters().size());
+                tp = rtp.getTypeParameters().getTypePatterns()[0];
+                assertTrue("parameter is wild",tp instanceof WildTypePattern);
+                tpwtp = (WildTypePattern) tp;
+                assertEquals("?",tpwtp.getNamePatterns()[0].maybeGetSimpleName());
+                assertEquals("Num*",tpwtp.upperBound.toString());
+                
+                assertFalse("does not match List",wtp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match generic List",wtp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list",wtp.matches(javaUtilListOfString,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list of double",wtp.matches(javaUtilListOfDouble,TypePattern.STATIC).alwaysTrue());
+                assertTrue("does not match String",wtp.matches(javaLangString,TypePattern.STATIC).alwaysFalse());                                               
+                assertFalse("does not match list of something",wtp.matches(javaUtilListOfSomething,TypePattern.STATIC).alwaysTrue());
+                
+                ResolvedType listOfNumber =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {UnresolvedType.forName("java.lang.Number").resolve(world)}, 
+                                               world);
+                
+                ResolvedType listOfDouble = 
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {UnresolvedType.forName("java.lang.Double").resolve(world)}, 
+                                               world);
+                        
+                assertFalse("does not match list of number",wtp.matches(listOfNumber,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match list of double",wtp.matches(listOfDouble,TypePattern.STATIC).alwaysTrue());
+
+                ResolvedType extendsNumber = TypeFactory.createTypeFromSignature("+Ljava/lang/Number;").resolve(world);
+                ResolvedType listOfExtendsNumber =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {extendsNumber}, 
+                                               world);
+
+                assertTrue("matches list of ? extends number",wtp.matches(listOfExtendsNumber,TypePattern.STATIC).alwaysTrue());                
+
+                ResolvedType extendsDouble = TypeFactory.createTypeFromSignature("+Ljava/lang/Double;").resolve(world);
+                ResolvedType listOfExtendsDouble =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {extendsDouble}, 
+                                               world);
+
+                assertFalse("does not match list of ? extends double",wtp.matches(listOfExtendsDouble,TypePattern.STATIC).alwaysTrue());                                                
+        }
+        
+        /**
+         * Foo<? super Number>
+         * 
+         */
+        public void testSomethingSuper() {
+                TypePattern rtp = resolveWildTypePattern("List<? super Double>", false);
+
+                assertTrue("resolves to exact type",rtp instanceof ExactTypePattern);
+                UnresolvedType exactType = rtp.getExactType();
+                assertTrue(exactType.isParameterizedType());
+                assertEquals("Pjava/util/List<-Ljava/lang/Double;>;",exactType.getSignature());
+                assertTrue("got a bounded reference type",exactType.getTypeParameters()[0] instanceof BoundedReferenceType);
+
+                ExactTypePattern etp = (ExactTypePattern) writeAndRead(rtp);
+                exactType = etp.getExactType();
+                exactType = exactType.resolve(world);
+                assertTrue(exactType.isParameterizedType());
+                assertEquals("Pjava/util/List<-Ljava/lang/Double;>;",exactType.getSignature());
+                assertTrue("got a bounded reference type",exactType.getTypeParameters()[0] instanceof BoundedReferenceType);
+
+                assertFalse("does not match List",etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match generic List",etp.matches(javaUtilList.getGenericType(),TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list",etp.matches(javaUtilListOfString,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match parameterized list of double",etp.matches(javaUtilListOfDouble,TypePattern.STATIC).alwaysTrue());
+                assertTrue("does not match String",etp.matches(javaLangString,TypePattern.STATIC).alwaysFalse());                                               
+                assertFalse("does not match list of something",etp.matches(javaUtilListOfSomething,TypePattern.STATIC).alwaysTrue());
+                
+                ResolvedType listOfNumber =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {UnresolvedType.forName("java.lang.Number").resolve(world)}, 
+                                               world);
+                
+                ResolvedType listOfDouble = 
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {UnresolvedType.forName("java.lang.Double").resolve(world)}, 
+                                               world);
+                        
+                assertFalse("does not match list of number",etp.matches(listOfNumber,TypePattern.STATIC).alwaysTrue());
+                assertFalse("does not match list of double",etp.matches(listOfDouble,TypePattern.STATIC).alwaysTrue());
+
+                ResolvedType superDouble = TypeFactory.createTypeFromSignature("-Ljava/lang/Double;").resolve(world);
+                ResolvedType listOfSuperDouble =
+                               TypeFactory.createParameterizedType(
+                                               javaUtilList, 
+                                               new UnresolvedType[] {superDouble}, 
+                                               world);
+
+                assertTrue("matches list of ? super double",etp.matches(listOfSuperDouble,TypePattern.STATIC).alwaysTrue());
+        }
+
+        private TypePattern resolveWildTypePattern(String source, boolean requireExact) {
+                WildTypePattern wtp = makeWildTypePattern(source);
+                return wtp.resolveBindings(scope, bindings, false, requireExact);
+        }
+        
+        private WildTypePattern makeWildTypePattern(String source) {
+                PatternParser parser = new PatternParser(source);
+                return (WildTypePattern) parser.parseTypePattern();
+        }
+        
+        private TypePattern writeAndRead(TypePattern etp) {
+                try {
+                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                        DataOutputStream dos = new DataOutputStream(baos);
+                        etp.write(dos);
+                        dos.flush();
+                        dos.close();
+                        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+                        VersionedDataInputStream in = new VersionedDataInputStream(bais);
+                        in.setVersion(new WeaverVersionInfo());
+                        TypePattern ret = TypePattern.read(in, null);
+                        return ret;
+                } catch (IOException ioEx) {
+                        fail(ioEx + " thrown during serialization");
+                }
+                return null;
+        }
+        
+        protected void setUp() throws Exception {
+               super.setUp();
+               this.world = new BcelWorld();
+               this.world.setBehaveInJava5Way(true);
+               this.bindings = new Bindings(0);
+               this.scope = new SimpleScope(world , new FormalBinding[] {});           
+               this.scope.setImportedPrefixes(new String[] {"java.io.","java.util.","java.lang."});
+               this.javaLangString = UnresolvedType.forName("java.lang.String").resolve(world);
+               this.javaUtilList = UnresolvedType.forName("java.util.List").resolve(world);
+               this.javaUtilListOfString = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] {javaLangString}, world);
+               this.javaUtilListOfDouble = 
+                       TypeFactory.createParameterizedType(
+                                       javaUtilList, 
+                                       new UnresolvedType[] {UnresolvedType.forName("java.lang.Double").resolve(world)}, 
+                                       world);
+               this.javaUtilListOfSomething = 
+                       TypeFactory.createParameterizedType(
+                                       javaUtilList, 
+                                       new UnresolvedType[] {UnresolvedType.SOMETHING.resolve(world)}, 
+                                       world);
+       }
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java
new file mode 100644 (file)
index 0000000..f9bef9c
--- /dev/null
@@ -0,0 +1,306 @@
+/* *******************************************************************
+ * 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: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver.reflect;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.aspectj.bridge.IMessageHandler;
+import org.aspectj.weaver.ReferenceType;
+import org.aspectj.weaver.ResolvedMember;
+import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.UnresolvedType;
+import org.aspectj.weaver.bcel.BcelWorld;
+
+public abstract class ReflectionBasedReferenceTypeDelegateTest extends TestCase {
+
+       protected ReflectionWorld world;
+       private ResolvedType objectType;
+       private ResolvedType classType;
+       
+       public void testIsAspect() {
+               assertFalse(objectType.isAspect());
+       }
+       
+       public void testIsAnnotationStyleAspect() {
+               assertFalse(objectType.isAnnotationStyleAspect());
+       }
+       
+       public void testIsInterface() {
+               assertFalse(objectType.isInterface());
+               assertTrue(world.resolve("java.io.Serializable").isInterface());
+       }
+       
+       public void testIsEnum() {
+               assertFalse(objectType.isEnum());
+       }
+       
+       public void testIsAnnotation() {
+               assertFalse(objectType.isAnnotation());
+       }
+       
+       public void testIsAnnotationWithRuntimeRetention() {
+               assertFalse(objectType.isAnnotationWithRuntimeRetention());
+       }
+       
+       public void testIsClass() {
+               assertTrue(objectType.isClass());
+               assertFalse(world.resolve("java.io.Serializable").isClass());
+       }
+       
+       public void testIsGeneric() {
+               assertFalse(objectType.isGenericType());
+       }
+       
+       public void testIsExposedToWeaver() {
+               assertFalse(objectType.isExposedToWeaver());
+       }
+       
+       public void testHasAnnotation() {
+               assertFalse(objectType.hasAnnotation(UnresolvedType.forName("Foo")));
+       }
+       
+       public void testGetAnnotations() {
+               assertEquals("no entries",0,objectType.getAnnotations().length);
+       }
+       
+       public void testGetAnnotationTypes() {
+               assertEquals("no entries",0,objectType.getAnnotationTypes().length);
+       }
+       
+       public void testGetTypeVariables() {
+               assertEquals("no entries",0,objectType.getTypeVariables().length);
+       }
+       
+       public void testGetPerClause() {
+               assertNull(objectType.getPerClause());
+       }
+       
+       public void testGetModifiers() {
+               assertEquals(Object.class.getModifiers(),objectType.getModifiers());
+       }
+       
+       public void testGetSuperclass() {
+               assertTrue("Superclass of object should be null, but it is: "+objectType.getSuperclass(),objectType.getSuperclass()==null);
+               assertEquals(objectType,world.resolve("java.lang.Class").getSuperclass());
+               ResolvedType d = world.resolve("reflect.tests.D");
+               assertEquals(world.resolve("reflect.tests.C"),d.getSuperclass());
+       }
+       
+
+       protected int findMethod(String name, ResolvedMember[] methods) {
+               for (int i=0; i<methods.length; i++) {
+                       if (name.equals(methods[i].getName())) {
+                               return i;
+                       }
+               }
+               return -1;
+       }
+       
+       protected int findMethod(String name, int numArgs, ResolvedMember[] methods) {
+               for (int i=0; i<methods.length; i++) {
+                       if (name.equals(methods[i].getName()) && (methods[i].getParameterTypes().length == numArgs)) {
+                               return i;
+                       }
+               }
+               return -1;
+       }
+       
+       public void testGetDeclaredMethods() {
+               ResolvedMember[] methods = objectType.getDeclaredMethods();
+               assertEquals(Object.class.getDeclaredMethods().length + Object.class.getDeclaredConstructors().length, methods.length);
+               
+               ResolvedType c = world.resolve("reflect.tests.C");
+               methods = c.getDeclaredMethods();
+               assertEquals(3,methods.length);
+               int idx = findMethod("foo", methods);
+               assertTrue(idx > -1);
+               
+               assertEquals(world.resolve("java.lang.String"),methods[idx].getReturnType());
+               assertEquals(1, methods[idx].getParameterTypes().length);
+               assertEquals(objectType,methods[idx].getParameterTypes()[0]);
+               assertEquals(1,methods[idx].getExceptions().length);
+               assertEquals(world.resolve("java.lang.Exception"),methods[idx].getExceptions()[0]);
+               int baridx = findMethod("bar", methods);
+               int initidx = findMethod("<init>", methods);
+               assertTrue(baridx > -1);
+               assertTrue(initidx > -1);
+               assertTrue(baridx != initidx && baridx != idx && idx <= 2 && initidx <= 2 && baridx <= 2);
+               
+               ResolvedType d = world.resolve("reflect.tests.D");
+               methods = d.getDeclaredMethods();
+               assertEquals(2,methods.length);
+
+               classType = world.resolve("java.lang.Class");
+               methods = classType.getDeclaredMethods();
+               assertEquals(Class.class.getDeclaredMethods().length + Class.class.getDeclaredConstructors().length, methods.length); 
+       }
+       
+       public void testGetDeclaredFields() {
+               ResolvedMember[] fields = objectType.getDeclaredFields();
+               assertEquals(0,fields.length);
+
+               ResolvedType c = world.resolve("reflect.tests.C");
+               fields = c.getDeclaredFields();
+               
+               assertEquals(2,fields.length);
+               assertEquals("f",fields[0].getName());
+               assertEquals("s",fields[1].getName());
+               assertEquals(ResolvedType.INT,fields[0].getReturnType());
+               assertEquals(world.resolve("java.lang.String"),fields[1].getReturnType());
+       }
+       
+       public void testGetDeclaredInterfaces() {
+               ResolvedType[] interfaces = objectType.getDeclaredInterfaces();
+               assertEquals(0,interfaces.length);
+
+               ResolvedType d = world.resolve("reflect.tests.D");
+               interfaces = d.getDeclaredInterfaces();
+               assertEquals(1,interfaces.length);
+               assertEquals(world.resolve("java.io.Serializable"),interfaces[0]);
+    }
+       
+       public void testGetDeclaredPointcuts() {
+               ResolvedMember[] pointcuts = objectType.getDeclaredPointcuts();
+               assertEquals(0,pointcuts.length);
+       }
+       
+       
+       
+       public void testSerializableSuperclass() {
+               ResolvedType serializableType = world.resolve("java.io.Serializable");
+               ResolvedType superType = serializableType.getSuperclass();
+        assertTrue("Superclass of serializable should be Object but was "+superType,superType.equals(UnresolvedType.OBJECT));    
+
+        BcelWorld bcelworld = new BcelWorld();
+        bcelworld.setBehaveInJava5Way(true);
+        ResolvedType bcelSupertype = bcelworld.resolve(UnresolvedType.SERIALIZABLE).getSuperclass();
+        assertTrue("Should be null but is "+bcelSupertype,bcelSupertype.equals(UnresolvedType.OBJECT));
+       }
+       
+       public void testSubinterfaceSuperclass() {              
+               ResolvedType ifaceType = world.resolve("java.security.Key");
+               ResolvedType superType = ifaceType.getSuperclass();
+               assertTrue("Superclass should be Object but was "+superType,superType.equals(UnresolvedType.OBJECT));  
+
+        BcelWorld bcelworld = new BcelWorld();
+        bcelworld.setBehaveInJava5Way(true);
+        ResolvedType bcelSupertype = bcelworld.resolve("java.security.Key").getSuperclass();
+        assertTrue("Should be null but is "+bcelSupertype,bcelSupertype.equals(UnresolvedType.OBJECT));
+       }
+       
+       public void testVoidSuperclass() {
+               ResolvedType voidType = world.resolve(Void.TYPE);
+               ResolvedType superType = voidType.getSuperclass();
+               assertNull(superType);
+                  
+        BcelWorld bcelworld = new BcelWorld();
+        bcelworld.setBehaveInJava5Way(true);
+        ResolvedType bcelSupertype = bcelworld.resolve("void").getSuperclass();
+        assertTrue("Should be null but is "+bcelSupertype,bcelSupertype==null);
+       }
+
+       public void testIntSuperclass() {
+               ResolvedType voidType = world.resolve(Integer.TYPE);
+               ResolvedType superType = voidType.getSuperclass();
+               assertNull(superType);
+
+        BcelWorld bcelworld = new BcelWorld();
+        bcelworld.setBehaveInJava5Way(true);
+        ResolvedType bcelSupertype = bcelworld.resolve("int").getSuperclass();
+        assertTrue("Should be null but is "+bcelSupertype,bcelSupertype==null);
+       }
+       
+    public void testGenericInterfaceSuperclass_BcelWorldResolution() {
+        BcelWorld bcelworld = new BcelWorld();
+        bcelworld.setBehaveInJava5Way(true);
+        
+        UnresolvedType javaUtilMap = UnresolvedType.forName("java.util.Map");
+        
+        ReferenceType rawType = (ReferenceType) bcelworld.resolve(javaUtilMap);
+        assertTrue("Should be the raw type ?!? "+rawType.getTypekind(),rawType.isRawType());
+        
+        ReferenceType genericType = (ReferenceType)rawType.getGenericType();
+        assertTrue("Should be the generic type ?!? "+genericType.getTypekind(),genericType.isGenericType());
+        
+        ResolvedType rt = rawType.getSuperclass();
+        assertTrue("Superclass for Map raw type should be Object but was "+rt,rt.equals(UnresolvedType.OBJECT));         
+        
+        ResolvedType rt2 = genericType.getSuperclass();
+        assertTrue("Superclass for Map generic type should be Object but was "+rt2,rt2.equals(UnresolvedType.OBJECT));         
+    }
+    
+    // FIXME asc maybe.  The reflection list of methods returned doesn't include <clinit> (the static initializer) ... is that really a problem.
+    public void testCompareSubclassDelegates() {
+       
+       boolean barfIfClinitMissing = false;
+        world.setBehaveInJava5Way(true);
+        
+        BcelWorld bcelWorld = new BcelWorld(getClass().getClassLoader(),IMessageHandler.THROW,null);
+        bcelWorld.setBehaveInJava5Way(true);
+        UnresolvedType javaUtilHashMap = UnresolvedType.forName("java.util.HashMap");
+        ReferenceType rawType =(ReferenceType)bcelWorld.resolve(javaUtilHashMap );
+        
+        ReferenceType rawReflectType =(ReferenceType)world.resolve(javaUtilHashMap );
+        ResolvedMember[] rms1 = rawType.getDelegate().getDeclaredMethods();
+        ResolvedMember[] rms2 = rawReflectType.getDelegate().getDeclaredMethods();
+        StringBuffer errors = new StringBuffer();
+        Set one = new HashSet();
+        for (int i = 0; i < rms1.length; i++) {
+                       one.add(rms1[i].toString());
+               }
+        Set two = new HashSet();
+        for (int i = 0; i < rms2.length; i++) {
+                       two.add(rms2[i].toString());
+               }
+        for (int i = 0;i<rms2.length;i++) {
+               if (!one.contains(rms2[i].toString())) {
+                       errors.append("Couldn't find "+rms2[i].toString()+" in the bcel set\n");
+               }
+        }
+        for (int i = 0;i<rms1.length;i++) {
+               if (!two.contains(rms1[i].toString())) {
+                       if (!barfIfClinitMissing && rms1[i].getName().equals("<clinit>")) continue;
+                       errors.append("Couldn't find "+rms1[i].toString()+" in the reflection set\n");
+               }
+        }
+        assertTrue("Errors:"+errors.toString(),errors.length()==0);
+        
+        // the good old ibm vm seems to offer clinit through its reflection support (see pr145322)
+        if (rms1.length==rms2.length) return;
+        if (barfIfClinitMissing) {
+               // the numbers must be exact
+            assertEquals(rms1.length,rms2.length);             
+        } else {
+               // the numbers can be out by one in favour of bcel
+               if (rms1.length!=(rms2.length+1)) {
+                       for (int i = 0; i < rms1.length; i++) {
+                                       System.err.println("bcel"+i+" is "+rms1[i]);
+                               }
+                       for (int i = 0; i < rms2.length; i++) {
+                                       System.err.println("refl"+i+" is "+rms2[i]);
+                               }
+               }
+               assertTrue("Should be one extra (clinit) in BCEL case, but bcel="+rms1.length+" reflect="+rms2.length,rms1.length==rms2.length+1);
+        }
+    }
+           
+       // todo: array of int   
+
+       protected void setUp() throws Exception {
+               world = new ReflectionWorld(getClass().getClassLoader());
+               objectType = world.resolve("java.lang.Object");
+       }
+}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java
new file mode 100644 (file)
index 0000000..39c5ccb
--- /dev/null
@@ -0,0 +1,41 @@
+/* *******************************************************************
+ * 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: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.weaver.reflect;
+
+import junit.framework.TestCase;
+
+import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.World;
+
+public class ReflectionWorldTest extends TestCase {
+
+       public void testDelegateCreation() {
+               World world = new ReflectionWorld(getClass().getClassLoader());
+               ResolvedType rt = world.resolve("java.lang.Object");
+               assertNotNull(rt);
+               assertEquals("Ljava/lang/Object;",rt.getSignature());
+       }
+       
+       public void testArrayTypes() {
+               IReflectionWorld world = new ReflectionWorld(getClass().getClassLoader());
+               String[] strArray = new String[1];
+               ResolvedType rt = world.resolve(strArray.getClass());
+               assertTrue(rt.isArray());
+       }
+       
+       public void testPrimitiveTypes() {
+               IReflectionWorld world = new ReflectionWorld(getClass().getClassLoader());
+               assertEquals("int",ResolvedType.INT,world.resolve(int.class));
+               assertEquals("void",ResolvedType.VOID,world.resolve(void.class));
+       }
+       
+}
index a72e34356f6a8b6a018b929883d6f2c6602b1324..96bc6d007972a3c6f77a318f239dd6d6e0aed348 100644 (file)
@@ -16,18 +16,15 @@ import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.aspectj.testing.util.TestUtil;
-import org.aspectj.weaver.tools.PointcutExpressionTest;
 
 /**
  */
 public class Weaver5ModuleTests extends TestCase {
 
     public static Test suite() {
-        TestSuite suite = new TestSuite(Weaver5ModuleTests.class.getName());
+       TestSuite suite = new TestSuite(Weaver5ModuleTests.class.getName());
         if (TestUtil.is15VMOrGreater()) {
-                   TestUtil.loadTestsReflectively(suite, "org.aspectj.weaver.tools.Java15PointcutExpressionTest", false);
-                   TestUtil.loadTestsReflectively(suite, "org.aspectj.weaver.AllTracing5Tests", false);
-                   suite.addTestSuite(PointcutExpressionTest.class);
+               TestUtil.loadTestsReflectively(suite, "org.aspectj.weaver.AllWeaver5Tests", false);
         } else {
             suite.addTest(TestUtil.testNamed("all tests require 1.5"));
         }
diff --git a/weaver5/testsrc/org/aspectj/weaver/tools/PointcutExpressionTest.java b/weaver5/testsrc/org/aspectj/weaver/tools/PointcutExpressionTest.java
deleted file mode 100644 (file)
index ac1897a..0000000
+++ /dev/null
@@ -1,570 +0,0 @@
-/* *******************************************************************
- * 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: 
- *   Andrew Clement          Initial implementation
- * ******************************************************************/
-
-package org.aspectj.weaver.tools;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.aspectj.util.LangUtil;
-
-import junit.framework.TestCase;
-
-public class PointcutExpressionTest extends TestCase {
-
-       PointcutParser p;
-       Constructor asCons;
-       Constructor bsCons;
-       Constructor bsStringCons;
-       Constructor clientCons;
-       Method a;
-       Method aa;
-       Method aaa;
-       Field x;
-       Field y;
-       Method b;
-       Method bsaa;
-       Field n;
-       Method foo;
-       Method bar;
-       
-       public void testMatchesMethodCall() {
-               PointcutExpression ex = p.parsePointcutExpression("call(* *..A.a*(..))");
-               assertTrue("Should match call to A.a()",ex.matchesMethodCall(a,a).alwaysMatches());
-               assertTrue("Should match call to A.aaa()",ex.matchesMethodCall(aaa,a).alwaysMatches());
-               assertTrue("Should match call to B.aa()",ex.matchesMethodCall(bsaa,a).alwaysMatches());
-               assertTrue("Should not match call to B.b()",ex.matchesMethodCall(b,a).neverMatches());
-               ex = p.parsePointcutExpression("call(* *..A.a*(int))");
-               assertTrue("Should match call to A.aa()",ex.matchesMethodCall(aa,a).alwaysMatches());
-               assertTrue("Should not match call to A.a()",ex.matchesMethodCall(a,a).neverMatches());
-               ex = p.parsePointcutExpression("call(void aaa(..)) && this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("Should match call to A.aaa() from Client",ex.matchesMethodCall(aaa,foo).alwaysMatches());
-               ex = p.parsePointcutExpression("call(void aaa(..)) && this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Should match call to A.aaa() from B",ex.matchesMethodCall(aaa,b).alwaysMatches());
-               assertTrue("May match call to A.aaa() from A",ex.matchesMethodCall(aaa,a).maybeMatches());
-               assertFalse("May match call to A.aaa() from A",ex.matchesMethodCall(aaa,a).alwaysMatches());
-               ex = p.parsePointcutExpression("execution(* *.*(..))");
-               assertTrue("Should not match call to A.aa",ex.matchesMethodCall(aa,a).neverMatches());
-               // this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("Should match Client",ex.matchesMethodCall(a,foo).alwaysMatches());
-               assertTrue("Should not match A",ex.matchesMethodCall(a,a).neverMatches());
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Should maybe match B",ex.matchesMethodCall(bsaa,a).maybeMatches());
-               assertFalse("Should maybe match B",ex.matchesMethodCall(bsaa,a).alwaysMatches());
-               // target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("Should not match Client",ex.matchesMethodCall(a,a).neverMatches());
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("Should match A",ex.matchesMethodCall(a,a).alwaysMatches());
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Should maybe match A",ex.matchesMethodCall(aa,a).maybeMatches());           
-               assertFalse("Should maybe match A",ex.matchesMethodCall(aa,a).alwaysMatches());         
-               // test args
-               ex = p.parsePointcutExpression("args(..,int)");
-               assertTrue("Should match A.aa",ex.matchesMethodCall(aa,a).alwaysMatches());
-               assertTrue("Should match A.aaa",ex.matchesMethodCall(aaa,a).alwaysMatches());
-               assertTrue("Should not match A.a",ex.matchesMethodCall(a,a).neverMatches());
-               // within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesMethodCall(a,a).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesMethodCall(a,b).neverMatches());
-               assertTrue("Matches in class A",ex.matchesMethodCall(a,A.class).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesMethodCall(a,B.class).neverMatches());
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Should match",ex.matchesMethodCall(b,bsaa).alwaysMatches());
-               assertTrue("Should not match",ex.matchesMethodCall(b,b).neverMatches());
-       }
-
-       public void testMatchesMethodExecution() {
-               PointcutExpression ex = p.parsePointcutExpression("execution(* *..A.aa(..))");
-               assertTrue("Should match execution of A.aa",ex.matchesMethodExecution(aa).alwaysMatches());
-               assertTrue("Should match execution of B.aa",ex.matchesMethodExecution(bsaa).alwaysMatches());
-               assertTrue("Should not match execution of A.a",ex.matchesMethodExecution(a).neverMatches());
-               ex = p.parsePointcutExpression("call(* *..A.a*(int))");
-               assertTrue("Should not match execution of A.a",ex.matchesMethodExecution(a).neverMatches());
-
-               // test this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("Should match A",ex.matchesMethodExecution(a).alwaysMatches());
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Maybe matches B",ex.matchesMethodExecution(a).maybeMatches());
-               assertFalse("Maybe matches B",ex.matchesMethodExecution(a).alwaysMatches());
-
-               // test target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("Should match A",ex.matchesMethodExecution(a).alwaysMatches());
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Maybe matches B",ex.matchesMethodExecution(a).maybeMatches());
-               assertFalse("Maybe matches B",ex.matchesMethodExecution(a).alwaysMatches());
-               
-               // test args
-               ex = p.parsePointcutExpression("args(..,int)");
-               assertTrue("Should match A.aa",ex.matchesMethodExecution(aa).alwaysMatches());
-               assertTrue("Should match A.aaa",ex.matchesMethodExecution(aaa).alwaysMatches());
-               assertTrue("Should not match A.a",ex.matchesMethodExecution(a).neverMatches());
-
-               // within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesMethodExecution(a).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesMethodExecution(bsaa).neverMatches());
-
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Should not match",ex.matchesMethodExecution(a).neverMatches());
-       }
-
-       public void testMatchesConstructorCall() {
-               PointcutExpression ex = p.parsePointcutExpression("call(new(String))");
-               assertTrue("Should match A(String)", ex.matchesConstructorCall(asCons,b).alwaysMatches());
-               assertTrue("Should match B(String)", ex.matchesConstructorCall(bsStringCons,b).alwaysMatches());
-               assertTrue("Should not match B()",ex.matchesConstructorCall(bsCons,foo).neverMatches());
-               ex = p.parsePointcutExpression("call(*..A.new(String))");
-               assertTrue("Should match A(String)", ex.matchesConstructorCall(asCons,b).alwaysMatches());
-               assertTrue("Should not match B(String)",ex.matchesConstructorCall(bsStringCons,foo).neverMatches());
-               // this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("Should match Client",ex.matchesConstructorCall(asCons,foo).alwaysMatches());
-               assertTrue("Should not match A",ex.matchesConstructorCall(asCons,a).neverMatches());
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Should maybe match B",ex.matchesConstructorCall(asCons,a).maybeMatches());
-               assertFalse("Should maybe match B",ex.matchesConstructorCall(asCons,a).alwaysMatches());
-               // target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("Should not match Client",ex.matchesConstructorCall(asCons,foo).neverMatches());
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("Should not match A (no target)",ex.matchesConstructorCall(asCons,a).neverMatches());
-               // args
-               ex = p.parsePointcutExpression("args(String)");
-               assertTrue("Should match A(String)", ex.matchesConstructorCall(asCons,b).alwaysMatches());
-               assertTrue("Should match B(String)", ex.matchesConstructorCall(bsStringCons,foo).alwaysMatches());
-               assertTrue("Should not match B()", ex.matchesConstructorCall(bsCons,foo).neverMatches());
-               // within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesConstructorCall(asCons,a).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesConstructorCall(asCons,b).neverMatches());
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Should match",ex.matchesConstructorCall(bsCons,aa).alwaysMatches());
-               assertTrue("Should not match",ex.matchesConstructorCall(bsCons,b).neverMatches());
-       }
-
-       public void testMatchesConstructorExecution() {
-               PointcutExpression ex = p.parsePointcutExpression("execution(new(String))");
-               assertTrue("Should match A(String)", ex.matchesConstructorExecution(asCons).alwaysMatches());
-               assertTrue("Should match B(String)", ex.matchesConstructorExecution(bsStringCons).alwaysMatches());
-               assertTrue("Should not match B()", ex.matchesConstructorExecution(bsCons).neverMatches());
-               ex = p.parsePointcutExpression("execution(*..A.new(String))");
-               assertTrue("Should match A(String)",ex.matchesConstructorExecution(asCons).alwaysMatches());
-               assertTrue("Should not match B(String)",ex.matchesConstructorExecution(bsStringCons).neverMatches());
-
-               // test this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("Should match A",ex.matchesConstructorExecution(asCons).alwaysMatches());
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Maybe matches B",ex.matchesConstructorExecution(asCons).maybeMatches());
-               assertFalse("Maybe matches B",ex.matchesConstructorExecution(asCons).alwaysMatches());
-               assertTrue("Should match B",ex.matchesConstructorExecution(bsCons).alwaysMatches());
-               assertTrue("Does not match client",ex.matchesConstructorExecution(clientCons).neverMatches());
-
-               // test target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("Should match A",ex.matchesConstructorExecution(asCons).alwaysMatches());
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Maybe matches B",ex.matchesConstructorExecution(asCons).maybeMatches());
-               assertFalse("Maybe matches B",ex.matchesConstructorExecution(asCons).alwaysMatches());
-               assertTrue("Should match B",ex.matchesConstructorExecution(bsCons).alwaysMatches());
-               assertTrue("Does not match client",ex.matchesConstructorExecution(clientCons).neverMatches());
-
-               // within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesConstructorExecution(asCons).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesConstructorExecution(bsCons).neverMatches());
-
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Does not match",ex.matchesConstructorExecution(bsCons).neverMatches());
-
-               // args
-               ex = p.parsePointcutExpression("args(String)");
-               assertTrue("Should match A(String)",ex.matchesConstructorExecution(asCons).alwaysMatches());
-               assertTrue("Should match B(String)", ex.matchesConstructorExecution(bsStringCons).alwaysMatches());
-               assertTrue("Should not match B()", ex.matchesConstructorExecution(bsCons).neverMatches());
-       }
-
-       public void testMatchesAdviceExecution() {
-               PointcutExpression ex = p.parsePointcutExpression("adviceexecution()");
-               assertTrue("Should match (advice) A.a",ex.matchesAdviceExecution(a).alwaysMatches());
-               // test this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("Should match Client",ex.matchesAdviceExecution(foo).alwaysMatches());
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Maybe matches B",ex.matchesAdviceExecution(a).maybeMatches());
-               assertFalse("Maybe matches B",ex.matchesAdviceExecution(a).alwaysMatches());
-               assertTrue("Does not match client",ex.matchesAdviceExecution(foo).neverMatches());
-
-               // test target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("Should match Client",ex.matchesAdviceExecution(foo).alwaysMatches());
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Maybe matches B",ex.matchesAdviceExecution(a).maybeMatches());
-               assertFalse("Maybe matches B",ex.matchesAdviceExecution(a).alwaysMatches());
-               assertTrue("Does not match client",ex.matchesAdviceExecution(foo).neverMatches());
-
-               // test within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesAdviceExecution(a).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesAdviceExecution(b).neverMatches());            
-
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Does not match",ex.matchesAdviceExecution(a).neverMatches());
-
-               // test args
-               ex = p.parsePointcutExpression("args(..,int)");
-               assertTrue("Should match A.aa",ex.matchesAdviceExecution(aa).alwaysMatches());
-               assertTrue("Should match A.aaa",ex.matchesAdviceExecution(aaa).alwaysMatches());
-               assertTrue("Should not match A.a",ex.matchesAdviceExecution(a).neverMatches());
-       }
-
-       public void testMatchesHandler() {
-               PointcutExpression ex = p.parsePointcutExpression("handler(Exception)");
-               assertTrue("Should match catch(Exception)",ex.matchesHandler(Exception.class,Client.class).alwaysMatches());
-               assertTrue("Should not match catch(Throwable)",ex.matchesHandler(Throwable.class,Client.class).neverMatches());
-               // test this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("Should match Client",ex.matchesHandler(Exception.class,foo).alwaysMatches());
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Maybe matches B",ex.matchesHandler(Exception.class,a).maybeMatches());
-               assertFalse("Maybe matches B",ex.matchesHandler(Exception.class,a).alwaysMatches());
-               assertTrue("Does not match client",ex.matchesHandler(Exception.class,foo).neverMatches());
-               // target - no target for exception handlers
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("Should match Client",ex.matchesHandler(Exception.class,foo).neverMatches());
-               // args
-               ex = p.parsePointcutExpression("args(Exception)");
-               assertTrue("Should match Exception",ex.matchesHandler(Exception.class,foo).alwaysMatches());
-               assertTrue("Should match RuntimeException",ex.matchesHandler(RuntimeException.class,foo).alwaysMatches());
-               assertTrue("Should not match String",ex.matchesHandler(String.class,foo).neverMatches());
-               assertTrue("Maybe matches Throwable",ex.matchesHandler(Throwable.class,foo).maybeMatches());
-               assertFalse("Maybe matches Throwable",ex.matchesHandler(Throwable.class,foo).alwaysMatches());
-               // within
-               ex = p.parsePointcutExpression("within(*..Client)");
-               assertTrue("Matches in class Client",ex.matchesHandler(Exception.class,foo).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesHandler(Exception.class,b).neverMatches());
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Matches within aa",ex.matchesHandler(Exception.class,aa).alwaysMatches());
-               assertTrue("Does not match within b",ex.matchesHandler(Exception.class,b).neverMatches());
-       }
-
-       public void testMatchesInitialization() {
-               PointcutExpression ex = p.parsePointcutExpression("initialization(new(String))");
-               assertTrue("Should match A(String)",ex.matchesInitialization(asCons).alwaysMatches());
-               assertTrue("Should match B(String)", ex.matchesInitialization(bsStringCons).alwaysMatches());
-               assertTrue("Should not match B()",ex.matchesInitialization(bsCons).neverMatches());
-               ex = p.parsePointcutExpression("initialization(*..A.new(String))");
-               assertTrue("Should match A(String)", ex.matchesInitialization(asCons).alwaysMatches());
-               assertTrue("Should not match B(String)", ex.matchesInitialization(bsStringCons).neverMatches());
-               // test this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("Should match A",ex.matchesInitialization(asCons).alwaysMatches());
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Maybe matches B",ex.matchesInitialization(asCons).maybeMatches());
-               assertFalse("Maybe matches B",ex.matchesInitialization(asCons).alwaysMatches());
-               
-               // test target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("Should match A",ex.matchesInitialization(asCons).alwaysMatches());
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("Maybe matches B",ex.matchesInitialization(asCons).maybeMatches());
-               assertFalse("Maybe matches B",ex.matchesInitialization(asCons).alwaysMatches());
-               // within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesInitialization(asCons).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesInitialization(bsCons).neverMatches());
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Does not match",ex.matchesInitialization(bsCons).neverMatches());
-               // args
-               ex = p.parsePointcutExpression("args(String)");
-               assertTrue("Should match A(String)", ex.matchesInitialization(asCons).alwaysMatches());
-               assertTrue("Should match B(String)", ex.matchesInitialization(bsStringCons).alwaysMatches());
-               assertTrue("Should not match B()",ex.matchesInitialization(bsCons).neverMatches());
-       }
-
-       public void testMatchesPreInitialization() {
-               PointcutExpression ex = p.parsePointcutExpression("preinitialization(new(String))");
-               assertTrue("Should match A(String)",ex.matchesPreInitialization(asCons).alwaysMatches());
-               assertTrue("Should match B(String)", ex.matchesPreInitialization(bsStringCons).alwaysMatches());
-               assertTrue("Should not match B()",ex.matchesPreInitialization(bsCons).neverMatches());
-               ex = p.parsePointcutExpression("preinitialization(*..A.new(String))");
-               assertTrue("Should match A(String)", ex.matchesPreInitialization(asCons).alwaysMatches());
-               assertTrue("Should not match B(String)", ex.matchesPreInitialization(bsStringCons).neverMatches());
-               // test this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("No match, no this at preinit",ex.matchesPreInitialization(asCons).neverMatches());
-               
-               // test target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("No match, no target at preinit",ex.matchesPreInitialization(asCons).neverMatches());
-
-               // within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesPreInitialization(asCons).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesPreInitialization(bsCons).neverMatches());
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Does not match",ex.matchesPreInitialization(bsCons).neverMatches());
-               // args
-               ex = p.parsePointcutExpression("args(String)");
-               assertTrue("Should match A(String)", ex.matchesPreInitialization(asCons).alwaysMatches());
-               assertTrue("Should match B(String)", ex.matchesPreInitialization(bsStringCons).alwaysMatches());
-               assertTrue("Should not match B()",ex.matchesPreInitialization(bsCons).neverMatches());
-       }
-
-       public void testMatchesStaticInitialization() {
-               // staticinit
-               PointcutExpression ex = p.parsePointcutExpression("staticinitialization(*..A+)");
-               assertTrue("Matches A",ex.matchesStaticInitialization(A.class).alwaysMatches());
-               assertTrue("Matches B",ex.matchesStaticInitialization(B.class).alwaysMatches());
-               assertTrue("Doesn't match Client",ex.matchesStaticInitialization(Client.class).neverMatches());
-               // this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("No this",ex.matchesStaticInitialization(A.class).neverMatches());
-               // target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-               assertTrue("No target",ex.matchesStaticInitialization(A.class).neverMatches());         
-
-               // args
-               ex = p.parsePointcutExpression("args()");
-               assertTrue("No args",ex.matchesStaticInitialization(A.class).alwaysMatches());
-               ex = p.parsePointcutExpression("args(String)");
-               assertTrue("No args",ex.matchesStaticInitialization(A.class).neverMatches());
-
-               // within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesStaticInitialization(A.class).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesStaticInitialization(B.class).neverMatches());         
-
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Does not match",ex.matchesStaticInitialization(A.class).neverMatches());
-       }
-
-       public void testMatchesFieldSet() {
-               PointcutExpression ex = p.parsePointcutExpression("set(* *..A+.*)");
-               assertTrue("matches x",ex.matchesFieldSet(x,a).alwaysMatches());
-               assertTrue("matches y",ex.matchesFieldSet(y,foo).alwaysMatches());
-               assertTrue("does not match n",ex.matchesFieldSet(n,foo).neverMatches());
-               // this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("matches Client",ex.matchesFieldSet(x,foo).alwaysMatches());
-               assertTrue("does not match A",ex.matchesFieldSet(n,a).neverMatches());
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("maybe matches A",ex.matchesFieldSet(x,a).maybeMatches());
-               assertFalse("maybe matches A",ex.matchesFieldSet(x,a).alwaysMatches());
-               // target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("matches B",ex.matchesFieldSet(y,foo).alwaysMatches());
-               assertTrue("maybe matches A",ex.matchesFieldSet(x,foo).maybeMatches());         
-               assertFalse("maybe matches A",ex.matchesFieldSet(x,foo).alwaysMatches());               
-               // args
-               ex = p.parsePointcutExpression("args(int)");
-               assertTrue("matches x",ex.matchesFieldSet(x,a).alwaysMatches());
-               assertTrue("matches y",ex.matchesFieldSet(y,a).alwaysMatches());
-               assertTrue("does not match n",ex.matchesFieldSet(n,a).neverMatches());
-               // within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesFieldSet(x,a).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesFieldSet(x,b).neverMatches());
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Should match",ex.matchesFieldSet(x,aa).alwaysMatches());
-               assertTrue("Should not match",ex.matchesFieldSet(x,b).neverMatches());
-       }
-
-       public void testMatchesFieldGet() {
-               PointcutExpression ex = p.parsePointcutExpression("get(* *..A+.*)");
-               assertTrue("matches x",ex.matchesFieldGet(x,a).alwaysMatches());
-               assertTrue("matches y",ex.matchesFieldGet(y,foo).alwaysMatches());
-               assertTrue("does not match n",ex.matchesFieldGet(n,foo).neverMatches());
-               // this
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.Client)");
-               assertTrue("matches Client",ex.matchesFieldGet(x,foo).alwaysMatches());
-               assertTrue("does not match A",ex.matchesFieldGet(n,a).neverMatches());
-               ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("maybe matches A",ex.matchesFieldGet(x,a).maybeMatches());
-               assertFalse("maybe matches A",ex.matchesFieldGet(x,a).alwaysMatches());
-               // target
-               ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertTrue("matches B",ex.matchesFieldGet(y,foo).alwaysMatches());
-               assertTrue("maybe matches A",ex.matchesFieldGet(x,foo).maybeMatches());         
-               assertFalse("maybe matches A",ex.matchesFieldGet(x,foo).alwaysMatches());               
-               // args - no args at get join point
-               ex = p.parsePointcutExpression("args(int)");
-               assertTrue("matches x",ex.matchesFieldGet(x,a).neverMatches());
-               // within
-               ex = p.parsePointcutExpression("within(*..A)");
-               assertTrue("Matches in class A",ex.matchesFieldGet(x,a).alwaysMatches());
-               assertTrue("Does not match in class B",ex.matchesFieldGet(x,b).neverMatches());
-               // withincode
-               ex = p.parsePointcutExpression("withincode(* a*(..))");
-               assertTrue("Should match",ex.matchesFieldGet(x,aa).alwaysMatches());
-               assertTrue("Should not match",ex.matchesFieldGet(x,b).neverMatches());
-       }
-       
-       public void testArgsMatching() {
-               // too few args
-               PointcutExpression ex = p.parsePointcutExpression("args(*,*,*,*)");
-               assertTrue("Too few args",ex.matchesMethodExecution(foo).neverMatches());
-               assertTrue("Matching #args",ex.matchesMethodExecution(bar).alwaysMatches());
-               // one too few + ellipsis
-               ex = p.parsePointcutExpression("args(*,*,*,..)");
-               assertTrue("Matches with ellipsis",ex.matchesMethodExecution(foo).alwaysMatches());
-               // exact number + ellipsis
-               assertTrue("Matches with ellipsis",ex.matchesMethodExecution(bar).alwaysMatches());
-               assertTrue("Does not match with ellipsis",ex.matchesMethodExecution(a).neverMatches());         
-               // too many + ellipsis
-               ex = p.parsePointcutExpression("args(*,..,*)");
-               assertTrue("Matches with ellipsis",ex.matchesMethodExecution(bar).alwaysMatches());
-               assertTrue("Does not match with ellipsis",ex.matchesMethodExecution(a).neverMatches());         
-               assertTrue("Matches with ellipsis",ex.matchesMethodExecution(aaa).alwaysMatches());
-               // exact match
-               ex = p.parsePointcutExpression("args(String,int,Number)");
-               assertTrue("Matches exactly",ex.matchesMethodExecution(foo).alwaysMatches());
-               // maybe match
-               ex = p.parsePointcutExpression("args(String,int,Double)");
-               assertTrue("Matches maybe",ex.matchesMethodExecution(foo).maybeMatches());
-               assertFalse("Matches maybe",ex.matchesMethodExecution(foo).alwaysMatches());
-               // never match
-               ex = p.parsePointcutExpression("args(String,Integer,Number)");
-               if (LangUtil.is15VMOrGreater()) {
-                       assertTrue("matches",ex.matchesMethodExecution(foo).alwaysMatches());
-               } else {
-                       assertTrue("Does not match",ex.matchesMethodExecution(foo).neverMatches());
-               }
-       }
-       
-//     public void testMatchesDynamically() {
-//             // everything other than this,target,args should just return true
-//             PointcutExpression ex = p.parsePointcutExpression("call(* *.*(..)) && execution(* *.*(..)) &&" +
-//                             "get(* *) && set(* *) && initialization(new(..)) && preinitialization(new(..)) &&" +
-//                             "staticinitialization(X) && adviceexecution() && within(Y) && withincode(* *.*(..)))");
-//             assertTrue("Matches dynamically",ex.matchesDynamically(a,b,new Object[0]));             
-//             // this
-//             ex = p.parsePointcutExpression("this(String)");
-//             assertTrue("String matches",ex.matchesDynamically("",this,new Object[0]));
-//             assertFalse("Object doesn't match",ex.matchesDynamically(new Object(),this,new Object[0]));
-//             ex = p.parsePointcutExpression("this(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-//             assertTrue("A matches",ex.matchesDynamically(new A(""),this,new Object[0]));
-//             assertTrue("B matches",ex.matchesDynamically(new B(""),this,new Object[0]));
-//             // target
-//             ex = p.parsePointcutExpression("target(String)");
-//             assertTrue("String matches",ex.matchesDynamically(this,"",new Object[0]));
-//             assertFalse("Object doesn't match",ex.matchesDynamically(this,new Object(),new Object[0]));
-//             ex = p.parsePointcutExpression("target(org.aspectj.weaver.tools.PointcutExpressionTest.A)");
-//             assertTrue("A matches",ex.matchesDynamically(this,new A(""),new Object[0]));
-//             assertTrue("B matches",ex.matchesDynamically(this,new B(""),new Object[0]));            
-//             // args
-//             ex = p.parsePointcutExpression("args(*,*,*,*)");
-//             assertFalse("Too few args",ex.matchesDynamically(null,null,new Object[]{a,b}));
-//             assertTrue("Matching #args",ex.matchesDynamically(null,null,new Object[]{a,b,aa,aaa}));
-//             // one too few + ellipsis
-//             ex = p.parsePointcutExpression("args(*,*,*,..)");
-//             assertTrue("Matches with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b,aa,aaa}));
-//             // exact number + ellipsis
-//             assertTrue("Matches with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b,aa}));
-//             assertFalse("Does not match with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b}));         
-//             // too many + ellipsis
-//             ex = p.parsePointcutExpression("args(*,..,*)");
-//             assertTrue("Matches with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b,aa,aaa}));
-//             assertFalse("Does not match with ellipsis",ex.matchesDynamically(null,null,new Object[]{a}));           
-//             assertTrue("Matches with ellipsis",ex.matchesDynamically(null,null,new Object[]{a,b}));
-//             // exact match
-//             ex = p.parsePointcutExpression("args(String,int,Number)");
-//             assertTrue("Matches exactly",ex.matchesDynamically(null,null,new Object[]{"",new Integer(5),new Double(5.0)}));
-//             ex = p.parsePointcutExpression("args(String,Integer,Number)");
-//             assertTrue("Matches exactly",ex.matchesDynamically(null,null,new Object[]{"",new Integer(5),new Double(5.0)}));
-//             // never match
-//             ex = p.parsePointcutExpression("args(String,Integer,Number)");
-//             assertFalse("Does not match",ex.matchesDynamically(null,null,new Object[]{a,b,aa}));            
-//}
-
-       public void testGetPointcutExpression() {
-               PointcutExpression ex = p.parsePointcutExpression("staticinitialization(*..A+)");
-               assertEquals("staticinitialization(*..A+)",ex.getPointcutExpression());
-       }
-       
-       public void testCouldMatchJoinPointsInType() {
-               PointcutExpression ex = p.parsePointcutExpression("execution(* org.aspectj.weaver.tools.PointcutExpressionTest.B.*(..))");
-               assertTrue("Could maybe match String (as best we know at this point)",ex.couldMatchJoinPointsInType(String.class));
-               assertTrue("Will always match B",ex.couldMatchJoinPointsInType(B.class));
-               ex = p.parsePointcutExpression("within(org.aspectj.weaver.tools.PointcutExpressionTest.B)");
-               assertFalse("Will never match String",ex.couldMatchJoinPointsInType(String.class));
-               assertTrue("Will always match B",ex.couldMatchJoinPointsInType(B.class));
-       }
-       
-       public void testMayNeedDynamicTest() {
-               PointcutExpression ex = p.parsePointcutExpression("execution(* org.aspectj.weaver.tools.PointcutExpressionTest.B.*(..))");
-               assertFalse("No dynamic test needed",ex.mayNeedDynamicTest());
-               ex = p.parsePointcutExpression("execution(* org.aspectj.weaver.tools.PointcutExpressionTest.B.*(..)) && args(org.aspectj.weaver.tools.PointcutExpressionTest.X)");
-               assertTrue("Dynamic test needed",ex.mayNeedDynamicTest());
-       }
-
-       protected void setUp() throws Exception {
-               super.setUp();
-               p = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
-               asCons = A.class.getConstructor(new Class[]{String.class});
-               bsCons = B.class.getConstructor(new Class[0]);
-               bsStringCons = B.class.getConstructor(new Class[]{String.class});
-               a = A.class.getMethod("a",new Class[0]);
-               aa = A.class.getMethod("aa",new Class[]{int.class});
-               aaa = A.class.getMethod("aaa",new Class[]{String.class,int.class});
-               x = A.class.getDeclaredField("x");
-               y = B.class.getDeclaredField("y");
-               b = B.class.getMethod("b",new Class[0]);
-               bsaa = B.class.getMethod("aa",new Class[]{int.class});
-               clientCons = Client.class.getConstructor(new Class[0]);
-               n = Client.class.getDeclaredField("n");
-               foo = Client.class.getDeclaredMethod("foo",new Class[]{String.class,int.class,Number.class});
-               bar = Client.class.getDeclaredMethod("bar",new Class[]{String.class,int.class,Integer.class,Number.class});
-       }
-       
-       static class A {
-         public A(String s) {}
-         public void a() {}
-         public void aa(int i) {}
-         public void aaa(String s, int i) {}
-         int x;
-       }
-       
-       static class B extends A {
-               public B() {super("");}
-               public B(String s) {super(s);}
-               public String b() { return null; }
-               public void aa(int i) {}
-               int y;
-       }
-       
-       static class Client {
-               public Client() {}
-               Number n;
-               public void foo(String s, int i, Number n) {}
-               public void bar(String s, int i, Integer i2, Number n) {}
-       }
-       
-       static class X {}
-       
-}