You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReferenceTypeTestCase.java 43KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. /* *******************************************************************
  2. * Copyright (c) 2005 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Adrian Colyer Initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver;
  13. import java.rmi.RemoteException;
  14. import java.util.ArrayList;
  15. import java.util.List;
  16. import java.util.Random;
  17. import org.aspectj.util.PartialOrder;
  18. import org.aspectj.weaver.bcel.BcelWorld;
  19. import junit.framework.TestCase;
  20. // test cases for Adrian's additions to ReferenceType
  21. // XXX - couldn't find any unit test cases for the rest of the ReferenceType class
  22. public class ReferenceTypeTestCase extends TestCase {
  23. public void testIsRawTrue() {
  24. BcelWorld world = new BcelWorld();
  25. world.setBehaveInJava5Way(true);
  26. UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class");
  27. ResolvedType rtx = world.resolve(javaLangClass);
  28. assertTrue("Resolves to reference type", (rtx instanceof ReferenceType));
  29. ReferenceType rt = (ReferenceType) rtx;
  30. assertTrue("java.lang.Class is raw", rt.isRawType());
  31. }
  32. public void testIsRawFalse() {
  33. BcelWorld world = new BcelWorld();
  34. world.setBehaveInJava5Way(true);
  35. UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object");
  36. ResolvedType rtx = world.resolve(javaLangObject);
  37. assertTrue("Resolves to reference type", (rtx instanceof ReferenceType));
  38. ReferenceType rt = (ReferenceType) rtx;
  39. assertFalse("java.lang.Object is not raw", rt.isRawType());
  40. }
  41. public void testIsGenericTrue() {
  42. BcelWorld world = new BcelWorld();
  43. world.setBehaveInJava5Way(true);
  44. UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class");
  45. ResolvedType rtx = world.resolve(javaLangClass);
  46. assertTrue("java.lang.Class has underpinning generic type", rtx.getGenericType().isGenericType());
  47. }
  48. public void testIsGenericFalse() {
  49. BcelWorld world = new BcelWorld();
  50. world.setBehaveInJava5Way(true);
  51. UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object");
  52. ResolvedType rtx = world.resolve(javaLangObject);
  53. assertFalse(rtx.isGenericType());
  54. }
  55. BcelWorld world;
  56. @Override
  57. public void setUp() throws Exception {
  58. super.setUp();
  59. world = new BcelWorld();
  60. world.setBehaveInJava5Way(true);
  61. }
  62. public void testCoercion01() {
  63. ReferenceType listOfString = (ReferenceType) world.resolve(UnresolvedType
  64. .forSignature("Pjava/util/List<Ljava/lang/String;>;"));
  65. ReferenceType listOfInteger = (ReferenceType) world.resolve(UnresolvedType
  66. .forSignature("Pjava/util/List<Ljava/lang/Integer;>;"));
  67. assertFalse(listOfInteger.isAssignableFrom(listOfString));
  68. assertFalse(listOfString.isAssignableFrom(listOfInteger));
  69. assertFalse(listOfInteger.isCoerceableFrom(listOfString));
  70. assertFalse(listOfString.isCoerceableFrom(listOfInteger));
  71. }
  72. public void testAssignable01() {
  73. List list = new ArrayList();
  74. List<String> listOfString = new ArrayList<String>();
  75. List<?> listOfSomething = new ArrayList<Integer>();
  76. List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
  77. List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
  78. // interfaces too List<? extends A,B>
  79. ReferenceType ajList = resolve("Ljava/util/List;");
  80. ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
  81. ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
  82. ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
  83. ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
  84. // try and write the java equivalent, if it succeeds then check isAssignableFrom() is true
  85. // if the java is only correct with a cast, check isCoerceableFrom()
  86. list = listOfString;
  87. assertTrue(ajList.isAssignableFrom(ajListOfString));
  88. list = listOfSomething;
  89. assertTrue(ajList.isAssignableFrom(ajListOfSomething));
  90. list = listOfSomethingNumberish;
  91. assertTrue(ajList.isAssignableFrom(ajListOfSomething));
  92. list = listOfSomethingSuperDouble;
  93. assertTrue(ajList.isAssignableFrom(ajListOfSomethingSuperDouble));
  94. listOfString = list; // unchecked conversion to List<String>
  95. assertFalse(ajListOfString.isAssignableFrom(ajList));
  96. assertTrue(ajListOfString.isCoerceableFrom(ajListOfSomething));
  97. // error: listOfString = listOfSomething;
  98. assertFalse(ajListOfString.isAssignableFrom(ajListOfSomething));
  99. // error: listOfString = listOfSomethingNumberish;
  100. assertFalse(ajListOfString.isAssignableFrom(ajListOfSomethingNumberish));
  101. // error: listOfString = listOfSomethingSuperDouble;
  102. assertFalse(ajListOfString.isAssignableFrom(ajListOfSomethingSuperDouble));
  103. // error: listOfString = (List<String>) listOfSomethingSuperDouble;
  104. assertFalse(ajListOfString.isCoerceableFrom(ajListOfSomethingSuperDouble));
  105. listOfSomething = list;
  106. assertTrue(ajListOfSomething.isAssignableFrom(ajList));
  107. listOfSomething = listOfString;
  108. assertTrue(ajListOfSomething.isAssignableFrom(ajListOfString));
  109. listOfSomething = listOfSomethingNumberish;
  110. assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomething));
  111. listOfSomething = listOfSomethingSuperDouble;
  112. assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomethingSuperDouble));
  113. listOfSomethingNumberish = list; // unchecked conversion
  114. assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajList));
  115. assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajList));
  116. // error: listOfSomethingNumberish = listOfString;
  117. assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfString));
  118. assertFalse(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfString));
  119. // error: listOfSomethingNumberish = listOfSomething;
  120. assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomething));
  121. listOfSomethingNumberish = (List<? extends Number>) listOfSomething;
  122. assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething));
  123. // error: listOfSomethingNumberish = listOfSomethingSuperDouble;
  124. assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingSuperDouble));
  125. // listOfSomethingNumberish = (List<? extends Number>) listOfSomethingSuperDouble;
  126. // assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomethingSuperDouble));
  127. }
  128. class C<E extends Number> {
  129. void m1(List<Integer> e) {
  130. }
  131. void m2(List<? extends Number> e) {
  132. }
  133. void m3(List<Number> e) {
  134. }
  135. void m4(List<?> e) {
  136. }
  137. void m5(List<E> e) {
  138. }
  139. void m6(List<? extends E> e) {
  140. }
  141. void m7(List<? extends List<? extends E>> e) {
  142. }
  143. void m8(List e) {
  144. }
  145. void m9(E e) {
  146. }
  147. }
  148. class A1 {
  149. }
  150. class B1 extends A1 {
  151. }
  152. class C1 extends B1 {
  153. }
  154. class D1 extends C1 {
  155. }
  156. class D2<E2 extends C1> {
  157. void m5(List<E2> e) {
  158. }
  159. }
  160. public void testAssignable02() {
  161. List list = new ArrayList();
  162. ArrayList arraylist = null;
  163. List<String> listOfString = new ArrayList<String>();
  164. List<?> listOfSomething = new ArrayList<Integer>();
  165. ArrayList<?> arrayListOfSomething = null;
  166. List<Number> listOfNumber = null;
  167. ArrayList<Number> arrayListOfNumber = null;
  168. ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
  169. List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
  170. List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
  171. List<Integer> listOfInteger = new ArrayList<Integer>();
  172. ArrayList<String> arrayListOfString;
  173. ArrayList<Integer> arraylistOfInteger;
  174. // interfaces too List<? extends A,B>
  175. ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
  176. ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
  177. ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
  178. ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
  179. ReferenceType ajList = resolve("Ljava/util/List;");
  180. ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
  181. ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
  182. ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
  183. ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
  184. ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
  185. ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
  186. ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
  187. ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
  188. // Effectively, whether the advice matches is based on whether what we pass at the joinpoint could
  189. // be bound to the specification in the args() pointcut
  190. // void around(): execution(* C.m1(..)) && args(List<Integer>){} //: Should match (it does)
  191. assertTrue(ajListOfInteger.isAssignableFrom(ajListOfInteger));
  192. // void around(): execution(* C.m1(..)) && args(ArrayList<Integer>){}//: Should runtime check (it does!)
  193. ArrayList<Integer> x = (ArrayList<Integer>) listOfInteger;
  194. assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfInteger));
  195. assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfInteger));
  196. // void around(): execution(* C.m1(..)) && args(List<Number>){} // Should not match (it does not!)
  197. // error: listOfNumber = listOfInteger;
  198. assertFalse(ajListOfNumber.isAssignableFrom(ajListOfInteger));
  199. assertFalse(ajListOfNumber.isCoerceableFrom(ajListOfInteger));
  200. // void around(): execution(* C.m1(..)) && args(ArrayList<Number>){} // Should not match (it does not)
  201. // error: arrayListOfNumber = listOfInteger;
  202. assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfInteger));
  203. assertFalse(ajArrayListOfNumber.isCoerceableFrom(ajListOfInteger));
  204. // void around(): execution(* C.m1(..)) && args(List<? extends Number>){} // Should match (it does)
  205. listOfSomethingNumberish = listOfInteger;
  206. assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfInteger));
  207. // void around(): execution(* C.m1(..)) && args(ArrayList<? extends Number>){}// Should runtime check (it does!)
  208. arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfInteger;
  209. assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfInteger));
  210. assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfInteger));
  211. // void around(): execution(* C.m1(..)) && args(List){}// Should match (it does)
  212. list = listOfInteger;
  213. assertTrue(ajList.isAssignableFrom(ajListOfInteger));
  214. // void around(): execution(* C.m1(..)) && args(ArrayList){}//: Should runtime check (it does not match!)
  215. arraylist = (ArrayList) listOfInteger;
  216. assertFalse(ajArrayList.isAssignableFrom(ajListOfInteger));
  217. assertTrue(ajArrayList.isCoerceableFrom(ajListOfInteger));
  218. // void around(): execution(* C.m1(..)) && args(List<?>){}// Should match (it does)
  219. listOfSomething = listOfInteger;
  220. assertTrue(ajListOfSomething.isAssignableFrom(ajListOfInteger));
  221. // void around(): execution(* C.m1(..)) && args(ArrayList<?>){}// Should runtime check (it does not match!)
  222. arrayListOfSomething = (ArrayList<?>) listOfInteger;
  223. assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfInteger));
  224. assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfInteger));
  225. // void around(): execution(* C.m1(..)) && args(ArrayList<String>){}// Should not match (it does not match!)
  226. // error: arrayListOfString = listOfInteger;
  227. assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfInteger));
  228. assertFalse(ajArrayListOfString.isCoerceableFrom(ajListOfInteger));
  229. }
  230. public void testAssignable03_method_m2() {
  231. List list = new ArrayList();
  232. ArrayList arraylist = null;
  233. List<String> listOfString = new ArrayList<String>();
  234. List<?> listOfSomething = new ArrayList<Integer>();
  235. ArrayList<?> arrayListOfSomething = null;
  236. List<Number> listOfNumber = null;
  237. ArrayList<Number> arrayListOfNumber = null;
  238. ArrayList<Integer> arrayListOfInteger = null;
  239. ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
  240. List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
  241. List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
  242. List<Integer> listOfInteger = new ArrayList<Integer>();
  243. ArrayList<String> arrayListOfString;
  244. ArrayList<Integer> arraylistOfInteger;
  245. // interfaces too List<? extends A,B>
  246. ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
  247. ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
  248. ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
  249. ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
  250. ReferenceType ajList = resolve("Ljava/util/List;");
  251. ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
  252. ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
  253. ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
  254. ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
  255. ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
  256. ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
  257. ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
  258. ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
  259. // void m2(List<? extends Number> e) {}
  260. // comment 11
  261. // void around(): execution(* C.m2(..)) && args(List<Integer>){} //: Should not match (but it does) ERROR
  262. listOfInteger = (List<Integer>) listOfSomethingNumberish;
  263. assertFalse(ajListOfInteger.isAssignableFrom(ajListOfSomethingNumberish));
  264. assertTrue(ajListOfInteger.isCoerceableFrom(ajListOfSomethingNumberish));
  265. // void around(): execution(* C.m2(..)) && args(ArrayList<Integer>){}//: Should not match (but it does!) ERROR
  266. arrayListOfInteger = (ArrayList<Integer>) listOfSomethingNumberish;
  267. assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfSomethingNumberish));
  268. assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfSomethingNumberish));
  269. // void around(): execution(* C.m2(..)) && args(List<Number>){} //: Should not match (but it does) ERROR
  270. listOfNumber = (List<Number>) listOfSomethingNumberish;
  271. assertFalse(ajListOfNumber.isAssignableFrom(ajListOfSomethingNumberish));
  272. assertTrue(ajListOfNumber.isCoerceableFrom(ajListOfSomethingNumberish));
  273. // void around(): execution(* C.m2(..)) && args(ArrayList<Number>){}//: Should not runtime check (but it does!) ERROR
  274. arrayListOfNumber = (ArrayList<Number>) listOfSomethingNumberish;
  275. assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfSomethingNumberish));
  276. assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfSomethingNumberish));
  277. // void around(): execution(* C.m2(..)) && args(List<? extends Number>){}//: Should match (it does)
  278. listOfSomethingNumberish = listOfSomethingNumberish;
  279. assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingNumberish));
  280. // void around(): execution(* C.m2(..)) && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
  281. arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfSomethingNumberish;
  282. assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingNumberish));
  283. assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfSomethingNumberish));
  284. // void around(): execution(* C.m2(..)) && args(List){}//: Should match (it does)
  285. list = listOfSomethingNumberish;
  286. assertTrue(ajList.isAssignableFrom(ajListOfSomethingNumberish));
  287. // void around(): execution(* C.m2(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR
  288. arraylist = (ArrayList) listOfSomethingNumberish;
  289. assertFalse(ajArrayList.isAssignableFrom(ajListOfSomethingNumberish));
  290. assertTrue(ajArrayList.isCoerceableFrom(ajListOfSomethingNumberish));
  291. // void around(): execution(* C.m2(..)) && args(List<?>){}//: Should match (it does)
  292. listOfSomething = listOfSomethingNumberish;
  293. assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomethingNumberish));
  294. // void around(): execution(* C.m2(..)) && args(ArrayList<?>){}//: Should runtime check (it does!)
  295. arrayListOfSomething = (ArrayList) listOfSomethingNumberish;
  296. assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfSomethingNumberish));
  297. assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfSomethingNumberish));
  298. // void around(): execution(* C.m2(..)) && args(ArrayList<String>){}//: Should not match (it does not match!)
  299. // error: arrayListOfString = listOfSomethingNumberish;
  300. assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfSomethingNumberish));
  301. assertFalse(ajArrayListOfString.isCoerceableFrom(ajListOfSomethingNumberish));
  302. }
  303. public void testAssignable04_method_m3() {
  304. List list = new ArrayList();
  305. ArrayList arraylist = null;
  306. List<String> listOfString = new ArrayList<String>();
  307. List<?> listOfSomething = new ArrayList<Integer>();
  308. ArrayList<?> arrayListOfSomething = null;
  309. List<Number> listOfNumber = null;
  310. ArrayList<Number> arrayListOfNumber = null;
  311. ArrayList<Integer> arrayListOfInteger = null;
  312. ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
  313. List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
  314. List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
  315. List<Integer> listOfInteger = new ArrayList<Integer>();
  316. ArrayList arrayList = null;
  317. ArrayList<String> arrayListOfString;
  318. ArrayList<Integer> arraylistOfInteger;
  319. // interfaces too List<? extends A,B>
  320. ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
  321. ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
  322. ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
  323. ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
  324. ReferenceType ajList = resolve("Ljava/util/List;");
  325. ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
  326. ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
  327. ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
  328. ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
  329. ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
  330. ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
  331. ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
  332. ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
  333. // void m3(List<Number> e) { }
  334. // void around(): execution(* C.m3(..)) && args(List<Integer>){} //: Should not match (it does not)
  335. // error: listOfInteger = listOfNumber;
  336. assertFalse(ajListOfInteger.isAssignableFrom(ajListOfNumber));
  337. assertFalse(ajListOfInteger.isCoerceableFrom(ajListOfNumber));
  338. // void around(): execution(* C.m3(..)) && args(ArrayList<Integer>){}//: Should not match (it does not)
  339. // error: arrayListOfInteger = listOfNumber;
  340. assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfNumber));
  341. assertFalse(ajArrayListOfInteger.isCoerceableFrom(ajListOfNumber));
  342. // void around(): execution(* C.m3(..)) && args(List<Number>){}//: Should match (it does)
  343. listOfNumber = listOfNumber;
  344. assertTrue(ajListOfNumber.isAssignableFrom(ajListOfNumber));
  345. // void around(): execution(* C.m3(..)) && args(ArrayList<Number>){}//: Should runtime match (it does)
  346. arrayListOfNumber = (ArrayList<Number>) listOfNumber;
  347. assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfNumber));
  348. assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfNumber));
  349. // void around(): execution(* C.m3(..)) && args(List<? extends Number>){}//: Should match (it does)
  350. listOfSomethingNumberish = listOfNumber;
  351. assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfNumber));
  352. // void around(): execution(* C.m3(..)) && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
  353. arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfNumber;
  354. assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfNumber));
  355. assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfNumber));
  356. // void around(): execution(* C.m3(..)) && args(List){}//: Should match (it does)
  357. list = listOfNumber;
  358. assertTrue(ajList.isAssignableFrom(ajListOfNumber));
  359. // void around(): execution(* C.m3(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR
  360. arrayList = (ArrayList) listOfNumber;
  361. assertFalse(ajArrayList.isAssignableFrom(ajListOfNumber));
  362. assertTrue(ajArrayList.isCoerceableFrom(ajListOfNumber));
  363. // void around(): execution(* C.m3(..)) && args(List<?>){}//: Should match (it does)
  364. listOfSomething = listOfNumber;
  365. assertTrue(ajListOfSomething.isAssignableFrom(ajListOfNumber));
  366. // void around(): execution(* C.m3(..)) && args(ArrayList<?>){}//: Should runtime check (it does!)
  367. arrayListOfSomething = (ArrayList<?>) listOfNumber;
  368. assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfNumber));
  369. assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfNumber));
  370. // void around(): execution(* C.m3(..)) && args(ArrayList<String>){}//: Should not match (it does not match!)
  371. // error: arrayListOfString = listOfNumber;
  372. assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfNumber));
  373. assertFalse(ajArrayListOfString.isCoerceableFrom(ajListOfNumber));
  374. }
  375. static class ClassA<T> {
  376. }
  377. static interface IMarker<H> {
  378. }
  379. static class ClassB<T> implements IMarker<ClassA<T>> {
  380. }
  381. static class ClassC<T> implements IMarker<T> {
  382. }
  383. public void testAssignability_pr267559() {
  384. ClassB cb = new ClassB();
  385. ClassB cb2 = new ClassB();
  386. ReferenceType rcb = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$ClassB;");
  387. ReferenceType rcb2 = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$ClassB;");
  388. boolean b = rcb.isAssignableFrom(rcb2);
  389. assertTrue(b);
  390. b = rcb2.isAssignableFrom(rcb);
  391. assertTrue(b);
  392. rcb = resolve("Porg/aspectj/weaver/ReferenceTypeTestCase$IMarker<Porg/aspectj/weaver/ReferenceTypeTestCase$ClassA<TT;>;>;");
  393. rcb2 = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$ClassB;");
  394. b = rcb.isAssignableFrom(rcb2);
  395. assertTrue(b);
  396. }
  397. public void testAssignable03_method_m4() {
  398. List list = new ArrayList();
  399. ArrayList arraylist = null;
  400. List<String> listOfString = new ArrayList<String>();
  401. List<?> listOfSomething = new ArrayList<Integer>();
  402. ArrayList<?> arrayListOfSomething = null;
  403. List<Number> listOfNumber = null;
  404. ArrayList<Number> arrayListOfNumber = null;
  405. ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
  406. List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
  407. List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
  408. List<Integer> listOfInteger = new ArrayList<Integer>();
  409. ArrayList<String> arrayListOfString;
  410. ArrayList<Integer> arraylistOfInteger;
  411. // interfaces too List<? extends A,B>
  412. ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
  413. ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
  414. ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
  415. ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
  416. ReferenceType ajList = resolve("Ljava/util/List;");
  417. ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
  418. ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
  419. ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
  420. ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
  421. ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
  422. ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
  423. ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
  424. ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
  425. // void m4(List<?> e) {}
  426. // void around(): execution(* C.m4(..)) && args(List<Integer>){} //: Should match with unchecked warning
  427. listOfInteger = (List<Integer>) listOfSomething;
  428. assertFalse(ajListOfInteger.isAssignableFrom(ajListOfSomething));
  429. assertTrue(ajListOfInteger.isCoerceableFrom(ajListOfSomething));
  430. // void around(): execution(* C.m4(..)) && args(ArrayList<Integer>){} // Should match with unchecked warning
  431. arraylistOfInteger = (ArrayList<Integer>) listOfSomething;
  432. assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfSomething));
  433. assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfSomething));
  434. // void around(): execution(* C.m4(..)) && args(List<Number>){} // Should match with unchecked warning
  435. listOfNumber = (List<Number>) listOfSomething;
  436. assertFalse(ajListOfNumber.isAssignableFrom(ajListOfSomething));
  437. assertTrue(ajListOfNumber.isCoerceableFrom(ajListOfSomething));
  438. // void around(): execution(* C.m4(..)) && args(ArrayList<Number>){} // Should match with unchecked warning
  439. arrayListOfNumber = (ArrayList<Number>) listOfSomething;
  440. assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfSomething));
  441. assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfSomething));
  442. // void around(): execution(* C.m4(..)) && args(List<? extends Number>){} // Should match with unchecked warning
  443. listOfSomethingNumberish = (List<? extends Number>) listOfSomething;
  444. assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomething));
  445. assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething));
  446. // void around(): execution(* C.m4(..)) && args(ArrayList<? extends Number>){} // Should match with unchecked warning
  447. arrayListOfSomethingNumberish = (ArrayList<? extends Number>) listOfSomething;
  448. assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfSomething));
  449. assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething));
  450. // void around(): execution(* C.m4(..)) && args(List){} // Should match
  451. list = listOfSomething;
  452. assertTrue(ajList.isAssignableFrom(ajListOfSomething));
  453. // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should runtime check
  454. arraylist = (ArrayList) listOfSomething;
  455. assertFalse(ajArrayList.isAssignableFrom(ajListOfSomething));
  456. assertTrue(ajArrayList.isCoerceableFrom(ajListOfSomething));
  457. // void around(): execution(* C.m4(..)) && args(List<?>){}//: Should match
  458. list = listOfSomething;
  459. assertTrue(ajList.isAssignableFrom(ajListOfSomething));
  460. // void around(): execution(* C.m4(..)) && args(ArrayList<?>){} // Should runtime check
  461. arrayListOfSomething = (ArrayList<?>) listOfSomething;
  462. assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfSomething));
  463. assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfSomething));
  464. // void around(): execution(* C.m4(..)) && args(ArrayList<String>){} // Should match with unchecked warning
  465. arrayListOfString = (ArrayList<String>) listOfSomething;
  466. assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfSomething));
  467. assertTrue(ajArrayListOfString.isCoerceableFrom(ajListOfSomething));
  468. }
  469. // copy of the real one in BcelClassWeaver
  470. public static class IfaceInitList implements PartialOrder.PartialComparable {
  471. final ResolvedType onType;
  472. List<ConcreteTypeMunger> list = new ArrayList<ConcreteTypeMunger>();
  473. IfaceInitList(ResolvedType onType) {
  474. this.onType = onType;
  475. }
  476. public int compareTo(Object other) {
  477. IfaceInitList o = (IfaceInitList) other;
  478. if (onType.isAssignableFrom(o.onType)) {
  479. return +1;
  480. } else if (o.onType.isAssignableFrom(onType)) {
  481. return -1;
  482. } else {
  483. return 0;
  484. }
  485. }
  486. public int fallbackCompareTo(Object other) {
  487. return 0;
  488. }
  489. }
  490. public void testExpensiveAssignableChecks_309336() {
  491. List objects = new ArrayList();
  492. ReferenceType rcb = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$Foo;");
  493. ReferenceType i = (ReferenceType) rcb.getDeclaredInterfaces()[0];
  494. while (i != null && i.isInterface()) {
  495. objects.add(Math.abs(new Random(12).nextInt(objects.size() + 1)), new IfaceInitList(i));
  496. ResolvedType[] rt = i.getDeclaredInterfaces();
  497. i = rt == null || rt.length == 0 ? null : (ReferenceType) rt[0];
  498. }
  499. for (int loop = 0; loop < 10; loop++) {
  500. // ReferenceType.r = 0;
  501. long stime = System.nanoTime();
  502. for (int j = 0; j < 10; j++) {
  503. List objects2 = new ArrayList();
  504. objects2.addAll(objects);
  505. PartialOrder.sort(objects2);
  506. }
  507. long etime = System.nanoTime();
  508. System.err.println("Took " + ((etime - stime) / 1000000) + "ms: calls ");// + ReferenceType.r);
  509. }
  510. // could do with asserting something... basically we are just checking we didn't run out of memory doing the sorts above!
  511. }
  512. 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> {
  513. T execute(String aArg) throws E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, RemoteException;
  514. }
  515. 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>
  516. extends Operator14<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E13> {
  517. }
  518. 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>
  519. extends Operator13<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E12> {
  520. }
  521. 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>
  522. extends Operator12<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E11> {
  523. }
  524. 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>
  525. extends Operator11<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E10> {
  526. }
  527. 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>
  528. extends Operator10<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E9> {
  529. }
  530. 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>
  531. extends Operator9<T, E1, E2, E3, E4, E5, E6, E7, E8, E8> {
  532. }
  533. 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>
  534. extends Operator8<T, E1, E2, E3, E4, E5, E6, E7, E7> {
  535. }
  536. public interface Operator6<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable, E6 extends Throwable>
  537. extends Operator7<T, E1, E2, E3, E4, E5, E6, E6> {
  538. }
  539. public interface Operator5<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable, E5 extends Throwable>
  540. extends Operator6<T, E1, E2, E3, E4, E5, E5> {
  541. }
  542. public interface Operator4<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable, E4 extends Throwable> extends
  543. Operator5<T, E1, E2, E3, E4, E4> {
  544. }
  545. public interface Operator3<T, E1 extends Throwable, E2 extends Throwable, E3 extends Throwable> extends
  546. Operator4<T, E1, E2, E3, E3> {
  547. }
  548. public interface Operator2<T, E1 extends Throwable, E2 extends Throwable> extends Operator3<T, E1, E2, E2> {
  549. }
  550. public interface Operator1<T, E1 extends Throwable> extends Operator2<T, E1, E1> {
  551. }
  552. public interface Operator<T> extends Operator1<T, RuntimeException> {
  553. }
  554. class Foo implements Operator<String> {
  555. public String execute(String aArg) throws NullPointerException, RemoteException {
  556. System.out.println("Doh!");
  557. return aArg;
  558. }
  559. }
  560. // public void testAssignable_method_m5() {
  561. // List list = new ArrayList();
  562. // ArrayList arraylist = null;
  563. // List<String> listOfString = new ArrayList<String>();
  564. // List<?> listOfSomething = new ArrayList<Integer>();
  565. // ArrayList<?> arrayListOfSomething = null;
  566. // List<Number> listOfNumber = null;
  567. // ArrayList<Number> arrayListOfNumber = null;
  568. // ArrayList<? extends Number> arrayListOfSomethingNumberish = null;
  569. // List<? extends Number> listOfSomethingNumberish = new ArrayList<Integer>();
  570. // List<? super Double> listOfSomethingSuperDouble = new ArrayList<Number>();
  571. // List<Integer> listOfInteger = new ArrayList<Integer>();
  572. // ArrayList<String> arrayListOfString;
  573. // ArrayList<Integer> arraylistOfInteger;
  574. // // interfaces too List<? extends A,B>
  575. //
  576. // ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList<Ljava/lang/String;>;");
  577. // ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList<Ljava/lang/Integer;>;");
  578. // ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList<Ljava/lang/Number;>;");
  579. // ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;");
  580. // ReferenceType ajList = resolve("Ljava/util/List;");
  581. // ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;");
  582. // ReferenceType ajListOfString = resolve("Pjava/util/List<Ljava/lang/String;>;");
  583. // ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;");
  584. // ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;");
  585. // ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;");
  586. // ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;");
  587. // ReferenceType ajListOfInteger = resolve("Pjava/util/List<Ljava/lang/Integer;>;");
  588. // ReferenceType ajListOfNumber = resolve("Pjava/util/List<Ljava/lang/Number;>;");
  589. // ReferenceType ajListOfEextendsNumber = resolve("Pjava/util/List<+TE")
  590. //
  591. // // class C<E extends Number> {
  592. // // void m5(List<E> e) { }
  593. // //
  594. // // void around(): execution(* C.m5(..)) && args(List<Integer>){} Should not match (but it does) ERROR
  595. //
  596. // // void around(): execution(* C.m5(..)) && args(ArrayList<Integer>){}//: Should not match (but it does!) ERROR
  597. // // void around(): execution(* C.m5(..)) && args(List<Number>){}//: Should not match (but it does!) ERROR
  598. // // void around(): execution(* C.m5(..)) && args(ArrayList<Number>){}//: Should not match (it does) ERROR
  599. // // void around(): execution(* C.m5(..)) && args(List<? extends Number>){}//: Should match (it does)
  600. // // void around(): execution(* C.m5(..)) && args(ArrayList<? extends Number>){}//: Should runtime check (it does!)
  601. // // void around(): execution(* C.m5(..)) && args(List){}//: Should match (it does)
  602. // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR
  603. // // void around(): execution(* C.m5(..)) && args(List<?>){}//: Should match (it does)
  604. // // void around(): execution(* C.m5(..)) && args(ArrayList<?>){}//: Should runtime check (it does not match!)
  605. // // void around(): execution(* C.m5(..)) && args(ArrayList<String>){}//: Should not match (it does not match!)
  606. // //
  607. // // // void around(): execution(* D2.m5(..)) && args(List<D1>){} //: Should
  608. // // not match (but it does) ERROR
  609. // // // void around(): execution(* D2.m5(..)) && args(ArrayList<D1>){}//:
  610. // // Should not match (but it does!) ERROR
  611. // // // void around(): execution(* D2.m5(..)) && args(List<C1>){}//: Should
  612. // // not match (but it does!) ERROR
  613. // // // void around(): execution(* D2.m5(..)) && args(ArrayList<C1>){}//:
  614. // // Should not match (it does) ERROR
  615. // // // void around(): execution(* D2.m5(..)) && args(List<? extends B1>){}//:
  616. // // Should match (it does)
  617. // // // void around(): execution(* D2.m5(..)) && args(ArrayList<? extends
  618. // // B1>){}//: Should runtime check (it does!)
  619. // // // void around(): execution(* D2.m5(..)) && args(List<? extends C1>){}//:
  620. // // Should match (it does)
  621. // // // void around(): execution(* D2.m5(..)) && args(ArrayList<? extends
  622. // // C1>){}//: Should runtime check (it does!)
  623. // // // void around(): execution(* D2.m5(..)) && args(List){}//: Should match
  624. // // (it does)
  625. // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should
  626. // // runtime check (it does not match!) ERROR
  627. // // // void around(): execution(* D2.m5(..)) && args(List<?>){}//: Should
  628. // // match (it does)
  629. // // // void around(): execution(* D2.m5(..)) && args(ArrayList<?>){}//:
  630. // // Should runtime check (it does not match!)
  631. // // // void around(): execution(* D2.m5(..)) && args(ArrayList<String>){}//:
  632. // // Should not match (it does not match!)
  633. // //
  634. // // // void around(): execution(* C.m6(..)) && args(List<Integer>){} //:
  635. // // Should not match (but it does) ERROR
  636. // // // void around(): execution(* C.m6(..)) && args(ArrayList<Integer>){}//:
  637. // // Should not match (but it does!) ERROR
  638. // // // void around(): execution(* C.m6(..)) && args(List<Number>){}//: Should
  639. // // not match (but it does!) ERROR
  640. // // // void around(): execution(* C.m6(..)) && args(ArrayList<Number>){}//:
  641. // // Should not match (it does) ERROR
  642. // // // void around(): execution(* C.m6(..)) && args(List<? extends
  643. // // Number>){}//: Should match (it does)
  644. // // // void around(): execution(* C.m6(..)) && args(ArrayList<? extends
  645. // // Number>){}//: Should runtime check (it does!)
  646. // // // void around(): execution(* C.m6(..)) && args(List){}//: Should match
  647. // // (it does)
  648. // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should
  649. // // runtime check (it does not match!)
  650. // // // void around(): execution(* C.m6(..)) && args(List<?>){}//: Should
  651. // // match (it does)
  652. // // // void around(): execution(* C.m6(..)) && args(ArrayList<?>){}//: Should
  653. // // runtime check (it does not match!)
  654. // // // void around(): execution(* C.m6(..)) && args(ArrayList<String>){}//:
  655. // // Should not match (it does not match!)
  656. // //
  657. // // // void around(): execution(* C.m7(..)) && args(List<List<Integer>>){}
  658. // // //: Should not match (but it does) ERROR
  659. // // // void around(): execution(* C.m7(..)) &&
  660. // // args(ArrayList<List<Integer>>){}//: Should not match (but it does!) ERROR
  661. // // // void around(): execution(* C.m7(..)) && args(List<List<Number>>){}//:
  662. // // Should not match (but it does!) ERROR
  663. // // // void around(): execution(* C.m7(..)) &&
  664. // // args(ArrayList<List<Number>>){}//: Should not match (but it does) ERROR
  665. // // // void around(): execution(* C.m7(..)) && args(List<? extends
  666. // // List<Number>>){}//: Should not match (but it does) ERROR
  667. // // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends
  668. // // List<Number>>){}//: Should not match (but it does!) ERROR
  669. // // // void around(): execution(* C.m7(..)) && args(List< ? extends List<?
  670. // // extends Number>>){}//: Should match (it does!)
  671. // // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends
  672. // // List<? extends Number>>){}//: Should match (it does!)
  673. // // // void around(): execution(* C.m7(..)) && args(List){}//: Should match
  674. // // (it does)
  675. // // // void around(): execution(* C.m7(..)) && args(ArrayList){}//: Should
  676. // // runtime check (it does not match!)
  677. // // // void around(): execution(* C.m7(..)) && args(List<?>){}//: Should
  678. // // match (it does)
  679. // // // void around(): execution(* C.m7(..)) && args(ArrayList<?>){}//: Should
  680. // // runtime check (it does!)
  681. // // // void around(): execution(* C.m7(..)) &&
  682. // // args(ArrayList<List<String>>){}//: Should not match (it does not match!)
  683. // //
  684. // // // void around(): execution(* C.m8(..)) && args(List<Integer>){} //:
  685. // // Should match with unchecked conversion (it does)
  686. // // // void around(): execution(* C.m8(..)) && args(ArrayList<Integer>){}//:
  687. // // Should runtime check with unchecked conversion (it does!)
  688. // // // void around(): execution(* C.m8(..)) && args(List<Number>){}//: Should
  689. // // match with unchecked conversion (it does!)
  690. // // // void around(): execution(* C.m8(..)) && args(ArrayList<Number>){}//:
  691. // // Should runtime check with unchecked conversion (it does)
  692. // // // void around(): execution(* C.m8(..)) && args(List<? extends
  693. // // Number>){}//: Should match with unchecked conversion (it does!)
  694. // // // void around(): execution(* C.m8(..)) && args(ArrayList<? extends
  695. // // Number>){}//: Should runtime check with unchecked conversion (it does)
  696. // // // void around(): execution(* C.m8(..)) && args(List){}//: Should match
  697. // // (it does)
  698. // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should
  699. // // runtime check (it does!)
  700. // // // void around(): execution(* C.m8(..)) && args(List<?>){}//: Should
  701. // // match (it does)
  702. // // // void around(): execution(* C.m8(..)) && args(ArrayList<?>){}//: Should
  703. // // runtime check (it does!)
  704. // // // void around(): execution(* C.m8(..)) && args(ArrayList<String>){}//:
  705. // // Should not match (it does not match!)
  706. // //
  707. // // // void around(): execution(* C.m9(..)) && args(List<Integer>){} //:
  708. // // Should not match (but it does) ERROR
  709. // // // void around(): execution(* C.m9(..)) && args(ArrayList<Integer>){}//:
  710. // // Should not match (it does not match!)
  711. // // // void around(): execution(* C.m9(..)) && args(Number){}//: Should match
  712. // // (it does!)
  713. // // // void around(): execution(* C.m9(..)) && args(Integer){}//: Should
  714. // // runtime check (it does)
  715. // // // void around(): execution(* C.m9(..)) && args(List<? extends
  716. // // Number>){}//: Should not match (but it does) ERROR
  717. // // // void around(): execution(* C.m9(..)) && args(ArrayList<? extends
  718. // // Number>){}//: Should not match (it does not match!)
  719. // // // void around(): execution(* C.m9(..)) && args(List){}//: Should not
  720. // // match (but it does) ERROR
  721. // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should
  722. // // not match (it does not match!)
  723. // // // void around(): execution(* C.m9(..)) && args(List<?>){}//: Should not
  724. // // match (but it does) ERROR
  725. // // // void around(): execution(* C.m9(..)) && args(ArrayList<?>){}//: Should
  726. // // not match (it does not match!)
  727. // // // void around(): execution(* C.m9(..)) && args(String){}//: Should not
  728. // // match (it does not match!)
  729. //
  730. // }
  731. private ReferenceType resolve(String sig) {
  732. return (ReferenceType) world.resolve(UnresolvedType.forSignature(sig));
  733. }
  734. }