aboutsummaryrefslogtreecommitdiffstats
path: root/weaver5/java5-testsrc/org/aspectj
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-02-08 15:02:11 -0800
committerAndy Clement <aclement@pivotal.io>2019-02-08 15:02:11 -0800
commit635f0ed47ffe11e93d96e4d24e4411eedfa1ddc9 (patch)
tree2fa95e5cf13bdefa559ce341761f90de747421e9 /weaver5/java5-testsrc/org/aspectj
parent66f6e011d251d84250c562950f491cab31af0ad3 (diff)
downloadaspectj-635f0ed47ffe11e93d96e4d24e4411eedfa1ddc9.tar.gz
aspectj-635f0ed47ffe11e93d96e4d24e4411eedfa1ddc9.zip
tidyup retired modules and add aspectjtools submodule
Diffstat (limited to 'weaver5/java5-testsrc/org/aspectj')
-rw-r--r--weaver5/java5-testsrc/org/aspectj/matcher/tools/ReflectionWorldAdvancedPointcutExpressionTests.java30
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java27
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java40
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/BcweaverModuleTests15.java41
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/BoundedReferenceTypeTestCase.java106
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/CommonReferenceTypeTests.java91
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java30
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java34
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/JoinPointSignatureIteratorTests.java107
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java155
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java854
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java154
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java81
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java110
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java68
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelWorldReferenceTypeTest.java23
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java422
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java316
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldReferenceTypeTest.java27
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java290
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java746
21 files changed, 0 insertions, 3752 deletions
diff --git a/weaver5/java5-testsrc/org/aspectj/matcher/tools/ReflectionWorldAdvancedPointcutExpressionTests.java b/weaver5/java5-testsrc/org/aspectj/matcher/tools/ReflectionWorldAdvancedPointcutExpressionTests.java
deleted file mode 100644
index d93daffd3..000000000
--- a/weaver5/java5-testsrc/org/aspectj/matcher/tools/ReflectionWorldAdvancedPointcutExpressionTests.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2008 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:
- * Andy Clement
- * ******************************************************************/
-package org.aspectj.matcher.tools;
-
-import org.aspectj.weaver.World;
-import org.aspectj.weaver.reflect.ReflectionWorld;
-
-/**
- * Run all the pointcut parsing/matching tests against a ReflectionWorld.
- *
- * @author Andy Clement
- */
-public class ReflectionWorldAdvancedPointcutExpressionTests extends CommonAdvancedPointcutExpressionTests {
-
- protected World getWorld() {
- World w = new ReflectionWorld(false, getClass().getClassLoader());
- w.setBehaveInJava5Way(true);
- return w;
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java b/weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java
deleted file mode 100644
index bf68cb56c..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * 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:
- * Matthew Webster - initial implementation
- *******************************************************************************/
-package org.aspectj.weaver;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class AllTracing5Tests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AllTracing5Tests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(Jdk14TraceFactoryTest.class);
- suite.addTestSuite(Jdk14TraceTest.class);
- //$JUnit-END$
- return suite;
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java b/weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java
deleted file mode 100644
index 54f35656f..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java
+++ /dev/null
@@ -1,40 +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
- * Matthew Webster Move from default package
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.aspectj.weaver.reflect.ReflectionWorldReferenceTypeTest;
-import org.aspectj.weaver.reflect.ReflectionWorldSpecificTest;
-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(BcweaverModuleTests15.suite());
- suite.addTestSuite(ReflectionWorldReferenceTypeTest.class);
- suite.addTestSuite(PointcutExpressionTest.class);
- suite.addTestSuite(JoinPointSignatureIteratorTests.class);
- // gives incompatible class version error...
- // suite.addTestSuite(ReflectionWorldAdvancedPointcutExpressionTests.class
- // );
- suite.addTestSuite(ReflectionWorldSpecificTest.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
deleted file mode 100644
index 4ae4d7beb..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/BcweaverModuleTests15.java
+++ /dev/null
@@ -1,41 +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.weaver.bcel.BcelGenericSignatureToTypeXTestCase;
-import org.aspectj.weaver.bcel.BcelWorldReferenceTypeTest;
-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(BcelWorldReferenceTypeTest.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
deleted file mode 100644
index 403b2ecb1..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/BoundedReferenceTypeTestCase.java
+++ /dev/null
@@ -1,106 +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:
- * Adrian Colyer Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import junit.framework.TestCase;
-
-import org.aspectj.weaver.bcel.BcelWorld;
-
-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.getAdditionalBounds().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.getAdditionalBounds().length);
- }
-
- public void testIsExtends() {
- assertTrue(extendsClass.kind == BoundedReferenceType.EXTENDS);
- assertFalse(superClass.kind == BoundedReferenceType.EXTENDS);
- }
-
- public void testIsSuper() {
- assertTrue(superClass.kind == BoundedReferenceType.SUPER);
- assertFalse(extendsClass.kind == BoundedReferenceType.SUPER);
- }
-
- 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]);
- }
- }
-
- @Override
- 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/CommonReferenceTypeTests.java b/weaver5/java5-testsrc/org/aspectj/weaver/CommonReferenceTypeTests.java
deleted file mode 100644
index 8d683e8af..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/CommonReferenceTypeTests.java
+++ /dev/null
@@ -1,91 +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:
- * Adrian Colyer Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver;
-
-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 abstract class CommonReferenceTypeTests extends TestCase {
-
- private World world;
-
- public abstract World getWorld();
-
- public void setUp() {
- world = getWorld();
- }
-
- public void testUnresolvedTypeSignatureProcessing() {
- world.setBehaveInJava5Way(true);
- UnresolvedType ut = null;
- ut = UnresolvedType.forName("java.util.List<java.util.List<java.lang.String>>[]").resolve(world);
- ut = UnresolvedType.forSignature("[Pjava/util/List<Pjava/util/List<Ljava/lang/String;>;>;").resolve(world);
- assertEquals("Signatures not equal ", "[Pjava/util/List<Pjava/util/List<Ljava/lang/String;>;>;", ut.getSignature());
- assertEquals("Names not equal ", "java.util.List<java.util.List<java.lang.String>>[]", ut.getName());
- }
-
- public void testArrays() {
- world.setBehaveInJava5Way(true);
- UnresolvedType ut = null;
- ut = UnresolvedType.forName("[Ljava.lang.String;");
- assertEquals("[Ljava/lang/String;",ut.getSignature());
- UnresolvedType reified = UnresolvedType.forSignature(ut.getSignature());
- ResolvedType rt = world.resolve(reified);
- assertEquals("[Ljava/lang/String;",rt.getSignature());
- assertEquals("java.lang.String[]",rt.getName());
- assertFalse(rt.isMissing());
-
- ut = UnresolvedType.forName("[[[[Ljava.lang.String;");
- assertEquals("[[[[Ljava/lang/String;",ut.getSignature());
- reified = UnresolvedType.forSignature(ut.getSignature());
- rt = world.resolve(reified);
- assertEquals("[[[[Ljava/lang/String;",rt.getSignature());
- assertEquals("java.lang.String[][][][]",rt.getName());
- assertTrue(rt.isArray());
- assertTrue(rt.getComponentType().isArray());
- assertFalse(rt.isMissing());
- }
-
- public void testIsRawTrue() {
- 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() {
- 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() {
- 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() {
- world.setBehaveInJava5Way(true);
- UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object");
- ResolvedType rtx = world.resolve(javaLangObject);
- assertFalse(rtx.isGenericType());
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java
deleted file mode 100644
index cec4d6a3d..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * 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:
- * Matthew Webster - initial implementation
- *******************************************************************************/
-package org.aspectj.weaver;
-
-import junit.framework.TestCase;
-
-import org.aspectj.weaver.tools.Jdk14TraceFactory;
-import org.aspectj.weaver.tools.Trace;
-
-public class Jdk14TraceFactoryTest extends TestCase {
-
- public void testJdk14TraceFactory() {
- new Jdk14TraceFactory();
- }
-
- public void testGetTrace() {
- Jdk14TraceFactory factory = new Jdk14TraceFactory();
- Trace trace = factory.getTrace(getClass());
- assertFalse("Tracing should be disbled by default",trace.isTraceEnabled());
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java
deleted file mode 100644
index 0c694cc9d..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * 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:
- * Matthew Webster - initial implementation
- *******************************************************************************/
-package org.aspectj.weaver;
-
-import org.aspectj.weaver.tools.DefaultTrace;
-import org.aspectj.weaver.tools.Jdk14Trace;
-
-public class Jdk14TraceTest extends AbstractTraceTest {
-
- protected void setUp() throws Exception {
- super.setUp();
- trace = new Jdk14Trace(getClass());
- trace.setTraceEnabled(true);
- }
-
- public void testJdk14Trace() {
- new Jdk14Trace(getClass());
- }
-
- public void testSetTraceEnabled() {
- DefaultTrace trace = new DefaultTrace(getClass());
- trace.setTraceEnabled(true);
- assertTrue(trace.isTraceEnabled());
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/JoinPointSignatureIteratorTests.java b/weaver5/java5-testsrc/org/aspectj/weaver/JoinPointSignatureIteratorTests.java
deleted file mode 100644
index 9b7aa00d6..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/JoinPointSignatureIteratorTests.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2009 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:
- * Andy Clement
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.aspectj.weaver.reflect.ReflectionWorld;
-
-/**
- * @author Andy Clement
- */
-public class JoinPointSignatureIteratorTests extends TestCase {
-
- private World getWorld() {
- return new ReflectionWorld(getClass().getClassLoader());
- }
-
- /**
- * Checking the signatures for a dynamic proxy - which is created using erased information and so is completely generics unaware
- */
- public void testPr268419() {
- World w = getWorld();
- w.setBehaveInJava5Way(true);
-
- // The proxy class here is not generated, it is simply loaded up. $Proxy1 is in the java5-testsrc folder, but it
- // obeys the rules of a generated proxy in that it extends java.lang.reflect.Proxy
- ResolvedType proxy = UnresolvedType.forName("$Proxy1").resolve(w);
- assertNotNull(proxy);
-
- // The test hierarchy here (messageservice and genericservice) contains 2 methods. One is generic
- // and one is not. The aim of the test here is that the join point signatures generated for both
- // should be the same because of the use of a proxy.
-
- List l = proxy.getMethodsWithoutIterator(false, false, false);
- for (Object object : l) {
- ResolvedMember rm = (ResolvedMember) object;
- if (expectedResults.containsKey(rm.toString())) {
- System.out.println("\nChecking: " + rm);
- int i = 0;
- List/* String */sigs = (List) expectedResults.get(rm.toString());
- Iterator jpsi = rm.getJoinPointSignatures(w);
- while (jpsi.hasNext()) {
- ResolvedMember sig = (ResolvedMember) jpsi.next();
- assertEquals(sigs.get(i).toString(), sig.toString());
- i++;
- }
- if (i != sigs.size()) {
- fail("Expected " + sigs.size() + " signatures but got " + i);
- }
- } else {
- if (rm.getName().equals("get1") || rm.getName().equals("get2")) {
- fail("\nFound this unchecked get method " + rm);
- // Iterator jpsi = rm.getJoinPointSignatures(w);
- // while (jpsi.hasNext()) {
- // ResolvedMember sig = (ResolvedMember) jpsi.next();
- // System.out.println(sig);
- // }
- }
- }
- }
- }
-
- public static Map expectedResults = new HashMap();
-
- static {
- List sigs = new ArrayList();
- sigs.add("java.lang.Object $Proxy1.get1(java.io.Serializable)");
- sigs.add("java.lang.Object MessageService.get1(java.io.Serializable)");
- sigs.add("java.lang.Object GenericService.get1(java.io.Serializable)");
- sigs.add("java.lang.Object GenericService.get1(java.io.Serializable)");
- expectedResults.put("java.lang.Object $Proxy1.get1(java.io.Serializable)", sigs);
-
- sigs = new ArrayList();
- sigs.add("java.lang.Object $Proxy1.get2(java.io.Serializable)");
- sigs.add("java.lang.Object MessageService.get2(java.io.Serializable)");
- sigs.add("java.lang.Object GenericService.get2(java.io.Serializable)");
- sigs.add("java.lang.Object GenericService.get2(java.io.Serializable)");
- expectedResults.put("java.lang.Object $Proxy1.get2(java.io.Serializable)", sigs);
-
- sigs = new ArrayList();
- sigs.add("java.lang.Object $Proxy1.get1(java.lang.Long)");
- expectedResults.put("java.lang.Object $Proxy1.get1(java.lang.Long)", sigs);
-
- sigs = new ArrayList();
- sigs.add("java.lang.Object GenericService.get1(java.io.Serializable)");
- expectedResults.put("java.lang.Object GenericService.get1(java.io.Serializable)", sigs);
-
- sigs = new ArrayList();
- sigs.add("java.lang.Object GenericService.get2(java.io.Serializable)");
- expectedResults.put("java.lang.Object GenericService.get2(java.io.Serializable)", sigs);
- }
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java b/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java
deleted file mode 100644
index f44095a0e..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java
+++ /dev/null
@@ -1,155 +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:
- * Adrian Colyer Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import org.aspectj.weaver.bcel.BcelWorld;
-
-import junit.framework.TestCase;
-
-/**
- * @author colyer
- * @author clement
- */
-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());
- }
- }
- /*
- public void testGenericReferenceTypeCreation() {
- UnresolvedType genericType = UnresolvedType.forGenericTypeSignature("Lorg/aspectj/weaver/MemberTestCase15$One;","<T:Ljava/lang/Object;>Ljava/lang/Object;");
- assertEquals("Porg/aspectj/weaver/MemberTestCase15$One<TT;>;",genericType.getSignature());
- assertEquals("Lorg/aspectj/weaver/MemberTestCase15$One;",genericType.getErasureSignature());
- }
-
- public void testMemberSignatureCreation() {
- World world = new BcelWorld("../weaver5/bin/");
- //new ReflectionWorld(false, getClass().getClassLoader());
- world.setBehaveInJava5Way(true);
- ResolvedType one = world.resolve("org.aspectj.weaver.MemberTestCase15$One<java.lang.String>");
- assertNotNull(one);
- assertFalse(one.isMissing());
-
- // Look at the methods on the parameterized type One<String>
- ResolvedMember member = findMethod("getter",one);
- String erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true);
- assertEquals("()Ljava/lang/String;",erasedSignature);
- String nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false);
- assertEquals("()Ljava/lang/String;",nonErasedSignature);
- erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true);
- assertEquals("()Ljava/lang/String;",erasedSignature);
- nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false);
- assertEquals("()Ljava/lang/String;",nonErasedSignature);
-
- member = findMethod("getterTwo",one);
- erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true);
- assertEquals("()Ljava/util/List;",erasedSignature);
- nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false);
- assertEquals("()Pjava/util/List<Ljava/lang/String;>;",nonErasedSignature);
- nonErasedSignature = MemberImpl.typesToSignature(member.getGenericReturnType(),member.getGenericParameterTypes(),true);
- assertEquals("()Ljava/util/List;",nonErasedSignature);
- nonErasedSignature = MemberImpl.typesToSignature(member.getGenericReturnType(),member.getGenericParameterTypes(),false);
- assertEquals("()Pjava/util/List<Ljava/lang/String;>;",nonErasedSignature);
-
- // Grab the generic type backing the parameterized type
- ResolvedType oneGeneric = one.getGenericType();
- assertTrue(oneGeneric.isGenericType());
- member = findMethod("getterTwo",oneGeneric);
- erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true);
- assertEquals("()Ljava/util/List;",erasedSignature);
- erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false);
- assertEquals("()Ljava/util/List;",erasedSignature);
- nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false);
- assertEquals("()Pjava/util/List<TT;>;",nonErasedSignature);
- nonErasedSignature = MemberImpl.typesToSignature(member.getGenericReturnType(),member.getGenericParameterTypes(),false);
- assertEquals("()Ljava/util/List;",nonErasedSignature);
-
-
- ResolvedType oneRaw = oneGeneric.getRawType();
- member = findMethod("getterTwo",oneRaw);
- }
-
- private ResolvedMember findMethod(String name, ResolvedType type) {
- ResolvedMember[] members = type.getDeclaredMethods();
- for (ResolvedMember member: members) {
- if (member.getName().equals(name)) {
- return member;
- }
- }
- return null;
- }
-
- // testcode
- class One<T> {
- T t;
- T getter() {
- return null;
- }
- List<T> getterTwo() {
- return null;
- }
- }
- */
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java
deleted file mode 100644
index 5fbc530e7..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java
+++ /dev/null
@@ -1,854 +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:
- * Adrian Colyer Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-import junit.framework.TestCase;
-
-import org.aspectj.util.PartialOrder;
-import org.aspectj.weaver.bcel.BcelWorld;
-
-// 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());
- }
-
- BcelWorld world;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- world = new BcelWorld();
- world.setBehaveInJava5Way(true);
- }
-
- public void testCoercion01() {
- ReferenceType listOfString = (ReferenceType) world.resolve(UnresolvedType
- .forSignature("Pjava/util/List<Ljava/lang/String;>;"));
- ReferenceType listOfInteger = (ReferenceType) world.resolve(UnresolvedType
- .forSignature("Pjava/util/List<Ljava/lang/Integer;>;"));
- assertFalse(listOfInteger.isAssignableFrom(listOfString));
- assertFalse(listOfString.isAssignableFrom(listOfInteger));
- assertFalse(listOfInteger.isCoerceableFrom(listOfString));
- assertFalse(listOfString.isCoerceableFrom(listOfInteger));
- }
-
- public void testAssignable01() {
- List list = new ArrayList();
- List<String> listOfString = new ArrayList<String>();
- List<?> listOfSomething = new ArrayList<Integer>();
- List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
- List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
- // interfaces too List<? extends A,B>
-
- ReferenceType ajList = resolve("Ljava/util/List;");
- ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
- ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
- ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
- ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
-
- // try and write the java equivalent, if it succeeds then check isAssignableFrom() is true
- // if the java is only correct with a cast, check isCoerceableFrom()
- list = listOfString;
- assertTrue(ajList.isAssignableFrom(ajListOfString));
- list = listOfSomething;
- assertTrue(ajList.isAssignableFrom(ajListOfSomething));
- list = listOfSomethingNumberish;
- assertTrue(ajList.isAssignableFrom(ajListOfSomething));
- list = listOfSomethingSuperDouble;
- assertTrue(ajList.isAssignableFrom(ajListOfSomethingSuperDouble));
-
- listOfString = list; // unchecked conversion to List<String>
- assertFalse(ajListOfString.isAssignableFrom(ajList));
- assertTrue(ajListOfString.isCoerceableFrom(ajListOfSomething));
- // error: listOfString = listOfSomething;
- assertFalse(ajListOfString.isAssignableFrom(ajListOfSomething));
- // error: listOfString = listOfSomethingNumberish;
- assertFalse(ajListOfString.isAssignableFrom(ajListOfSomethingNumberish));
- // error: listOfString = listOfSomethingSuperDouble;
- assertFalse(ajListOfString.isAssignableFrom(ajListOfSomethingSuperDouble));
- // error: listOfString = (List<String>) listOfSomethingSuperDouble;
- assertFalse(ajListOfString.isCoerceableFrom(ajListOfSomethingSuperDouble));
-
- listOfSomething = list;
- assertTrue(ajListOfSomething.isAssignableFrom(ajList));
- listOfSomething = listOfString;
- assertTrue(ajListOfSomething.isAssignableFrom(ajListOfString));
- listOfSomething = listOfSomethingNumberish;
- assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomething));
- listOfSomething = listOfSomethingSuperDouble;
- assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomethingSuperDouble));
-
- listOfSomethingNumberish = list; // unchecked conversion
- assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajList));
- assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajList));
- // error: listOfSomethingNumberish = listOfString;
- assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfString));
- assertFalse(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfString));
- // error: listOfSomethingNumberish = listOfSomething;
- assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomething));
- listOfSomethingNumberish = (List<? extends Number>) listOfSomething;
- assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething));
- // error: listOfSomethingNumberish = listOfSomethingSuperDouble;
- assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingSuperDouble));
- // listOfSomethingNumberish = (List<? extends Number>) listOfSomethingSuperDouble;
- // assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomethingSuperDouble));
- }
-
- class C<E extends Number> {
- void m1(List<Integer> e) {
- }
-
- void m2(List<? extends Number> e) {
- }
-
- void m3(List<Number> e) {
- }
-
- void m4(List<?> e) {
- }
-
- void m5(List<E> e) {
- }
-
- void m6(List<? extends E> e) {
- }
-
- void m7(List<? extends List<? extends E>> e) {
- }
-
- void m8(List e) {
- }
-
- void m9(E e) {
- }
- }
-
- class A1 {
- }
-
- class B1 extends A1 {
- }
-
- class C1 extends B1 {
- }
-
- class D1 extends C1 {
- }
-
- class D2<E2 extends C1> {
- void m5(List<E2> e) {
- }
- }
-
- public void testAssignable02() {
- List list = new ArrayList();
- ArrayList arraylist = null;
- List<String> listOfString = new ArrayList<String>();
- List<?> listOfSomething = new ArrayList<Integer>();
- ArrayList<?> arrayListOfSomething = null;
- List<Number> listOfNumber = null;
- ArrayList<Number> arrayListOfNumber = null;
- ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
- List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
- List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
- List<Integer> listOfInteger = new ArrayList<Integer>();
- ArrayList<String> arrayListOfString;
- ArrayList<Integer> arraylistOfInteger;
- // interfaces too List<? extends A,B>
-
- ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
- ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
- ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
- ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
- ReferenceType ajList = resolve("Ljava/util/List;");
- ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
- ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
- ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
- ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
- ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
- ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
- ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
- ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
- // Effectively, whether the advice matches is based on whether what we pass at the joinpoint could
- // be bound to the specification in the args() pointcut
-
- // void around(): execution(* C.m1(..)) && args(List<Integer>){} //: Should match (it does)
- assertTrue(ajListOfInteger.isAssignableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(ArrayList<Integer>){}//: Should runtime check (it does!)
- ArrayList<Integer> x = (ArrayList<Integer>) listOfInteger;
- assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfInteger));
- assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(List<Number>){} // Should not match (it does not!)
- // error: listOfNumber = listOfInteger;
- assertFalse(ajListOfNumber.isAssignableFrom(ajListOfInteger));
- assertFalse(ajListOfNumber.isCoerceableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(ArrayList<Number>){} // Should not match (it does not)
- // error: arrayListOfNumber = listOfInteger;
- assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfInteger));
- assertFalse(ajArrayListOfNumber.isCoerceableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(List<? extends Number>){} // Should match (it does)
- listOfSomethingNumberish = listOfInteger;
- assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(ArrayList<? extends Number>){}// Should runtime check (it does!)
- arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfInteger;
- assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfInteger));
- assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(List){}// Should match (it does)
- list = listOfInteger;
- assertTrue(ajList.isAssignableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(ArrayList){}//: Should runtime check (it does not match!)
- arraylist = (ArrayList) listOfInteger;
- assertFalse(ajArrayList.isAssignableFrom(ajListOfInteger));
- assertTrue(ajArrayList.isCoerceableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(List<?>){}// Should match (it does)
- listOfSomething = listOfInteger;
- assertTrue(ajListOfSomething.isAssignableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(ArrayList<?>){}// Should runtime check (it does not match!)
- arrayListOfSomething = (ArrayList<?>) listOfInteger;
- assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfInteger));
- assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfInteger));
-
- // void around(): execution(* C.m1(..)) && args(ArrayList<String>){}// Should not match (it does not match!)
- // error: arrayListOfString = listOfInteger;
- assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfInteger));
- assertFalse(ajArrayListOfString.isCoerceableFrom(ajListOfInteger));
- }
-
- public void testAssignable03_method_m2() {
- List list = new ArrayList();
- ArrayList arraylist = null;
- List<String> listOfString = new ArrayList<String>();
- List<?> listOfSomething = new ArrayList<Integer>();
- ArrayList<?> arrayListOfSomething = null;
- List<Number> listOfNumber = null;
- ArrayList<Number> arrayListOfNumber = null;
- ArrayList<Integer> arrayListOfInteger = null;
- ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
- List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
- List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
- List<Integer> listOfInteger = new ArrayList<Integer>();
- ArrayList<String> arrayListOfString;
- ArrayList<Integer> arraylistOfInteger;
- // interfaces too List<? extends A,B>
-
- ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
- ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
- ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
- ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
- ReferenceType ajList = resolve("Ljava/util/List;");
- ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
- ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
- ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
- ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
- ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
- ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
- ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
- ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
-
- // void m2(List<? extends Number> e) {}
-
- // comment 11
- // void around(): execution(* C.m2(..)) && args(List<Integer>){} //: Should not match (but it does) ERROR
- listOfInteger = (List<Integer>) listOfSomethingNumberish;
- assertFalse(ajListOfInteger.isAssignableFrom(ajListOfSomethingNumberish));
- assertTrue(ajListOfInteger.isCoerceableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(ArrayList<Integer>){}//: Should not match (but it does!) ERROR
- arrayListOfInteger = (ArrayList<Integer>) listOfSomethingNumberish;
- assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfSomethingNumberish));
- assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(List<Number>){} //: Should not match (but it does) ERROR
- listOfNumber = (List<Number>) listOfSomethingNumberish;
- assertFalse(ajListOfNumber.isAssignableFrom(ajListOfSomethingNumberish));
- assertTrue(ajListOfNumber.isCoerceableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(ArrayList<Number>){}//: Should not runtime check (but it does!) ERROR
- arrayListOfNumber = (ArrayList<Number>) listOfSomethingNumberish;
- assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfSomethingNumberish));
- assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(List<? extends Number>){}//: Should match (it does)
- listOfSomethingNumberish = listOfSomethingNumberish;
- assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
- arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfSomethingNumberish;
- assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingNumberish));
- assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(List){}//: Should match (it does)
- list = listOfSomethingNumberish;
- assertTrue(ajList.isAssignableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR
- arraylist = (ArrayList) listOfSomethingNumberish;
- assertFalse(ajArrayList.isAssignableFrom(ajListOfSomethingNumberish));
- assertTrue(ajArrayList.isCoerceableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(List<?>){}//: Should match (it does)
- listOfSomething = listOfSomethingNumberish;
- assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(ArrayList<?>){}//: Should runtime check (it does!)
- arrayListOfSomething = (ArrayList) listOfSomethingNumberish;
- assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfSomethingNumberish));
- assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfSomethingNumberish));
-
- // void around(): execution(* C.m2(..)) && args(ArrayList<String>){}//: Should not match (it does not match!)
- // error: arrayListOfString = listOfSomethingNumberish;
- assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfSomethingNumberish));
- assertFalse(ajArrayListOfString.isCoerceableFrom(ajListOfSomethingNumberish));
- }
-
- public void testAssignable04_method_m3() {
- List list = new ArrayList();
- ArrayList arraylist = null;
- List<String> listOfString = new ArrayList<String>();
- List<?> listOfSomething = new ArrayList<Integer>();
- ArrayList<?> arrayListOfSomething = null;
- List<Number> listOfNumber = null;
- ArrayList<Number> arrayListOfNumber = null;
- ArrayList<Integer> arrayListOfInteger = null;
- ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
- List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
- List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
- List<Integer> listOfInteger = new ArrayList<Integer>();
- ArrayList arrayList = null;
- ArrayList<String> arrayListOfString;
- ArrayList<Integer> arraylistOfInteger;
- // interfaces too List<? extends A,B>
-
- ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
- ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
- ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
- ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
- ReferenceType ajList = resolve("Ljava/util/List;");
- ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
- ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
- ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
- ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
- ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
- ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
- ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
- ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
-
- // void m3(List<Number> e) { }
-
- // void around(): execution(* C.m3(..)) && args(List<Integer>){} //: Should not match (it does not)
- // error: listOfInteger = listOfNumber;
- assertFalse(ajListOfInteger.isAssignableFrom(ajListOfNumber));
- assertFalse(ajListOfInteger.isCoerceableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(ArrayList<Integer>){}//: Should not match (it does not)
- // error: arrayListOfInteger = listOfNumber;
- assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfNumber));
- assertFalse(ajArrayListOfInteger.isCoerceableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(List<Number>){}//: Should match (it does)
- listOfNumber = listOfNumber;
- assertTrue(ajListOfNumber.isAssignableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(ArrayList<Number>){}//: Should runtime match (it does)
- arrayListOfNumber = (ArrayList<Number>) listOfNumber;
- assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfNumber));
- assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(List<? extends Number>){}//: Should match (it does)
- listOfSomethingNumberish = listOfNumber;
- assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
- arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfNumber;
- assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfNumber));
- assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(List){}//: Should match (it does)
- list = listOfNumber;
- assertTrue(ajList.isAssignableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR
- arrayList = (ArrayList) listOfNumber;
- assertFalse(ajArrayList.isAssignableFrom(ajListOfNumber));
- assertTrue(ajArrayList.isCoerceableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(List<?>){}//: Should match (it does)
- listOfSomething = listOfNumber;
- assertTrue(ajListOfSomething.isAssignableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(ArrayList<?>){}//: Should runtime check (it does!)
- arrayListOfSomething = (ArrayList<?>) listOfNumber;
- assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfNumber));
- assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfNumber));
-
- // void around(): execution(* C.m3(..)) && args(ArrayList<String>){}//: Should not match (it does not match!)
- // error: arrayListOfString = listOfNumber;
- assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfNumber));
- assertFalse(ajArrayListOfString.isCoerceableFrom(ajListOfNumber));
-
- }
-
- static class ClassA<T> {
- }
-
- static interface IMarker<H> {
- }
-
- static class ClassB<T> implements IMarker<ClassA<T>> {
- }
-
- static class ClassC<T> implements IMarker<T> {
- }
-
- public void testAssignability_pr267559() {
- ClassB cb = new ClassB();
- ClassB cb2 = new ClassB();
-
- ReferenceType rcb = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$ClassB;");
- ReferenceType rcb2 = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$ClassB;");
- boolean b = rcb.isAssignableFrom(rcb2);
- assertTrue(b);
- b = rcb2.isAssignableFrom(rcb);
- assertTrue(b);
-
- rcb = resolve("Porg/aspectj/weaver/ReferenceTypeTestCase$IMarker<Porg/aspectj/weaver/ReferenceTypeTestCase$ClassA<TT;>;>;");
- rcb2 = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$ClassB;");
- b = rcb.isAssignableFrom(rcb2);
- assertTrue(b);
- }
-
- public void testAssignable03_method_m4() {
- List list = new ArrayList();
- ArrayList arraylist = null;
- List<String> listOfString = new ArrayList<String>();
- List<?> listOfSomething = new ArrayList<Integer>();
- ArrayList<?> arrayListOfSomething = null;
- List<Number> listOfNumber = null;
- ArrayList<Number> arrayListOfNumber = null;
- ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
- List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
- List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
- List<Integer> listOfInteger = new ArrayList<Integer>();
- ArrayList<String> arrayListOfString;
- ArrayList<Integer> arraylistOfInteger;
- // interfaces too List<? extends A,B>
-
- ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
- ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
- ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
- ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
- ReferenceType ajList = resolve("Ljava/util/List;");
- ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
- ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
- ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
- ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
- ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
- ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
- ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
- ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
-
- // void m4(List<?> e) {}
-
- // void around(): execution(* C.m4(..)) && args(List<Integer>){} //: Should match with unchecked warning
- listOfInteger = (List<Integer>) listOfSomething;
- assertFalse(ajListOfInteger.isAssignableFrom(ajListOfSomething));
- assertTrue(ajListOfInteger.isCoerceableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(ArrayList<Integer>){} // Should match with unchecked warning
- arraylistOfInteger = (ArrayList<Integer>) listOfSomething;
- assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfSomething));
- assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(List<Number>){} // Should match with unchecked warning
- listOfNumber = (List<Number>) listOfSomething;
- assertFalse(ajListOfNumber.isAssignableFrom(ajListOfSomething));
- assertTrue(ajListOfNumber.isCoerceableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(ArrayList<Number>){} // Should match with unchecked warning
- arrayListOfNumber = (ArrayList<Number>) listOfSomething;
- assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfSomething));
- assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(List<? extends Number>){} // Should match with unchecked warning
- listOfSomethingNumberish = (List<? extends Number>) listOfSomething;
- assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomething));
- assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(ArrayList<? extends Number>){} // Should match with unchecked warning
- arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfSomething;
- assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfSomething));
- assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(List){} // Should match
- list = listOfSomething;
- assertTrue(ajList.isAssignableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should runtime check
- arraylist = (ArrayList) listOfSomething;
- assertFalse(ajArrayList.isAssignableFrom(ajListOfSomething));
- assertTrue(ajArrayList.isCoerceableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(List<?>){}//: Should match
- list = listOfSomething;
- assertTrue(ajList.isAssignableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(ArrayList<?>){} // Should runtime check
- arrayListOfSomething = (ArrayList<?>) listOfSomething;
- assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfSomething));
- assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfSomething));
-
- // void around(): execution(* C.m4(..)) && args(ArrayList<String>){} // Should match with unchecked warning
- arrayListOfString = (ArrayList<String>) listOfSomething;
- assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfSomething));
- assertTrue(ajArrayListOfString.isCoerceableFrom(ajListOfSomething));
- }
-
- // copy of the real one in BcelClassWeaver
- public static class IfaceInitList implements PartialOrder.PartialComparable {
- final ResolvedType onType;
- List<ConcreteTypeMunger> list = new ArrayList<ConcreteTypeMunger>();
-
- IfaceInitList(ResolvedType onType) {
- this.onType = onType;
- }
-
- public int compareTo(Object other) {
- IfaceInitList o = (IfaceInitList) other;
- if (onType.isAssignableFrom(o.onType)) {
- return +1;
- } else if (o.onType.isAssignableFrom(onType)) {
- return -1;
- } else {
- return 0;
- }
- }
-
- public int fallbackCompareTo(Object other) {
- return 0;
- }
- }
-
- public void testExpensiveAssignableChecks_309336() {
- List objects = new ArrayList();
- ReferenceType rcb = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$Foo;");
- ReferenceType i = (ReferenceType) rcb.getDeclaredInterfaces()[0];
- while (i != null && i.isInterface()) {
- objects.add(Math.abs(new Random(12).nextInt(objects.size() + 1)), new IfaceInitList(i));
- ResolvedType[] rt = i.getDeclaredInterfaces();
- i = rt == null || rt.length == 0 ? null : (ReferenceType) rt[0];
- }
- for (int loop = 0; loop < 10; loop++) {
- // ReferenceType.r = 0;
- long stime = System.nanoTime();
- for (int j = 0; j < 10; j++) {
- List objects2 = new ArrayList();
- objects2.addAll(objects);
- PartialOrder.sort(objects2);
- }
- long etime = System.nanoTime();
- System.err.println("Took " + ((etime - stime) / 1000000) + "ms: calls ");// + ReferenceType.r);
- }
- // could do with asserting something... basically we are just checking we didn't run out of memory doing the sorts above!
- }
-
- public interface Operator14<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable, E7 extends Throwable, E8 extends Throwable, E9 extends Throwable, E10 extends Throwable, E11 extends Throwable, E12 extends Throwable, E13 extends Throwable, E14 extends Throwable> {
- T execute(String aArg) throws E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, RemoteException;
- }
-
- public interface Operator13<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable, E7 extends Throwable, E8 extends Throwable, E9 extends Throwable, E10 extends Throwable, E11 extends Throwable, E12 extends Throwable, E13 extends Throwable>
- extends Operator14<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E13> {
- }
-
- public interface Operator12<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable, E7 extends Throwable, E8 extends Throwable, E9 extends Throwable, E10 extends Throwable, E11 extends Throwable, E12 extends Throwable>
- extends Operator13<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E12> {
- }
-
- public interface Operator11<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable, E7 extends Throwable, E8 extends Throwable, E9 extends Throwable, E10 extends Throwable, E11 extends Throwable>
- extends Operator12<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E11> {
- }
-
- public interface Operator10<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable, E7 extends Throwable, E8 extends Throwable, E9 extends Throwable, E10 extends Throwable>
- extends Operator11<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E10> {
-
- }
-
- public interface Operator9<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable, E7 extends Throwable, E8 extends Throwable, E9 extends Throwable>
- extends Operator10<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E9> {
- }
-
- public interface Operator8<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable, E7 extends Throwable, E8 extends Throwable>
- extends Operator9<T, E1, E2, E3, E4, E5, E6, E7, E8, E8> {
- }
-
- public interface Operator7<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable, E7 extends Throwable>
- extends Operator8<T, E1, E2, E3, E4, E5, E6, E7, E7> {
- }
-
- public interface Operator6<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable>
- extends Operator7<T, E1, E2, E3, E4, E5, E6, E6> {
-
- }
-
- public interface Operator5<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable>
- extends Operator6<T, E1, E2, E3, E4, E5, E5> {
- }
-
- public interface Operator4<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable> extends
- Operator5<T, E1, E2, E3, E4, E4> {
- }
-
- public interface Operator3<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable> extends
- Operator4<T, E1, E2, E3, E3> {
- }
-
- public interface Operator2<T, E1 extends Throwable, E2 extends Throwable> extends Operator3<T, E1, E2, E2> {
-
- }
-
- public interface Operator1<T, E1 extends Throwable> extends Operator2<T, E1, E1> {
- }
-
- public interface Operator<T> extends Operator1<T, RuntimeException> {
- }
-
- class Foo implements Operator<String> {
- public String execute(String aArg) throws NullPointerException, RemoteException {
- System.out.println("Doh!");
- return aArg;
- }
- }
-
- // public void testAssignable_method_m5() {
- // List list = new ArrayList();
- // ArrayList arraylist = null;
- // List<String> listOfString = new ArrayList<String>();
- // List<?> listOfSomething = new ArrayList<Integer>();
- // ArrayList<?> arrayListOfSomething = null;
- // List<Number> listOfNumber = null;
- // ArrayList<Number> arrayListOfNumber = null;
- // ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
- // List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
- // List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
- // List<Integer> listOfInteger = new ArrayList<Integer>();
- // ArrayList<String> arrayListOfString;
- // ArrayList<Integer> arraylistOfInteger;
- // // interfaces too List<? extends A,B>
- //
- // ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
- // ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
- // ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
- // ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
- // ReferenceType ajList = resolve("Ljava/util/List;");
- // ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
- // ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
- // ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
- // ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
- // ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
- // ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
- // ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
- // ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
- // ReferenceType ajListOfEextendsNumber = resolve("Pjava/util/List<+TE")
- //
- // // class C<E extends Number> {
- // // void m5(List<E> e) { }
- // //
- // // void around(): execution(* C.m5(..)) && args(List<Integer>){} Should not match (but it does) ERROR
- //
- // // void around(): execution(* C.m5(..)) && args(ArrayList<Integer>){}//: Should not match (but it does!) ERROR
- // // void around(): execution(* C.m5(..)) && args(List<Number>){}//: Should not match (but it does!) ERROR
- // // void around(): execution(* C.m5(..)) && args(ArrayList<Number>){}//: Should not match (it does) ERROR
- // // void around(): execution(* C.m5(..)) && args(List<? extends Number>){}//: Should match (it does)
- // // void around(): execution(* C.m5(..)) && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
- // // void around(): execution(* C.m5(..)) && args(List){}//: Should match (it does)
- // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR
- // // void around(): execution(* C.m5(..)) && args(List<?>){}//: Should match (it does)
- // // void around(): execution(* C.m5(..)) && args(ArrayList<?>){}//: Should runtime check (it does not match!)
- // // void around(): execution(* C.m5(..)) && args(ArrayList<String>){}//: Should not match (it does not match!)
- // //
- // // // void around(): execution(* D2.m5(..)) && args(List<D1>){} //: Should
- // // not match (but it does) ERROR
- // // // void around(): execution(* D2.m5(..)) && args(ArrayList<D1>){}//:
- // // Should not match (but it does!) ERROR
- // // // void around(): execution(* D2.m5(..)) && args(List<C1>){}//: Should
- // // not match (but it does!) ERROR
- // // // void around(): execution(* D2.m5(..)) && args(ArrayList<C1>){}//:
- // // Should not match (it does) ERROR
- // // // void around(): execution(* D2.m5(..)) && args(List<? extends B1>){}//:
- // // Should match (it does)
- // // // void around(): execution(* D2.m5(..)) && args(ArrayList<? extends
- // // B1>){}//: Should runtime check (it does!)
- // // // void around(): execution(* D2.m5(..)) && args(List<? extends C1>){}//:
- // // Should match (it does)
- // // // void around(): execution(* D2.m5(..)) && args(ArrayList<? extends
- // // C1>){}//: Should runtime check (it does!)
- // // // void around(): execution(* D2.m5(..)) && args(List){}//: Should match
- // // (it does)
- // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should
- // // runtime check (it does not match!) ERROR
- // // // void around(): execution(* D2.m5(..)) && args(List<?>){}//: Should
- // // match (it does)
- // // // void around(): execution(* D2.m5(..)) && args(ArrayList<?>){}//:
- // // Should runtime check (it does not match!)
- // // // void around(): execution(* D2.m5(..)) && args(ArrayList<String>){}//:
- // // Should not match (it does not match!)
- // //
- // // // void around(): execution(* C.m6(..)) && args(List<Integer>){} //:
- // // Should not match (but it does) ERROR
- // // // void around(): execution(* C.m6(..)) && args(ArrayList<Integer>){}//:
- // // Should not match (but it does!) ERROR
- // // // void around(): execution(* C.m6(..)) && args(List<Number>){}//: Should
- // // not match (but it does!) ERROR
- // // // void around(): execution(* C.m6(..)) && args(ArrayList<Number>){}//:
- // // Should not match (it does) ERROR
- // // // void around(): execution(* C.m6(..)) && args(List<? extends
- // // Number>){}//: Should match (it does)
- // // // void around(): execution(* C.m6(..)) && args(ArrayList<? extends
- // // Number>){}//: Should runtime check (it does!)
- // // // void around(): execution(* C.m6(..)) && args(List){}//: Should match
- // // (it does)
- // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should
- // // runtime check (it does not match!)
- // // // void around(): execution(* C.m6(..)) && args(List<?>){}//: Should
- // // match (it does)
- // // // void around(): execution(* C.m6(..)) && args(ArrayList<?>){}//: Should
- // // runtime check (it does not match!)
- // // // void around(): execution(* C.m6(..)) && args(ArrayList<String>){}//:
- // // Should not match (it does not match!)
- // //
- // // // void around(): execution(* C.m7(..)) && args(List<List<Integer>>){}
- // // //: Should not match (but it does) ERROR
- // // // void around(): execution(* C.m7(..)) &&
- // // args(ArrayList<List<Integer>>){}//: Should not match (but it does!) ERROR
- // // // void around(): execution(* C.m7(..)) && args(List<List<Number>>){}//:
- // // Should not match (but it does!) ERROR
- // // // void around(): execution(* C.m7(..)) &&
- // // args(ArrayList<List<Number>>){}//: Should not match (but it does) ERROR
- // // // void around(): execution(* C.m7(..)) && args(List<? extends
- // // List<Number>>){}//: Should not match (but it does) ERROR
- // // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends
- // // List<Number>>){}//: Should not match (but it does!) ERROR
- // // // void around(): execution(* C.m7(..)) && args(List< ? extends List<?
- // // extends Number>>){}//: Should match (it does!)
- // // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends
- // // List<? extends Number>>){}//: Should match (it does!)
- // // // void around(): execution(* C.m7(..)) && args(List){}//: Should match
- // // (it does)
- // // // void around(): execution(* C.m7(..)) && args(ArrayList){}//: Should
- // // runtime check (it does not match!)
- // // // void around(): execution(* C.m7(..)) && args(List<?>){}//: Should
- // // match (it does)
- // // // void around(): execution(* C.m7(..)) && args(ArrayList<?>){}//: Should
- // // runtime check (it does!)
- // // // void around(): execution(* C.m7(..)) &&
- // // args(ArrayList<List<String>>){}//: Should not match (it does not match!)
- // //
- // // // void around(): execution(* C.m8(..)) && args(List<Integer>){} //:
- // // Should match with unchecked conversion (it does)
- // // // void around(): execution(* C.m8(..)) && args(ArrayList<Integer>){}//:
- // // Should runtime check with unchecked conversion (it does!)
- // // // void around(): execution(* C.m8(..)) && args(List<Number>){}//: Should
- // // match with unchecked conversion (it does!)
- // // // void around(): execution(* C.m8(..)) && args(ArrayList<Number>){}//:
- // // Should runtime check with unchecked conversion (it does)
- // // // void around(): execution(* C.m8(..)) && args(List<? extends
- // // Number>){}//: Should match with unchecked conversion (it does!)
- // // // void around(): execution(* C.m8(..)) && args(ArrayList<? extends
- // // Number>){}//: Should runtime check with unchecked conversion (it does)
- // // // void around(): execution(* C.m8(..)) && args(List){}//: Should match
- // // (it does)
- // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should
- // // runtime check (it does!)
- // // // void around(): execution(* C.m8(..)) && args(List<?>){}//: Should
- // // match (it does)
- // // // void around(): execution(* C.m8(..)) && args(ArrayList<?>){}//: Should
- // // runtime check (it does!)
- // // // void around(): execution(* C.m8(..)) && args(ArrayList<String>){}//:
- // // Should not match (it does not match!)
- // //
- // // // void around(): execution(* C.m9(..)) && args(List<Integer>){} //:
- // // Should not match (but it does) ERROR
- // // // void around(): execution(* C.m9(..)) && args(ArrayList<Integer>){}//:
- // // Should not match (it does not match!)
- // // // void around(): execution(* C.m9(..)) && args(Number){}//: Should match
- // // (it does!)
- // // // void around(): execution(* C.m9(..)) && args(Integer){}//: Should
- // // runtime check (it does)
- // // // void around(): execution(* C.m9(..)) && args(List<? extends
- // // Number>){}//: Should not match (but it does) ERROR
- // // // void around(): execution(* C.m9(..)) && args(ArrayList<? extends
- // // Number>){}//: Should not match (it does not match!)
- // // // void around(): execution(* C.m9(..)) && args(List){}//: Should not
- // // match (but it does) ERROR
- // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should
- // // not match (it does not match!)
- // // // void around(): execution(* C.m9(..)) && args(List<?>){}//: Should not
- // // match (but it does) ERROR
- // // // void around(): execution(* C.m9(..)) && args(ArrayList<?>){}//: Should
- // // not match (it does not match!)
- // // // void around(): execution(* C.m9(..)) && args(String){}//: Should not
- // // match (it does not match!)
- //
- // }
-
- private ReferenceType resolve(String sig) {
- return (ReferenceType) world.resolve(UnresolvedType.forSignature(sig));
- }
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java b/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java
deleted file mode 100644
index 475c330eb..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2005-2017 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;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.Field;
-
-import org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateTest;
-
-public class TestJava5ReflectionBasedReferenceTypeDelegate extends ReflectionBasedReferenceTypeDelegateTest {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("TestJava5ReflectionBasedReferenceTypeDelegate");
- suite.addTestSuite(TestJava5ReflectionBasedReferenceTypeDelegate.class);
- return suite;
- }
-
- /**
- * Let's play about with a generic type and ensure we can work with it in a reflective world.
- */
- public void testResolveGeneric() {
- UnresolvedType collectionType = UnresolvedType.forName("java.util.Collection");
- world.resolve(collectionType).getRawType().resolve(world);
- ResolvedMember[] methods = world.resolve(collectionType).getDeclaredMethods();
- int i = -1;
- for (int j=0;j<methods.length;j++) {
- ResolvedMember method = methods[j];
- if (method.getName().equals("toArray") && method.getParameterSignature().equals("([TT;)")) {
- i = j;
- }
- }
- assertTrue("Couldn't find 'toArray' in the set of methods? ", i != -1);
- // String expectedSignature = "java.lang.Object[] java.util.Collection.toArray(java.lang.Object[])";
- String expectedSignature = "([Ljava/lang/Object;)[Ljava/lang/Object;";
-
- assertTrue("Expected signature of '" + expectedSignature + "' but it was '" + methods[i].getSignatureErased(), methods[i]
- .getSignatureErased().equals(expectedSignature));
- }
-
- /**
- * Can we resolve the dreaded Enum type...
- */
- public void testResolveEnum() {
- ResolvedType enumType = world.resolve("java.lang.Enum");
- assertTrue("Should be the raw type but is " + enumType.typeKind, enumType.isRawType());
- ResolvedType theGenericEnumType = enumType.getGenericType();
- assertTrue("Should have a type variable ", theGenericEnumType.getTypeVariables().length > 0);
- TypeVariable tv = theGenericEnumType.getTypeVariables()[0];
- String expected = "TypeVar E extends java.lang.Enum<E>";
- assertTrue("Type variable should be '" + expected + "' but is '" + tv + "'", tv.toString().equals(expected));
- }
-
- public void testResolveClass() {
- world.resolve("java.lang.Class").getGenericType();
- }
-
- public void testGenericInterfaceSuperclass_ReflectionWorldResolution() {
-
- UnresolvedType javaUtilMap = UnresolvedType.forName("java.util.Map");
-
- ReferenceType rawType = (ReferenceType) world.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));
- }
-
- /**
- * This is testing the optimization in the reflective annotation finder to verify that if you only want runtime
- * annotation info then we use reflection and don't go digging through the classfile bytes.
- */
- public void testAnnotationFinderClassRetention() throws Exception {
- ResolvedType type = world.resolve(AnnoTesting.class.getName());
- ResolvedMember[] ms = type.getDeclaredMethods();
- int findMethod = findMethod("a", ms);
-
- ResolvedMember methodWithOnlyClassLevelAnnotation = ms[findMethod("a", ms)];
- ResolvedMember methodWithOnlyRuntimeLevelAnnotation = ms[findMethod("b", ms)];
- ResolvedMember methodWithClassAndRuntimeLevelAnnotations = ms[findMethod("c", ms)];
- ResolvedMember methodWithClassAndRuntimeLevelAnnotations2 = ms[findMethod("d", ms)];
-
- assertTrue(methodWithOnlyClassLevelAnnotation.hasAnnotation(world.resolve(AnnoClass.class.getName())));
- assertTrue(methodWithOnlyRuntimeLevelAnnotation.hasAnnotation(world.resolve(AnnoRuntime.class.getName())));
-
- // This is the tricky scenario.
-
- // When asking about the runtime level annotations it should not go digging into bcel
- assertTrue(methodWithClassAndRuntimeLevelAnnotations.hasAnnotation(world.resolve(AnnoRuntime.class.getName())));
-
- Field annotationsField = ResolvedMemberImpl.class.getDeclaredField("annotationTypes");
- annotationsField.setAccessible(true);
- ResolvedType[] annoTypes = (ResolvedType[])annotationsField.get(methodWithClassAndRuntimeLevelAnnotations);
-
- // Should only be the runtime one here
- assertEquals(1, annoTypes.length);
-
- // But when you do ask again and this time for class level, it should redo the unpack and pull both runtime and class out
- assertTrue(methodWithClassAndRuntimeLevelAnnotations.hasAnnotation(world.resolve(AnnoClass.class.getName())));
-
- annotationsField.setAccessible(true);
- annoTypes = (ResolvedType[])annotationsField.get(methodWithClassAndRuntimeLevelAnnotations);
-
- // Now both should be there
- assertEquals(2, annoTypes.length);
-
- assertTrue(methodWithClassAndRuntimeLevelAnnotations2.hasAnnotation(world.resolve(AnnoRuntime.class.getName())));
- // now ask for 'all annotations' via another route, this should reunpack and get them all
- ResolvedType[] annotations = methodWithClassAndRuntimeLevelAnnotations2.getAnnotationTypes();
- assertEquals(2,annotations.length);
- }
-
- @Retention(RetentionPolicy.CLASS)
- @interface AnnoClass {}
-
- @Retention(RetentionPolicy.RUNTIME)
- @interface AnnoRuntime {}
-
- class AnnoTesting {
-
- @AnnoClass
- public void a() {}
-
- @AnnoRuntime
- public void b() {}
-
- @AnnoClass @AnnoRuntime
- public void c() {}
-
- @AnnoClass @AnnoRuntime
- public void d() {}
-
- }
-
-} \ 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
deleted file mode 100644
index 367a4fc93..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java
+++ /dev/null
@@ -1,81 +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:
- * Adrian Colyer Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import junit.framework.TestCase;
-
-import org.aspectj.weaver.bcel.BcelWorld;
-
-/**
- * @author colyer
- *
- */
-public class TypeVariableReferenceTypeTestCase extends TestCase {
-
- ReferenceType javaLangClass;
- ReferenceType jlNumber;
- ReferenceType javaLangObject;
- BoundedReferenceType extendsClass;
- BoundedReferenceType superClass;
- BoundedReferenceType extendsWithExtras;
- BcelWorld world;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- world = new BcelWorld("../bin");
- world.setBehaveInJava5Way(true);
- javaLangClass = (ReferenceType) world.resolve(UnresolvedType.forName("java/lang/Class"));
- jlNumber = (ReferenceType) world.resolve(UnresolvedType.forSignature("Ljava/lang/Number;"));
- 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")) });
- }
-
- public void testConstructionByNameAndVariable() {
- TypeVariable tv = new TypeVariable("T", javaLangClass);
- TypeVariableReferenceType tvrt = new TypeVariableReferenceType(tv, world);
- assertEquals("T", tvrt.getTypeVariable().getName());
- assertEquals(javaLangClass, tvrt.getTypeVariable().getUpperBound());
- }
-
- public void testBounds() {
- // Load up the testclass from below
- ResolvedType testerClass = world.resolve(Tester1.class.getName());
- ResolvedType genericTesterClass = testerClass.getGenericType();
-
- // Check the declaration type variable
- TypeVariable[] typevars = genericTesterClass.getTypeVariables();
- TypeVariable typevar = typevars[0];
- assertEquals(jlNumber, typevar.getUpperBound());
- assertEquals("T", typevar.getName());
- ResolvedMember member = genericTesterClass.getDeclaredMethods()[1];
-
- // getParameterTypes() returning the erased parameter
- UnresolvedType param = member.getParameterTypes()[0];
- assertEquals(jlNumber, param);
-
- // Check the type variable reference
- TypeVariableReferenceType tvReference = (TypeVariableReferenceType) member.getGenericParameterTypes()[0];
- assertEquals("T", tvReference.getTypeVariableName());
- assertEquals(jlNumber, tvReference.getUpperBound());
- assertEquals(jlNumber, tvReference.getDelegate().getResolvedTypeX());
- }
-
- class Tester1<T extends Number> {
- public void method(T t) {
- }
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java
deleted file mode 100644
index 8ef8f70c1..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java
+++ /dev/null
@@ -1,110 +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:
- * Adrian Colyer Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver;
-
-import junit.framework.TestCase;
-
-import org.aspectj.weaver.bcel.BcelWorld;
-
-public class TypeVariableTestCase extends TestCase {
-
- private UnresolvedType javaLangNumber;
- private UnresolvedType javaLangDouble;
- private UnresolvedType javaUtilList;
- private UnresolvedType javaIoSerializable;
- private World world;
-
- public void testName() {
- TypeVariable tv = new TypeVariable("T");
- assertEquals("T", tv.getName());
- }
-
- public void testDefaultBounds() {
- TypeVariable tv = new TypeVariable("T");
- assertEquals("Object", UnresolvedType.OBJECT, tv.getFirstBound());
- assertNull(tv.getUpperBound());
- assertEquals("no additional bounds", 0, tv.getSuperInterfaces().length);
- }
-
- 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.getSuperInterfaces().length);
- assertEquals("java.util.List", javaUtilList, tv.getSuperInterfaces()[0]);
-
- tv = new TypeVariable("E", null, new UnresolvedType[] { javaUtilList });
- assertEquals("1 additional bound", 1, tv.getSuperInterfaces().length);
- assertEquals("java.util.List", javaUtilList, tv.getSuperInterfaces()[0]);
- }
-
- public void testResolution() {
- TypeVariable tv = new TypeVariable("T", javaLangNumber, new UnresolvedType[] { javaUtilList });
- tv.resolve(world);
- assertEquals("resolved number", javaLangNumber.resolve(world), tv.getUpperBound());
- assertEquals("resolved list", javaUtilList.resolve(world), tv.getSuperInterfaces()[0]);
- }
-
- 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)));
- }
-
- // ---
-
- @Override
- 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();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java
deleted file mode 100644
index 58f774840..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java
+++ /dev/null
@@ -1,68 +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:
- * 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.JavaClass;
-import org.aspectj.apache.bcel.classfile.Signature;
-import org.aspectj.util.GenericSignature;
-import org.aspectj.util.GenericSignatureParser;
-import org.aspectj.util.GenericSignature.ClassSignature;
-import org.aspectj.weaver.UnresolvedType;
-
-/**
- * @author colyer
- *
- */
-public class BcelGenericSignatureToTypeXTestCase extends TestCase {
-
- public final GenericSignature.ClassSignature getGenericClassTypeSignature(JavaClass jClass) {
- Signature sig = jClass.getSignatureAttribute();
- if (sig != null) {
- GenericSignatureParser parser = new GenericSignatureParser();
- ClassSignature classSig = parser.parseAsClassSignature(sig.getSignature());
- return classSig;
- }
- return null;
- }
-
- public void testEnumFromHell() throws Exception {
- BcelWorld world = new BcelWorld();
- JavaClass javaLangEnum = Repository.lookupClass("java/lang/Enum");
- GenericSignature.ClassSignature cSig = getGenericClassTypeSignature(javaLangEnum);
- 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();
- GenericSignature.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());
- BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superInterfaceSignatures[0], cSig.formalTypeParameters,
- world);
-
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelWorldReferenceTypeTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelWorldReferenceTypeTest.java
deleted file mode 100644
index 0ab70023e..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelWorldReferenceTypeTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002-2008 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:
- * PARC initial implementation
- * ******************************************************************/
-package org.aspectj.weaver.bcel;
-
-import org.aspectj.weaver.CommonReferenceTypeTests;
-import org.aspectj.weaver.World;
-
-public class BcelWorldReferenceTypeTest extends CommonReferenceTypeTests {
-
- public World getWorld() {
- return new BcelWorld();
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java
deleted file mode 100644
index 5eda5d577..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java
+++ /dev/null
@@ -1,422 +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://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.IOException;
-
-import junit.framework.TestCase;
-
-import org.aspectj.weaver.BoundedReferenceType;
-import org.aspectj.weaver.CompressingDataOutputStream;
-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(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(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();
- ConstantPoolSimulator cps = new ConstantPoolSimulator();
- CompressingDataOutputStream dos = new CompressingDataOutputStream(baos, cps);
- etp.write(dos);
- dos.flush();
- dos.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- VersionedDataInputStream in = new VersionedDataInputStream(bais, cps);
- 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
deleted file mode 100644
index 72c7c85f7..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java
+++ /dev/null
@@ -1,316 +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:
- * Adrian Colyer Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver.reflect;
-
-import java.lang.reflect.Method;
-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(UnresolvedType.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);
- }
- }
-
- public void testArrayArgsSig() throws Exception {
- Method invokeMethod = Method.class.getMethod("invoke", new Class[] { Object.class, Object[].class });
- ResolvedMember reflectionMethod = ReflectionBasedReferenceTypeDelegateFactory.createResolvedMethod(invokeMethod, world);
- String exp = "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;";
- assertTrue("Expected: \n" + exp + "\n but got:\n" + reflectionMethod.getSignature(), reflectionMethod.getSignature()
- .equals(exp));
- }
-
- // 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/ReflectionWorldReferenceTypeTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldReferenceTypeTest.java
deleted file mode 100644
index 720c88289..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldReferenceTypeTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002-2008 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
- * ******************************************************************/
-package org.aspectj.weaver.reflect;
-
-import org.aspectj.weaver.CommonReferenceTypeTests;
-import org.aspectj.weaver.World;
-
-public class ReflectionWorldReferenceTypeTest extends CommonReferenceTypeTests {
-
- protected boolean getSupportsAutoboxing() {
- return true;
- }
-
- public World getWorld() {
- return new ReflectionWorld(false, getClass().getClassLoader());
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java
deleted file mode 100644
index 1108ca13c..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2005,2017 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
- * ******************************************************************/
-package org.aspectj.weaver.reflect;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.List;
-import java.util.Map;
-
-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.WeakClassLoaderReference;
-import org.aspectj.weaver.World;
-import org.aspectj.weaver.bcel.BcelWorld;
-
-import junit.framework.TestCase;
-
-/**
- * @author Andy Clement
- * @author Adrian Colyer
- */
-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());
- }
-
- // Removed for now. In Spring the reflection worlds are customized by introducing new
- // PCD handlers. It means more thought needs to be put into reusing worlds.
- public void xtestReflectionWorldFactory() throws Exception {
- ClassLoader parent = getClass().getClassLoader();
- ClassLoader cl1 = new URLClassLoader(new URL[] {}, parent);
- ClassLoader cl2 = new URLClassLoader(new URL[] {}, parent);
-
- WeakClassLoaderReference wcl1 = new WeakClassLoaderReference(cl1);
- WeakClassLoaderReference wcl2 = new WeakClassLoaderReference(cl2);
- ReflectionWorld a = ReflectionWorld.getReflectionWorldFor(wcl1);
-
- ResolvedType stringClass1 = a.resolve(String.class);
- assertNotNull(stringClass1);
-
- ReflectionWorld b = ReflectionWorld.getReflectionWorldFor(wcl1);
-
- // They should be the same because the classloader has not gone away
- assertTrue(a==b);
-
- cl1 = null;
- for (int i=0;i<100;i++) {
- System.gc(); // How robust is it that this should be causing the reference to be collected?
- }
- b = ReflectionWorld.getReflectionWorldFor(wcl1);
-
- assertFalse(a==b);
-
- cl1 = new URLClassLoader(new URL[] {}, parent);
- wcl1 = new WeakClassLoaderReference(cl1);
- a = ReflectionWorld.getReflectionWorldFor(wcl1);
- b = ReflectionWorld.getReflectionWorldFor(wcl2);
- assertFalse(a==b);
-
- Field declaredField = ReflectionWorld.class.getDeclaredField("rworlds");
- declaredField.setAccessible(true);
- Map worlds = (Map)declaredField.get(null);
- assertEquals(2, worlds.size());
-
- cl2 = null;
- for (int i=0;i<100;i++) {
- System.gc(); // How robust is it that this should be causing the reference to be collected?
- }
- ReflectionWorld.getReflectionWorldFor(wcl1); // need to call this to trigger tidyup
- assertEquals(1, worlds.size());
-
- cl1 = null;
- for (int i=0;i<100;i++) {
- System.gc(); // How robust is it that this should be causing the reference to be collected?
- }
- ReflectionWorld.getReflectionWorldFor(wcl1); // need to call this to trigger tidyup
- assertEquals(0, worlds.size());
-
- cl1 = new URLClassLoader(new URL[] {}, parent);
- wcl1 = new WeakClassLoaderReference(cl1);
- ReflectionWorld reflectionWorldFor = ReflectionWorld.getReflectionWorldFor(wcl1);
- assertEquals(1, worlds.size());
- ReflectionWorld.cleanUpWorlds();
- assertEquals(0, worlds.size());
- }
-
- 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", UnresolvedType.INT, world.resolve(int.class));
- assertEquals("void", UnresolvedType.VOID, world.resolve(void.class));
- }
-
- static class AbstractSuperClass<A,B> {}
- static interface InterfaceOne {}
- static interface InterfaceTwo<A> {}
- static class ID {}
- static abstract class AbstractTestClass<T> extends AbstractSuperClass<T,ID> implements InterfaceOne, InterfaceTwo<T> {
-
- }
- static class TestType {}
-// static class ConcreteClass extends AbstractTestClass<TestType> {
- static class ConcreteClass extends AbstractTestClass<List<TestType>> {
- }
-
- static class Bar extends ConcreteClass {}
-
- public void testGenerics() {
- ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader());
-// world.lookupOrCreateName(UnresolvedType.forName(AbstractTestClass.class.getName()));
-// ResolvedType resolvedType = world.resolve(AbstractTestClass.class);
- JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world);
- ResolvedType resolvedType2 = converter.fromType(ConcreteClass.class);
- }
-
- public void testTypeConversions_509327() throws Exception {
- ReflectionWorld rWorld = new ReflectionWorld(getClass().getClassLoader());
- JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(rWorld);
-
- // Check basic conversion of String to String
- Method method = TestClass.class.getDeclaredMethod("m");
- Type stringType = method.getGenericReturnType();
- assertEquals("java.lang.String",stringType.getTypeName());
- ResolvedType stringResolvedType = converter.fromType(stringType);
- assertEquals("java.lang.String",stringResolvedType.getName());
-
- // public String m() { return ""; }
- method = TestClass2.class.getDeclaredMethod("m");
- stringType = method.getGenericReturnType();
- assertEquals("java.lang.String",stringType.getTypeName());
- stringResolvedType = converter.fromType(stringType);
- assertEquals("java.lang.String",stringResolvedType.getName());
-
- // Verify that the conversion process creates the same thing as the bcel unpacking
-
- // Here the return type is a non-static inner of a generic class
- // public Inner m2() { return null; }
- method = TestClass2.class.getDeclaredMethod("m2");
- Type innerType = method.getGenericReturnType();
- assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2<T>.Inner",innerType.getTypeName());
- ResolvedType rType_Inner = converter.fromType(innerType);
- assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",rType_Inner.getSignature());
- assertEquals(UnresolvedType.TypeKind.SIMPLE,rType_Inner.getTypekind());
- ResolvedType rType_Outer = rType_Inner.getOuterClass();
- assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2;",rType_Outer.getSignature());
-
- BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null);
- bWorld.setBehaveInJava5Way(true);
- UnresolvedType javaUtilHashMap = UnresolvedType.forName("java.util.HashMap");
- ReferenceType rawType = (ReferenceType) bWorld.resolve(javaUtilHashMap);
- assertNotNull(rawType);
-
- // Now use bcel to resolve the same m2 method, and compare the signatures of the return types
- ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName()));
- assertNotNull(bResolved_TestClass2);
- ResolvedMember bMethod_m2 = findMethod(bResolved_TestClass2,"m2");
- ResolvedType bType_Inner = (ResolvedType) bMethod_m2.getReturnType();
- assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",bType_Inner.getSignature());
- assertEquals(UnresolvedType.TypeKind.SIMPLE,bType_Inner.getTypekind());
- ResolvedType bType_Outer = bType_Inner.getOuterClass();
- assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2;",bType_Outer.getSignature());
-
- assertEquals(bType_Inner.getSignature(),rType_Inner.getSignature());
- assertEquals(bType_Outer.getSignature(),rType_Outer.getSignature());
- }
-
-
- public void testTypeConversions_509327_2() throws Exception {
- ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader());
- JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world);
- BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null);
- bWorld.setBehaveInJava5Way(true);
-
- // Slightly more advanced, now the method is returning a parameterized form of the outer
- // generic class
-
- // public TestClass2<String>.Inner m3() { return new TestClass2<String>.Inner("Foo"); }
- Method method = TestClass2.class.getDeclaredMethod("m3");
- Type type_ParameterizedInner = method.getGenericReturnType();
- assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2<java.lang.String>.Inner",type_ParameterizedInner.getTypeName());
- ResolvedType rType_ParameterizedInner = converter.fromType(type_ParameterizedInner);
- // NOTE: DECLARED PARAMETERIZATION OF OUTER IS LOST
- assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",rType_ParameterizedInner.getSignature());
-
- ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName()));
- assertNotNull(bResolved_TestClass2);
- ResolvedMember bMethod_m3 = findMethod(bResolved_TestClass2,"m3");
- ResolvedType bType_Inner = (ResolvedType) bMethod_m3.getReturnType();
- // NOTE: DECLARED PARAMETERIZATION OF OUTER IS LOST
- assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",bType_Inner.getSignature());
-
- assertEquals(UnresolvedType.TypeKind.SIMPLE,bType_Inner.getTypekind());
- ResolvedType bType_Outer = bType_Inner.getOuterClass();
-
- // Fields seem to lose it too, although the backinggenericmember has the info
-// ResolvedMember bField_f = findField(bResolved_TestClass2,"f");
-// ResolvedMember backingGenericMember = bField_f.getBackingGenericMember();
-// System.out.println(backingGenericMember);
-// System.out.println(backingGenericMember.getGenericReturnType());
-// System.out.println(bField_f);
-// System.out.println(bField_f.getSignature());
-// System.out.println(bField_f.getGenericReturnType());
- }
-
-// public void testbar() throws Exception {
-// ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader());
-// JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world);
-//
-// // public TestClass2<String>.Inner m3() { return new TestClass2<String>.Inner("Foo"); }
-// Method method = TestClass2.class.getDeclaredMethod("m3");
-// Type type_ParameterizedInner = method.getGenericReturnType();
-// assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2<java.lang.String>.Inner",type_ParameterizedInner.getTypeName());
-// ResolvedType rType_ParameterizedInner = converter.fromType(type_ParameterizedInner);
-// System.out.println(rType_ParameterizedInner);
-// System.out.println(type_ParameterizedInner.getTypeName());
-// }
-//
-// public void testfoo() {
-// ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader());
-// JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world);
-// BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null);
-// bWorld.setBehaveInJava5Way(true);
-//
-//
-// ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName()));
-// ResolvedMember bField_f = findField(bResolved_TestClass2,"f");
-// System.out.println(bField_f);
-// System.out.println(bField_f.getGenericReturnType());
-// System.out.println(bField_f.getReturnType());
-// System.out.println(bField_f.getBackingGenericMember().getGenericReturnType());
-// }
-
- static class TestClass {
- public String m() { return ""; }
- }
-
- static class TestClass2<T> {
- class Inner {
- T t;
- Inner(T t) {
- this.t = t;
- }
- }
- public String m() { return ""; }
- public Inner m2() { return null; }
- public TestClass2<String> f;
- public TestClass2<String>.Inner m3() { return new TestClass2<String>.Inner("Foo"); }
- }
-
- private ResolvedMember findMethod(ResolvedType resolvedType, String methodName) {
- for (ResolvedMember method: resolvedType.getDeclaredMethods()) {
- if (method.getName().equals(methodName)) {
- return method;
- }
- }
- return null;
- }
-
- private ResolvedMember findField(ResolvedType resolvedType, String fieldName) {
- for (ResolvedMember field: resolvedType.getDeclaredFields()) {
- if (field.getName().equals(fieldName)) {
- return field;
- }
- }
- return null;
- }
-
-}
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java
deleted file mode 100644
index f651a2f29..000000000
--- a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java
+++ /dev/null
@@ -1,746 +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:
- * Adrian Colyer Initial implementation
- * ******************************************************************/
-package org.aspectj.weaver.tools;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.aspectj.lang.annotation.Pointcut;
-import org.aspectj.weaver.ResolvedType;
-import org.aspectj.weaver.internal.tools.PointcutExpressionImpl;
-import org.aspectj.weaver.patterns.AbstractPatternNodeVisitor;
-import org.aspectj.weaver.patterns.AndAnnotationTypePattern;
-import org.aspectj.weaver.patterns.AnnotationPatternList;
-import org.aspectj.weaver.patterns.AnyAnnotationTypePattern;
-import org.aspectj.weaver.patterns.BindingAnnotationTypePattern;
-import org.aspectj.weaver.patterns.ExactAnnotationTypePattern;
-import org.aspectj.weaver.patterns.KindedPointcut;
-import org.aspectj.weaver.patterns.NotAnnotationTypePattern;
-import org.aspectj.weaver.patterns.OrAnnotationTypePattern;
-import org.aspectj.weaver.patterns.SignaturePattern;
-import org.aspectj.weaver.patterns.TypePattern;
-import org.aspectj.weaver.patterns.TypePatternList;
-import org.aspectj.weaver.patterns.WildAnnotationTypePattern;
-
-import test.A1AnnotatedType;
-import test.A2AnnotatedType;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test parameter pointcut parsing. Extended by Andy Clement to cover parameter annotation matching.
- *
- */
-public class Java15PointcutExpressionTest extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("Java15PointcutExpressionTest");
- suite.addTestSuite(Java15PointcutExpressionTest.class);
- return suite;
- }
-
- private PointcutParser parser;
- private Method a;
- private Method b;
- private Method c;
- private Method d;
-
- /**
- * Parse some expressions and ensure we capture the parameter annotations and parameter type annotations correctly.
- * Buckle up, this will get complicated ;)
- */
- public void testParseParameterAnnotationExpressions() {
- PointcutParser p = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
- PointcutExpression pexpr = null;
-
- pexpr = p.parsePointcutExpression("execution(public void foo(@MA *))");
- checkParameterAnnotations(pexpr,0,null,"@MA","exact[@MA:t]");
-
- pexpr = p.parsePointcutExpression("execution(public void foo(@MA (*)))");
- checkParameterAnnotations(pexpr,0,"@MA",null,"exact[@MA:p]");
-
- pexpr = p.parsePointcutExpression("execution(public void foo(@MA @MB *))");
- checkParameterAnnotations(pexpr,0,null,"@MA @MB","(exact[@MA:t] and exact[@MB:t])");
-
- pexpr = p.parsePointcutExpression("execution(public void foo(@MA (@MB *)))");
- checkParameterAnnotations(pexpr,0,"@MA","@MB","(exact[@MA:p] and exact[@MB:t])");
-
- pexpr = p.parsePointcutExpression("execution(public void foo(@MA @MB (@MC *)))");
- checkParameterAnnotations(pexpr,0,"@MA @MB","@MC","((exact[@MA:p] and exact[@MB:p]) and exact[@MC:t])");
-
- pexpr = p.parsePointcutExpression("execution(public void foo(@MA (@MB @MC @MD *)))");
- checkParameterAnnotations(pexpr,0,"@MA","@MB @MC @MD","(exact[@MA:p] and ((exact[@MB:t] and exact[@MC:t]) and exact[@MD:t]))");
-
- pexpr = p.parsePointcutExpression("execution(public void foo(@(MA || MB) (@MC @MD *)))");
- checkParameterAnnotations(pexpr,0,null/*Should be MA MB */,"@MC @MD","(wild[(MA || MB)] and (exact[@MC:t] and exact[@MD:t]))"); // I dont think WildAnnotationTypePatterns work properly...
-
- pexpr = p.parsePointcutExpression("execution(public void foo(@MA (@MB *),(@MC *),@MD (*)))");
- checkParameterAnnotations(pexpr,0,"@MA","@MB","(exact[@MA:p] and exact[@MB:t])");
- checkParameterAnnotations(pexpr,1,null,"@MC","exact[@MC:t]");
- checkParameterAnnotations(pexpr,2,"@MD",null,"exact[@MD:p]");
-
- }
-
- public void testMatchingAnnotationValueExpressions() throws SecurityException, NoSuchMethodException {
- PointcutParser p = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
- PointcutExpression pexpr = null;
- ShadowMatch match = null;
-
- Method n = test.AnnoValues.class.getMethod("none");
- Method r = test.AnnoValues.class.getMethod("redMethod");
- Method g = test.AnnoValues.class.getMethod("greenMethod");
- Method b = test.AnnoValues.class.getMethod("blueMethod");
- Method d = test.AnnoValues.class.getMethod("defaultMethod");
-
- pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.RED) public void *(..))");
- assertTrue("Should match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED
- assertTrue("Should match", pexpr.matchesMethodExecution(r).alwaysMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(d).alwaysMatches());
-
- pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.GREEN) public void *(..))");
- assertTrue("Should not match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED
- assertTrue("Should not match", pexpr.matchesMethodExecution(r).neverMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(d).neverMatches());
-
- pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.BLUE) public void *(..))");
- assertTrue("Should not match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED
- assertTrue("Should not match", pexpr.matchesMethodExecution(r).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(d).neverMatches());
-
- pexpr = p.parsePointcutExpression("execution(@test.A3 public void *(..))");
- assertTrue("Should match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED
- assertTrue("Should match", pexpr.matchesMethodExecution(r).alwaysMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(d).alwaysMatches());
-
- }
-
- private static final Set<PointcutPrimitive> DEFAULT_SUPPORTED_PRIMITIVES = new HashSet<PointcutPrimitive>();
-
- static {
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION);
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.ARGS);
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.REFERENCE);
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.THIS);
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.TARGET);
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.WITHIN);
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ANNOTATION);
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_WITHIN);
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ARGS);
- DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_TARGET);
- }
-
- public void testPerformanceOfPointcutParsing() {
- String expression = "execution(public * rewards.internal.*.*Repository+.*(..))";
- long stime1 = System.currentTimeMillis();
- PointcutParser parser = PointcutParser.getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(DEFAULT_SUPPORTED_PRIMITIVES);
- long stime2 = System.currentTimeMillis();
- PointcutExpression pointcutExpression = parser.parsePointcutExpression(expression, null, new PointcutParameter[0]);
- long etime = System.currentTimeMillis();
- System.out.println("Time to get a parser "+(stime2-stime1)+"ms");
- System.out.println("Time taken to parse expression is "+(etime-stime2)+"ms");
- }
-
-
- public void testPerformanceOfPointcutParsingWithBean() {
- String expression = "execution(public * rewards.internal.*.*Repository+.*(..))";
- PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
- BeanDesignatorHandler beanHandler = new BeanDesignatorHandler();
- parser.registerPointcutDesignatorHandler(beanHandler);
- long stime = System.currentTimeMillis();
- PointcutExpression pointcutExpression = parser.parsePointcutExpression(expression, null, new PointcutParameter[0]);
- long etime = System.currentTimeMillis();
- System.out.println("Time taken to parse expression is "+(etime-stime)+"ms");
- }
-
- private class BeanDesignatorHandler implements PointcutDesignatorHandler {
-
- private String askedToParse;
- public boolean simulateDynamicTest = false;
-
- public String getDesignatorName() {
- return "bean";
- }
-
- /* (non-Javadoc)
- * @see org.aspectj.weaver.tools.PointcutDesignatorHandler#parse(java.lang.String)
- */
- public ContextBasedMatcher parse(String expression) {
- this.askedToParse = expression;
- return null;
-// return new BeanPointcutExpression(expression,this.simulateDynamicTest);
- }
-
- public String getExpressionLastAskedToParse() {
- return this.askedToParse;
- }
- }
-
-
- /**
- * Test matching of pointcuts against expressions. A reflection world is being used on the backend here (not a Bcel one).
- */
- public void testMatchingParameterAnnotationExpressions() throws SecurityException, NoSuchMethodException {
- PointcutParser p = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
- PointcutExpression pexpr = null;
- ShadowMatch match = null;
-
- Method a = test.A.class.getMethod("a",new Class[] {String.class}); // public void a(String s) {}
- Method b = test.A.class.getMethod("b",new Class[] {String.class}); // public void b(@A1 String s) {}
- Method c = test.A.class.getMethod("c",new Class[] {String.class}); // public void c(@A1 @A2 String s) {}
-// Method d = test.A.class.getMethod("d",new Class[] {String.class,String.class});// public void d(@A1 String s,@A2 String t) {}
-
- Method e = test.A.class.getMethod("e",new Class[] {A1AnnotatedType.class}); // public void e(A1AnnotatedType s) {}
- Method f = test.A.class.getMethod("f",new Class[] {A2AnnotatedType.class}); // public void f(A2AnnotatedType s) {}
- Method g = test.A.class.getMethod("g",new Class[] {A1AnnotatedType.class}); // public void g(@A2 A1AnnotatedType s) {}
- Method h = test.A.class.getMethod("h",new Class[] {A1AnnotatedType.class}); // public void h(@A1 A1AnnotatedType s) {}
-// Method i = test.A.class.getMethod("i",new Class[] {A1AnnotatedType.class,String.class}); // public void i(A1AnnotatedType s,@A2 String t) {}
-// Method j = test.A.class.getMethod("j",new Class[] {String.class}); // public void j(@A1 @A2 String s) {}
-
- pexpr = p.parsePointcutExpression("execution(public void *(@test.A1 *))");
- assertTrue("Should not match", pexpr.matchesMethodExecution(a).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(c).neverMatches());
-
- pexpr = p.parsePointcutExpression("execution(public void *(@test.A1 (*)))");
- assertTrue("Should not match", pexpr.matchesMethodExecution(a).neverMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(c).alwaysMatches());
-
- pexpr = p.parsePointcutExpression("execution(public void *(@test.A1 *))");
- assertTrue("Should match", pexpr.matchesMethodExecution(e).alwaysMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(f).neverMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(h).alwaysMatches());
-
- pexpr = p.parsePointcutExpression("execution(public void *(@test.A1 (*)))");
- assertTrue("Should not match", pexpr.matchesMethodExecution(e).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(f).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(h).alwaysMatches());
-
- pexpr = p.parsePointcutExpression("execution(public void *(@(test.A1 || test.A2) (*)))");
- assertTrue("Should not match", pexpr.matchesMethodExecution(a).neverMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(c).alwaysMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches());
- assertTrue("Should match", pexpr.matchesMethodExecution(h).alwaysMatches());
-
- pexpr = p.parsePointcutExpression("execution(public void *(@(test.A1 && test.A2) (*),..))");
- assertTrue("Should not match", pexpr.matchesMethodExecution(a).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(c).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches());
- assertTrue("Should not match", pexpr.matchesMethodExecution(h).neverMatches());
-// assertTrue("Should match", pexpr.matchesMethodExecution(j).alwaysMatches()); // should match but does not, broken implementation, old bug - see WildAnnotationTypePattern.match
-
-
-
- }
-
- private void checkParameterAnnotations(PointcutExpression pe,int parameterNumber,String expectedParameterAnnotations,String expectedParameterTypeAnnotations,String expectedNodeStructure) {
- org.aspectj.weaver.patterns.Pointcut p = ((PointcutExpressionImpl)pe).getUnderlyingPointcut();
- KindedPointcut kindedP = (KindedPointcut)p;
- SignaturePattern sp = kindedP.getSignature();
- TypePatternList tpl = sp.getParameterTypes();
- TypePattern[] tps = tpl.getTypePatterns();
-
- // A visitor over the annotation pattern for the parameter will break it down into parameter vs parameter type annotations
- MyPatternNodeVisitor mpnv = new MyPatternNodeVisitor();
- tps[parameterNumber].getAnnotationPattern().accept(mpnv,null);
-
- if (expectedNodeStructure==null) {
- // The caller hasn't worked it out yet!!
- System.out.println(mpnv.getStringRepresentation());
- } else if (!mpnv.getStringRepresentation().equals(expectedNodeStructure)) {
- System.out.println(mpnv.getStringRepresentation());
- fail("Expected annotation pattern node structure for expression "+pe.getPointcutExpression()+
- " was '"+expectedNodeStructure+"' but it turned out to be '"+mpnv.getStringRepresentation()+"'");
- }
-
- tps[parameterNumber].getAnnotationPattern().toString();
-
- // parameter type annotation checking
- Set<String> expected = new HashSet<String>();
- expected.addAll(mpnv.getParameterTypeAnnotations());
-
- StringTokenizer st = new StringTokenizer(expectedParameterTypeAnnotations==null?"":expectedParameterTypeAnnotations);
- while (st.hasMoreTokens()) {
- String nextToken = st.nextToken();
- if (!expected.contains(nextToken))
- fail("In pointcut expression "+pe.getPointcutExpression()+" parameter "+parameterNumber+". The annotation type pattern did not include parameter type annotation "+nextToken+". It's full set was "+mpnv.getParameterTypeAnnotations());
- expected.remove(nextToken);
- }
- if (expected.size()>0) { // we have excess ones!
- StringBuffer excessTokens = new StringBuffer();
- for (Iterator iterator = expected.iterator(); iterator.hasNext();) {
- String string = (String) iterator.next();
- excessTokens.append(string).append(" ");
- }
- fail("In pointcut expression "+pe.getPointcutExpression()+" parameter "+parameterNumber+". The annotation type pattern has these unexpected parameter type annotations "+excessTokens.toString());
- }
-
- // parameter annotation checking
- expected = new HashSet<String>();
- expected.addAll(mpnv.getParameterAnnotations());
-
- st = new StringTokenizer(expectedParameterAnnotations==null?"":expectedParameterAnnotations);
- while (st.hasMoreTokens()) {
- String nextToken = st.nextToken();
- if (!expected.contains(nextToken))
- fail("In pointcut expression "+pe.getPointcutExpression()+" parameter "+parameterNumber+". The annotation type pattern did not include parameter annotation "+nextToken+". It's full set was "+mpnv.getParameterAnnotations());
- expected.remove(nextToken);
- }
- if (expected.size()>0) { // we have excess ones!
- StringBuffer excessTokens = new StringBuffer();
- for (Iterator iterator = expected.iterator(); iterator.hasNext();) {
- String string = (String) iterator.next();
- excessTokens.append(string).append(" ");
- }
- fail("In pointcut expression "+pe.getPointcutExpression()+" parameter "+parameterNumber+". The annotation type pattern has these unexpected parameter annotations "+excessTokens.toString());
- }
-
- }
-
- static class MyPatternNodeVisitor extends AbstractPatternNodeVisitor {
- private StringBuffer stringRep = new StringBuffer();
- private List<String> parameterAnnotations = new ArrayList<String>();
- private List<String> parameterTypeAnnotations = new ArrayList<String>();
-
- public String getStringRepresentation() { return stringRep.toString(); }
- public List<String> getParameterAnnotations() { return parameterAnnotations; }
- public List<String> getParameterTypeAnnotations() { return parameterTypeAnnotations; }
-
- public Object visit(AndAnnotationTypePattern node, Object data) {
- stringRep.append("(");
- node.getLeft().accept(this, data);
- stringRep.append(" and ");
- node.getRight().accept(this, data);
- stringRep.append(")");
- return node;
- }
- public Object visit(AnyAnnotationTypePattern node, Object data) {
- stringRep.append("any");
- return node;
- }
- public Object visit(ExactAnnotationTypePattern node, Object data) {
- stringRep.append("exact["+stringify(node.getResolvedAnnotationType())+":"+(node.isForParameterAnnotationMatch()?"p":"t")+"]");
- if (node.isForParameterAnnotationMatch()) {
- parameterAnnotations.add(stringify(node.getResolvedAnnotationType()));
- } else {
- parameterTypeAnnotations.add(stringify(node.getResolvedAnnotationType()));
- }
- return node;
- }
- private String stringify(ResolvedType resolvedAnnotationType) {
- return "@"+resolvedAnnotationType.getSimpleName();
- }
-
- public Object visit(BindingAnnotationTypePattern node, Object data) {
- stringRep.append("binding");
-
- return node;
- }
- public Object visit(NotAnnotationTypePattern node, Object data) {
- stringRep.append("not");
- return node;
- }
- public Object visit(OrAnnotationTypePattern node, Object data) {
- stringRep.append("(");
- node.getLeft().accept(this, data);
- stringRep.append(" or ");
- node.getRight().accept(this, data);
- stringRep.append(")");
- return node;
- }
- public Object visit(WildAnnotationTypePattern node, Object data) {
- stringRep.append("wild[");
- stringRep.append(node.getTypePattern().toString());
- stringRep.append("]");
- return node;
- }
- public Object visit(AnnotationPatternList node, Object data) {
- stringRep.append("list");
-
- return node;
- }
-
-
- }
-
-
-
- public void testAtThis() {
- PointcutExpression atThis = parser.parsePointcutExpression("@this(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
- ShadowMatch sMatch1 = atThis.matchesMethodExecution(a);
- ShadowMatch sMatch2 = atThis.matchesMethodExecution(b);
- assertTrue("maybe matches A",sMatch1.maybeMatches());
- assertTrue("maybe matches B",sMatch2.maybeMatches());
- JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]);
- assertFalse("does not match",jp1.matches());
- JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[0]);
- assertTrue("matches",jp2.matches());
- }
-
- public void testAtTarget() {
- PointcutExpression atTarget = parser.parsePointcutExpression("@target(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
- ShadowMatch sMatch1 = atTarget.matchesMethodExecution(a);
- ShadowMatch sMatch2 = atTarget.matchesMethodExecution(b);
- assertTrue("maybe matches A",sMatch1.maybeMatches());
- assertTrue("maybe matches B",sMatch2.maybeMatches());
- JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]);
- assertFalse("does not match",jp1.matches());
- JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[0]);
- assertTrue("matches",jp2.matches());
- }
-
- public void testAtThisWithBinding() {
- PointcutParameter param = parser.createPointcutParameter("a",MyAnnotation.class);
- B myB = new B();
- MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class);
- PointcutExpression atThis = parser.parsePointcutExpression("@this(a)",A.class,new PointcutParameter[] {param});
- ShadowMatch sMatch1 = atThis.matchesMethodExecution(a);
- ShadowMatch sMatch2 = atThis.matchesMethodExecution(b);
- assertTrue("maybe matches A",sMatch1.maybeMatches());
- assertTrue("maybe matches B",sMatch2.maybeMatches());
- JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]);
- assertFalse("does not match",jp1.matches());
- JoinPointMatch jp2 = sMatch2.matchesJoinPoint(myB, myB, new Object[0]);
- assertTrue("matches",jp2.matches());
- assertEquals(1,jp2.getParameterBindings().length);
- assertEquals("should be myB's annotation",bAnnotation,jp2.getParameterBindings()[0].getBinding());
- }
-
- public void testAtTargetWithBinding() {
- PointcutParameter param = parser.createPointcutParameter("a",MyAnnotation.class);
- B myB = new B();
- MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class);
- PointcutExpression atThis = parser.parsePointcutExpression("@target(a)",A.class,new PointcutParameter[] {param});
- ShadowMatch sMatch1 = atThis.matchesMethodExecution(a);
- ShadowMatch sMatch2 = atThis.matchesMethodExecution(b);
- assertTrue("maybe matches A",sMatch1.maybeMatches());
- assertTrue("maybe matches B",sMatch2.maybeMatches());
- JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]);
- assertFalse("does not match",jp1.matches());
- JoinPointMatch jp2 = sMatch2.matchesJoinPoint(myB, myB, new Object[0]);
- assertTrue("matches",jp2.matches());
- assertEquals(1,jp2.getParameterBindings().length);
- assertEquals("should be myB's annotation",bAnnotation,jp2.getParameterBindings()[0].getBinding());
- }
-
- public void testAtArgs() {
- PointcutExpression atArgs = parser.parsePointcutExpression("@args(..,org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
- ShadowMatch sMatch1 = atArgs.matchesMethodExecution(a);
- ShadowMatch sMatch2 = atArgs.matchesMethodExecution(c);
- assertTrue("never matches A",sMatch1.neverMatches());
- assertTrue("maybe matches C",sMatch2.maybeMatches());
- JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[]{new A(),new B()});
- assertTrue("matches",jp2.matches());
-
- atArgs = parser.parsePointcutExpression("@args(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation,org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
- sMatch1 = atArgs.matchesMethodExecution(a);
- sMatch2 = atArgs.matchesMethodExecution(c);
- assertTrue("never matches A",sMatch1.neverMatches());
- assertTrue("maybe matches C",sMatch2.maybeMatches());
- JoinPointMatch jp1 = sMatch2.matchesJoinPoint(new A(), new A(), new Object[] {new A(), new B()});
- assertFalse("does not match",jp1.matches());
- jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new B(),new B()});
- assertTrue("matches",jp2.matches());
- }
-
- public void testAtArgs2() {
- PointcutExpression atArgs = parser.parsePointcutExpression("@args(*, org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
- ShadowMatch sMatch1 = atArgs.matchesMethodExecution(c);
- ShadowMatch sMatch2 = atArgs.matchesMethodExecution(d);
- assertTrue("maybe matches c",sMatch1.maybeMatches());
- assertTrue("maybe matches d",sMatch2.maybeMatches());
- JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new B(), new B(), new Object[] {new A(), new B()});
- assertTrue("matches",jp1.matches());
- JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new A(),new A()});
- assertFalse("does not match",jp2.matches());
- }
-
- public void testAtArgsWithBinding() {
- PointcutParameter p1 = parser.createPointcutParameter("a",MyAnnotation.class);
- PointcutParameter p2 = parser.createPointcutParameter("b", MyAnnotation.class);
- PointcutExpression atArgs = parser.parsePointcutExpression("@args(..,a)",A.class,new PointcutParameter[] {p1});
- ShadowMatch sMatch2 = atArgs.matchesMethodExecution(c);
- assertTrue("maybe matches C",sMatch2.maybeMatches());
- JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[]{new A(),new B()});
- assertTrue("matches",jp2.matches());
- assertEquals(1,jp2.getParameterBindings().length);
- MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class);
- assertEquals("annotation on B",bAnnotation,jp2.getParameterBindings()[0].getBinding());
-
- atArgs = parser.parsePointcutExpression("@args(a,b)",A.class,new PointcutParameter[] {p1,p2});
- sMatch2 = atArgs.matchesMethodExecution(c);
- assertTrue("maybe matches C",sMatch2.maybeMatches());
- jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new B(),new B()});
- assertTrue("matches",jp2.matches());
- assertEquals(2,jp2.getParameterBindings().length);
- assertEquals("annotation on B",bAnnotation,jp2.getParameterBindings()[0].getBinding());
- assertEquals("annotation on B",bAnnotation,jp2.getParameterBindings()[1].getBinding());
- }
-
- public void testAtWithin() {
- PointcutExpression atWithin = parser.parsePointcutExpression("@within(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
- ShadowMatch sMatch1 = atWithin.matchesMethodExecution(a);
- ShadowMatch sMatch2 = atWithin.matchesMethodExecution(b);
- assertTrue("does not match a",sMatch1.neverMatches());
- assertTrue("matches b",sMatch2.alwaysMatches());
- }
-
- public void testAtWithinWithBinding() {
- PointcutParameter p1 = parser.createPointcutParameter("x",MyAnnotation.class);
- PointcutExpression atWithin = parser.parsePointcutExpression("@within(x)",B.class,new PointcutParameter[] {p1});
- ShadowMatch sMatch1 = atWithin.matchesMethodExecution(a);
- ShadowMatch sMatch2 = atWithin.matchesMethodExecution(b);
- assertTrue("does not match a",sMatch1.neverMatches());
- assertTrue("matches b",sMatch2.alwaysMatches());
- JoinPointMatch jpm = sMatch2.matchesJoinPoint(new B(), new B(), new Object[0]);
- assertTrue(jpm.matches());
- assertEquals(1,jpm.getParameterBindings().length);
- MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class);
- assertEquals("annotation on B",bAnnotation,jpm.getParameterBindings()[0].getBinding());
- }
-
- public void testAtWithinCode() {
- PointcutExpression atWithinCode = parser.parsePointcutExpression("@withincode(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
- ShadowMatch sMatch1 = atWithinCode.matchesMethodCall(a,b);
- ShadowMatch sMatch2 = atWithinCode.matchesMethodCall(a,a);
- assertTrue("does not match from b",sMatch1.neverMatches());
- assertTrue("matches from a",sMatch2.alwaysMatches());
- }
-
- public void testAtWithinCodeWithBinding() {
- PointcutParameter p1 = parser.createPointcutParameter("x",MyAnnotation.class);
- PointcutExpression atWithinCode = parser.parsePointcutExpression("@withincode(x)",A.class,new PointcutParameter[] {p1});
- ShadowMatch sMatch2 = atWithinCode.matchesMethodCall(a,a);
- assertTrue("matches from a",sMatch2.alwaysMatches());
- JoinPointMatch jpm = sMatch2.matchesJoinPoint(new A(), new A(), new Object[0]);
- assertEquals(1,jpm.getParameterBindings().length);
- MyAnnotation annOna = a.getAnnotation(MyAnnotation.class);
- assertEquals("MyAnnotation on a",annOna,jpm.getParameterBindings()[0].getBinding());
- }
-
- public void testAtAnnotation() {
- PointcutExpression atAnnotation = parser.parsePointcutExpression("@annotation(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)");
- ShadowMatch sMatch1 = atAnnotation.matchesMethodCall(b,a);
- ShadowMatch sMatch2 = atAnnotation.matchesMethodCall(a,a);
- assertTrue("does not match call to b",sMatch1.neverMatches());
- assertTrue("matches call to a",sMatch2.alwaysMatches());
- }
-
- public void testAtAnnotationWithBinding() {
- PointcutParameter p1 = parser.createPointcutParameter("x",MyAnnotation.class);
- PointcutExpression atAnnotation = parser.parsePointcutExpression("@annotation(x)",A.class,new PointcutParameter[] {p1});
- ShadowMatch sMatch2 = atAnnotation.matchesMethodCall(a,a);
- assertTrue("matches call to a",sMatch2.alwaysMatches());
- JoinPointMatch jpm = sMatch2.matchesJoinPoint(new A(), new A(), new Object[0]);
- assertTrue(jpm.matches());
- assertEquals(1,jpm.getParameterBindings().length);
- MyAnnotation annOna = a.getAnnotation(MyAnnotation.class);
- assertEquals("MyAnnotation on a",annOna,jpm.getParameterBindings()[0].getBinding());
- }
-
- public void testReferencePointcutNoParams() {
- PointcutExpression pc = parser.parsePointcutExpression("foo()",C.class,new PointcutParameter[0]);
- ShadowMatch sMatch1 = pc.matchesMethodCall(a,b);
- ShadowMatch sMatch2 = pc.matchesMethodExecution(a);
- assertTrue("no match on call",sMatch1.neverMatches());
- assertTrue("match on execution",sMatch2.alwaysMatches());
-
- pc = parser.parsePointcutExpression("org.aspectj.weaver.tools.Java15PointcutExpressionTest.C.foo()");
- sMatch1 = pc.matchesMethodCall(a,b);
- sMatch2 = pc.matchesMethodExecution(a);
- assertTrue("no match on call",sMatch1.neverMatches());
- assertTrue("match on execution",sMatch2.alwaysMatches());
- }
-
- public void testReferencePointcutParams() {
- PointcutParameter p1 = parser.createPointcutParameter("x",A.class);
- PointcutExpression pc = parser.parsePointcutExpression("goo(x)",C.class,new PointcutParameter[] {p1});
-
- ShadowMatch sMatch1 = pc.matchesMethodCall(a,b);
- ShadowMatch sMatch2 = pc.matchesMethodExecution(a);
- assertTrue("no match on call",sMatch1.neverMatches());
- assertTrue("match on execution",sMatch2.maybeMatches());
- A anA = new A();
- JoinPointMatch jpm = sMatch2.matchesJoinPoint(anA, new A(), new Object[0]);
- assertTrue(jpm.matches());
- assertEquals("should be bound to anA",anA,jpm.getParameterBindings()[0].getBinding());
-
- }
-
- public void testExecutionWithClassFileRetentionAnnotation() {
- PointcutExpression pc1 = parser.parsePointcutExpression("execution(@org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation * *(..))");
- PointcutExpression pc2 = parser.parsePointcutExpression("execution(@org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyClassFileRetentionAnnotation * *(..))");
- ShadowMatch sMatch = pc1.matchesMethodExecution(a);
- assertTrue("matches",sMatch.alwaysMatches());
- sMatch = pc2.matchesMethodExecution(a);
- assertTrue("no match",sMatch.neverMatches());
- sMatch = pc1.matchesMethodExecution(b);
- assertTrue("no match",sMatch.neverMatches());
- sMatch = pc2.matchesMethodExecution(b);
- assertTrue("matches",sMatch.alwaysMatches());
- }
-
- public void testGenericMethodSignatures() throws Exception{
- PointcutExpression ex = parser.parsePointcutExpression("execution(* set*(java.util.List<org.aspectj.weaver.tools.Java15PointcutExpressionTest.C>))");
- Method m = TestBean.class.getMethod("setFriends",List.class);
- ShadowMatch sm = ex.matchesMethodExecution(m);
- assertTrue("should match",sm.alwaysMatches());
- }
-
- public void testAnnotationInExecution() throws Exception {
- parser.parsePointcutExpression("execution(@(org.springframework..*) * *(..))");
- }
-
- public void testVarArgsMatching() throws Exception {
- PointcutExpression ex = parser.parsePointcutExpression("execution(* *(String...))");
- Method usesVarArgs = D.class.getMethod("varArgs",String[].class);
- Method noVarArgs = D.class.getMethod("nonVarArgs", String[].class);
- ShadowMatch sm1 = ex.matchesMethodExecution(usesVarArgs);
- assertTrue("should match",sm1.alwaysMatches());
- ShadowMatch sm2 = ex.matchesMethodExecution(noVarArgs);
- assertFalse("should not match",sm2.alwaysMatches());
- }
-
- public void testJavaLangMatching() throws Exception {
- PointcutExpression ex = parser.parsePointcutExpression("@within(java.lang.Deprecated)");
- Method foo = GoldenOldie.class.getMethod("foo");
- ShadowMatch sm1 = ex.matchesMethodExecution(foo);
- assertTrue("should match",sm1.alwaysMatches());
- }
-
- public void testReferencePCsInSameType() throws Exception {
- PointcutExpression ex = parser.parsePointcutExpression("org.aspectj.weaver.tools.Java15PointcutExpressionTest.NamedPointcutResolution.c()",NamedPointcutResolution.class,new PointcutParameter[0]);
- ShadowMatch sm = ex.matchesMethodExecution(a);
- assertTrue("should match",sm.alwaysMatches());
- sm = ex.matchesMethodExecution(b);
- assertTrue("does not match",sm.neverMatches());
- }
-
- public void testReferencePCsInOtherType() throws Exception {
- PointcutExpression ex = parser.parsePointcutExpression("org.aspectj.weaver.tools.Java15PointcutExpressionTest.ExternalReferrer.d()",ExternalReferrer.class,new PointcutParameter[0]);
- ShadowMatch sm = ex.matchesMethodExecution(a);
- assertTrue("should match",sm.alwaysMatches());
- sm = ex.matchesMethodExecution(b);
- assertTrue("does not match",sm.neverMatches());
- }
-
- public void testArrayTypeInArgs() throws Exception {
- PointcutParameter[] params = new PointcutParameter[3];
- params[0] = parser.createPointcutParameter("d", Date.class);
- params[1] = parser.createPointcutParameter("s", String.class);
- params[2] = parser.createPointcutParameter("ss", String[].class);
- parser.parsePointcutExpression("org.aspectj.weaver.tools.Java15PointcutExpressionTest.UsesArrays.pc(d,s,ss)",UsesArrays.class,params);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
- a = A.class.getMethod("a");
- b = B.class.getMethod("b");
- c = B.class.getMethod("c",new Class[] {A.class,B.class});
- d = B.class.getMethod("d",new Class[] {A.class,A.class});
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- private @interface MyAnnotation {}
-
- private @interface MyClassFileRetentionAnnotation {}
-
- private static class A {
- @MyAnnotation public void a() {}
- }
-
- @MyAnnotation
- private static class B {
- @MyClassFileRetentionAnnotation public void b() {}
- public void c(A anA, B aB) {}
-
- public void d(A anA, A anotherA) {}
- }
-
- private static class C {
-
- @Pointcut("execution(* *(..))")
- public void foo() {}
-
- @Pointcut(value="execution(* *(..)) && this(x)", argNames="x")
- public void goo(A x) {}
- }
-
- private static class D {
-
- public void nonVarArgs(String[] strings) {};
-
- public void varArgs(String... strings) {};
-
- }
-
- static class TestBean {
- public void setFriends(List<C> friends) {}
- }
-
- @Deprecated
- static class GoldenOldie {
- public void foo() {}
- }
-
- private static class NamedPointcutResolution {
-
- @Pointcut("execution(* *(..))")
- public void a() {}
-
- @Pointcut("this(org.aspectj.weaver.tools.Java15PointcutExpressionTest.A)")
- public void b() {}
-
- @Pointcut("a() && b()")
- public void c() {}
- }
-
- private static class ExternalReferrer {
-
- @Pointcut("org.aspectj.weaver.tools.Java15PointcutExpressionTest.NamedPointcutResolution.a() && " +
- "org.aspectj.weaver.tools.Java15PointcutExpressionTest.NamedPointcutResolution.b())")
- public void d() {}
-
- }
-
- private static class UsesArrays {
-
- @Pointcut("execution(* *(..)) && args(d,s,ss)")
- public void pc(Date d, String s, String[] ss) {}
-
- }
-}
-
-