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.

TypeAnnotationsTest.java 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. /* *******************************************************************
  2. * Copyright (c) 2013 VMware
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. *
  9. * Contributors:
  10. * Andy Clement - initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.apache.bcel.classfile.tests;
  13. import org.aspectj.apache.bcel.Constants;
  14. import org.aspectj.apache.bcel.classfile.Attribute;
  15. import org.aspectj.apache.bcel.classfile.Field;
  16. import org.aspectj.apache.bcel.classfile.JavaClass;
  17. import org.aspectj.apache.bcel.classfile.Method;
  18. import org.aspectj.apache.bcel.classfile.annotation.RuntimeTypeAnnos;
  19. import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisTypeAnnos;
  20. import org.aspectj.apache.bcel.classfile.annotation.TypeAnnotationGen;
  21. public class TypeAnnotationsTest extends BcelTestCase {
  22. protected void setUp() throws Exception {
  23. super.setUp();
  24. }
  25. public Attribute getAttribute(Attribute[] attrs, byte tag) {
  26. for (Attribute attr: attrs) {
  27. if (attr.getTag() == tag) {
  28. return attr;
  29. }
  30. }
  31. return null;
  32. }
  33. public void testClassTypeParameter() throws Exception {
  34. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnClassTypeParameter");
  35. RuntimeVisTypeAnnos rvta = (RuntimeVisTypeAnnos)getAttribute(jc.getAttributes(), Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS);
  36. assertTrue(rvta.areVisible());
  37. TypeAnnotationGen[] tas = rvta.getTypeAnnotations();
  38. assertEquals(2,tas.length);
  39. checkTypeAnnotationClassTypeParameter(tas[0],0,"@Anno");
  40. checkTypeAnnotationClassTypeParameter(tas[1],1,"@Anno(value=2)");
  41. }
  42. public void testMethodTypeParameter() throws Exception {
  43. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnMethodTypeParameter");
  44. Method m = getMethod(jc, "m");
  45. RuntimeVisTypeAnnos rvta = (RuntimeVisTypeAnnos)getAttribute(m.getAttributes(), Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS);
  46. assertTrue(rvta.areVisible());
  47. TypeAnnotationGen[] tas = rvta.getTypeAnnotations();
  48. assertEquals(1,tas.length);
  49. checkTypeAnnotationMethodTypeParameter(tas[0],0,"@Anno");
  50. }
  51. public void testSuperinterface() throws Exception {
  52. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnSuperinterface1");
  53. RuntimeVisTypeAnnos rvta = (RuntimeVisTypeAnnos)getAttribute(jc.getAttributes(), Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS);
  54. assertTrue(rvta.areVisible());
  55. TypeAnnotationGen[] tas = rvta.getTypeAnnotations();
  56. assertEquals(1,tas.length);
  57. TypeAnnotationGen ta = tas[0];
  58. checkTypeAnnotationClassExtends(ta, 0, "@Anno");
  59. }
  60. public void testSupertypes() throws Exception {
  61. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnSupertypes");
  62. RuntimeVisTypeAnnos rvta = (RuntimeVisTypeAnnos)getAttribute(jc.getAttributes(), Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS);
  63. assertTrue(rvta.areVisible());
  64. TypeAnnotationGen[] tas = rvta.getTypeAnnotations();
  65. assertEquals(3,tas.length);
  66. checkTypeAnnotationClassExtends(tas[0],-1,"@Anno(value=1)");
  67. checkTypeAnnotationClassExtends(tas[1],0,"@Anno");
  68. checkTypeAnnotationClassExtends(tas[2],1,"@Anno(value=2)");
  69. }
  70. public void testClassTypeParameterBound() throws Exception {
  71. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnClassTypeParameterBound");
  72. RuntimeVisTypeAnnos rvta = (RuntimeVisTypeAnnos)getAttribute(jc.getAttributes(), Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS);
  73. assertTrue(rvta.areVisible());
  74. TypeAnnotationGen[] tas = rvta.getTypeAnnotations();
  75. assertEquals(3,tas.length);
  76. checkTypeAnnotationClassTypeParameterBound(tas[0],0,0,"@Anno");
  77. checkTypePath(tas[0],TypeAnnotationGen.NO_TYPE_PATH);
  78. checkTypeAnnotationClassTypeParameterBound(tas[1],0,1,"@Anno(value=2)");
  79. checkTypePath(tas[1],TypeAnnotationGen.NO_TYPE_PATH);
  80. checkTypeAnnotationClassTypeParameterBound(tas[2],0,1,"@Anno(value=3)");
  81. checkTypePath(tas[2],new int[]{TypeAnnotationGen.TYPE_PATH_ENTRY_KIND_TYPE_ARGUMENT,0});
  82. }
  83. public void testMethodTypeParameterBound() throws Exception {
  84. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnMethodTypeParameterBound");
  85. Method m = getMethod(jc, "m");
  86. RuntimeVisTypeAnnos rvta = (RuntimeVisTypeAnnos)getAttribute(m.getAttributes(), Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS);
  87. assertTrue(rvta.areVisible());
  88. TypeAnnotationGen[] tas = rvta.getTypeAnnotations();
  89. assertEquals(3,tas.length);
  90. checkTypeAnnotationMethodTypeParameterBound(tas[0],0,0,"@Anno");
  91. checkTypePath(tas[0],TypeAnnotationGen.NO_TYPE_PATH);
  92. checkTypeAnnotationMethodTypeParameterBound(tas[1],0,1,"@Anno(value=2)");
  93. checkTypePath(tas[1],TypeAnnotationGen.NO_TYPE_PATH);
  94. checkTypeAnnotationMethodTypeParameterBound(tas[2],0,1,"@Anno(value=3)");
  95. checkTypePath(tas[2],new int[]{TypeAnnotationGen.TYPE_PATH_ENTRY_KIND_TYPE_ARGUMENT,1});
  96. }
  97. public void testField() throws Exception {
  98. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnField");
  99. Field f = getField(jc,"f1");
  100. RuntimeVisTypeAnnos rvta = (RuntimeVisTypeAnnos)getAttribute(f.getAttributes(), Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS);
  101. assertTrue(rvta.areVisible());
  102. TypeAnnotationGen[] tas = rvta.getTypeAnnotations();
  103. assertEquals(1,tas.length);
  104. checkTypeAnnotationField(tas[0],"@Anno");
  105. checkTypePath(tas[0],TypeAnnotationGen.NO_TYPE_PATH);
  106. tas = getTypeAnnotations(getField(jc,"f2"),true);
  107. checkTypeAnnotationField(tas[0],"@Anno");
  108. checkTypePath(tas[0],new int[]{TypeAnnotationGen.TYPE_PATH_ENTRY_KIND_TYPE_ARGUMENT,0});
  109. tas = getTypeAnnotations(getField(jc,"f3"),true);
  110. checkTypeAnnotationField(tas[0],"@Anno");
  111. checkTypePath(tas[0],new int[]{TypeAnnotationGen.TYPE_PATH_ENTRY_KIND_ARRAY,0});
  112. tas = getTypeAnnotations(getField(jc,"f4"),true);
  113. checkTypeAnnotationField(tas[0],"@Anno");
  114. checkTypePath(tas[0],new int[]{
  115. TypeAnnotationGen.TYPE_PATH_ENTRY_KIND_ARRAY,0,
  116. TypeAnnotationGen.TYPE_PATH_ENTRY_KIND_TYPE_ARGUMENT,0
  117. });
  118. }
  119. public void testMethodReturn() throws Exception {
  120. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnMethodReturn");
  121. TypeAnnotationGen[] tas = getTypeAnnotations(getMethod(jc,"m"), true);
  122. checkTypeAnnotationMethodReturn(tas[0],"@Anno");
  123. checkTypePath(tas[0],TypeAnnotationGen.NO_TYPE_PATH);
  124. }
  125. public void testMethodReceiver() throws Exception {
  126. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnMethodReceiver");
  127. TypeAnnotationGen[] tas = getTypeAnnotations(getMethod(jc,"m"), true);
  128. checkTypeAnnotationMethodReceiver(tas[0],"@Anno");
  129. checkTypePath(tas[0],TypeAnnotationGen.NO_TYPE_PATH);
  130. }
  131. public void testMethodFormalParameter() throws Exception {
  132. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnMethodFormalParameter");
  133. TypeAnnotationGen[] tas = getTypeAnnotations(getMethod(jc,"m"), true);
  134. checkTypeAnnotationMethodFormalParameter(tas[0],0, "@Anno");
  135. checkTypePath(tas[0],TypeAnnotationGen.NO_TYPE_PATH);
  136. }
  137. public void testThrows() throws Exception {
  138. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnThrows");
  139. TypeAnnotationGen[] tas = getTypeAnnotations(getMethod(jc,"m"), true);
  140. checkTypeAnnotationThrows(tas[0],0, "@Anno");
  141. checkTypePath(tas[0],TypeAnnotationGen.NO_TYPE_PATH);
  142. checkTypeAnnotationThrows(tas[1],1, "@Anno(value=2)");
  143. checkTypePath(tas[1],TypeAnnotationGen.NO_TYPE_PATH);
  144. }
  145. public void testLocalVariable() throws Exception {
  146. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnLocalVariable");
  147. // TODO I think the attribute should be on the code for the method, not the method
  148. TypeAnnotationGen[] tas = getTypeAnnotations(getMethod(jc,"m").getAttributes(), true);
  149. assertEquals(1,tas.length);
  150. checkTypeAnnotationLocalVariable(tas[0],new int[]{11,8,1}, "@Anno");
  151. }
  152. public void testResourceVariable() throws Exception {
  153. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnResourceVariable");
  154. // TODO I think the attribute should be on the code for the method, not the method
  155. TypeAnnotationGen[] tas = getTypeAnnotations(getMethod(jc,"m").getAttributes(), true);
  156. assertEquals(2,tas.length);
  157. checkTypeAnnotationResourceVariable(tas[0],new int[]{17,204,1}, "@Anno");
  158. checkTypeAnnotationResourceVariable(tas[1],new int[]{36,114,3}, "@Anno(value=99)");
  159. }
  160. public void testExceptionParameter() throws Exception {
  161. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnExceptionParameter");
  162. // TODO I think the attribute should be on the code for the method, not the method
  163. TypeAnnotationGen[] tas = getTypeAnnotations(getMethod(jc,"m").getAttributes(), true);
  164. assertEquals(2,tas.length);
  165. checkTypeAnnotationExceptionParameter(tas[0],0, "@Anno(value=99)");
  166. checkTypeAnnotationExceptionParameter(tas[1],0, "@Anno");
  167. }
  168. public void testInstanceOf() throws Exception {
  169. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnInstanceOf");
  170. // TODO I think the attribute should be on the code for the method, not the method
  171. TypeAnnotationGen[] tas = getTypeAnnotations(getMethod(jc,"m").getAttributes(), true);
  172. assertEquals(2,tas.length);
  173. checkTypeAnnotationInstanceOf(tas[0],3, "@Anno(value=1)");
  174. checkTypeAnnotationInstanceOf(tas[1],18, "@Anno(value=1)");
  175. }
  176. public void testNew() throws Exception {
  177. JavaClass jc = getClassFromJava8Jar("TypeAnnoOnNew");
  178. // TODO I think the attribute should be on the code for the method, not the method
  179. TypeAnnotationGen[] tas = getTypeAnnotations(getMethod(jc,"m").getAttributes(), true);
  180. assertEquals(4,tas.length);
  181. checkTypeAnnotationNew(tas[0],0, "@Anno");
  182. checkTypePath(tas[0],TypeAnnotationGen.NO_TYPE_PATH);
  183. // TODO type path bugs in javac b90 according to the spec
  184. // checkTypeAnnotationNew(tas[1],8, "@Anno(value=2)");
  185. // checkTypePath(tas[1],new int[]{
  186. // TypeAnnotationGen.TYPE_PATH_ENTRY_KIND_ARRAY,0
  187. // });
  188. // checkTypeAnnotationNew(tas[2],13, "@Anno(value=4)");
  189. // checkTypePath(tas[2],TypeAnnotationGen.NO_TYPE_PATH);
  190. // checkTypeAnnotationNew(tas[3],13, "@Anno(value=3)");
  191. // checkTypePath(tas[3],new int[]{
  192. // TypeAnnotationGen.TYPE_PATH_ENTRY_KIND_ARRAY,0,
  193. // TypeAnnotationGen.TYPE_PATH_ENTRY_KIND_ARRAY,0
  194. // });
  195. }
  196. // ---
  197. private TypeAnnotationGen[] getTypeAnnotations(Attribute[] attrs, boolean visible) {
  198. RuntimeTypeAnnos rvta = (RuntimeTypeAnnos)getAttribute(attrs, visible?Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS:Constants.ATTR_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS);
  199. return rvta.getTypeAnnotations();
  200. }
  201. private TypeAnnotationGen[] getTypeAnnotations(Method m, boolean visible) {
  202. RuntimeTypeAnnos rvta = (RuntimeTypeAnnos)getAttribute(m.getAttributes(), visible?Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS:Constants.ATTR_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS);
  203. return rvta.getTypeAnnotations();
  204. }
  205. private TypeAnnotationGen[] getTypeAnnotations(Field f, boolean visible) {
  206. RuntimeTypeAnnos rvta = (RuntimeTypeAnnos)getAttribute(f.getAttributes(), visible?Constants.ATTR_RUNTIME_VISIBLE_TYPE_ANNOTATIONS:Constants.ATTR_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS);
  207. return rvta.getTypeAnnotations();
  208. }
  209. private void checkTypePath(TypeAnnotationGen ta, int[] expectedTypePath) {
  210. int[] typepath = ta.getTypePath();
  211. if (expectedTypePath==TypeAnnotationGen.NO_TYPE_PATH || expectedTypePath==null) {
  212. if (typepath!=TypeAnnotationGen.NO_TYPE_PATH) {
  213. fail("Expected no type path but was "+ta.getTypePathString());
  214. }
  215. } else {
  216. assertEquals(expectedTypePath.length, typepath.length);
  217. for (int i=0;i<expectedTypePath.length;i++) {
  218. if (expectedTypePath[i]!=typepath[i]) {
  219. fail("Expected type path: "+TypeAnnotationGen.toTypePathString(expectedTypePath)+" does not match actual type path "+ta.getTypePathString());
  220. }
  221. }
  222. }
  223. }
  224. private void checkLocalVarTarget(TypeAnnotationGen ta, int[] expectedLocalVarTarget) {
  225. int[] localVarTarget = ta.getLocalVarTarget();
  226. assertEquals(expectedLocalVarTarget.length, localVarTarget.length);
  227. for (int i=0;i<expectedLocalVarTarget.length;i++) {
  228. if (expectedLocalVarTarget[i]!=localVarTarget[i]) {
  229. fail("Expected local var target: "+toLocalVarTargetString(expectedLocalVarTarget)+" does not match actual type path "+toLocalVarTargetString(localVarTarget));
  230. }
  231. }
  232. }
  233. public static String toLocalVarTargetString(int[] localVarTarget) {
  234. StringBuilder sb = new StringBuilder();
  235. int count = 0;
  236. while (count < localVarTarget.length) {
  237. sb.append("{start_pc="+localVarTarget[count++]+",length="+localVarTarget[count++]+",index="+localVarTarget[count++]+"}");
  238. }
  239. return sb.toString();
  240. }
  241. private void checkTypeAnnotationLocalVariable(TypeAnnotationGen ta, int[] expectedLocalVarTarget, String expectedAnnotationText) {
  242. assertEquals(TypeAnnotationGen.LOCAL_VARIABLE,ta.getTargetType());
  243. checkLocalVarTarget(ta,expectedLocalVarTarget);
  244. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  245. }
  246. private void checkTypeAnnotationResourceVariable(TypeAnnotationGen ta, int[] expectedLocalVarTarget, String expectedAnnotationText) {
  247. assertEquals(TypeAnnotationGen.RESOURCE_VARIABLE,ta.getTargetType());
  248. checkLocalVarTarget(ta,expectedLocalVarTarget);
  249. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  250. }
  251. private void checkTypeAnnotationExceptionParameter(TypeAnnotationGen ta, int expectedExceptionTableIndex, String expectedAnnotationText) {
  252. assertEquals(TypeAnnotationGen.EXCEPTION_PARAMETER,ta.getTargetType());
  253. assertEquals(expectedExceptionTableIndex,ta.getExceptionTableIndex());
  254. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  255. }
  256. private void checkTypeAnnotationInstanceOf(TypeAnnotationGen ta, int expectedOffset, String expectedAnnotationText) {
  257. assertEquals(TypeAnnotationGen.INSTANCEOF,ta.getTargetType());
  258. assertEquals(expectedOffset,ta.getOffset());
  259. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  260. }
  261. private void checkTypeAnnotationNew(TypeAnnotationGen ta, int expectedOffset, String expectedAnnotationText) {
  262. assertEquals(TypeAnnotationGen.NEW,ta.getTargetType());
  263. assertEquals(expectedOffset,ta.getOffset());
  264. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  265. }
  266. private void checkTypeAnnotationConstructorReference(TypeAnnotationGen ta, int expectedOffset, String expectedAnnotationText) {
  267. assertEquals(TypeAnnotationGen.CONSTRUCTOR_REFERENCE,ta.getTargetType());
  268. assertEquals(expectedOffset,ta.getOffset());
  269. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  270. }
  271. private void checkTypeAnnotationMethodReference(TypeAnnotationGen ta, int expectedOffset, String expectedAnnotationText) {
  272. assertEquals(TypeAnnotationGen.METHOD_REFERENCE,ta.getTargetType());
  273. assertEquals(expectedOffset,ta.getOffset());
  274. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  275. }
  276. private void checkTypeAnnotationField(TypeAnnotationGen ta, String expectedAnnotationText) {
  277. assertEquals(TypeAnnotationGen.FIELD,ta.getTargetType());
  278. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  279. }
  280. private void checkTypeAnnotationMethodReturn(TypeAnnotationGen ta, String expectedAnnotationText) {
  281. assertEquals(TypeAnnotationGen.METHOD_RETURN,ta.getTargetType());
  282. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  283. }
  284. private void checkTypeAnnotationMethodFormalParameter(TypeAnnotationGen ta, int expectedFormalParameterIndex, String expectedAnnotationText) {
  285. assertEquals(TypeAnnotationGen.METHOD_FORMAL_PARAMETER,ta.getTargetType());
  286. assertEquals(expectedFormalParameterIndex,ta.getMethodFormalParameterIndex());
  287. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  288. }
  289. private void checkTypeAnnotationThrows(TypeAnnotationGen ta, int expectedThrowsTypeIndex, String expectedAnnotationText) {
  290. assertEquals(TypeAnnotationGen.THROWS,ta.getTargetType());
  291. assertEquals(expectedThrowsTypeIndex,ta.getThrowsTypeIndex());
  292. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  293. }
  294. private void checkTypeAnnotationMethodReceiver(TypeAnnotationGen ta, String expectedAnnotationText) {
  295. assertEquals(TypeAnnotationGen.METHOD_RECEIVER,ta.getTargetType());
  296. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  297. }
  298. private void checkTypeAnnotationClassExtends(TypeAnnotationGen ta, int expectedSupertypeIndex, String expectedAnnotationText) {
  299. assertEquals(TypeAnnotationGen.CLASS_EXTENDS,ta.getTargetType());
  300. assertEquals(expectedSupertypeIndex,ta.getSupertypeIndex());
  301. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  302. }
  303. private void checkTypeAnnotationClassTypeParameter(TypeAnnotationGen ta, int expectedTypeParameterIndex, String expectedAnnotationText) {
  304. assertEquals(TypeAnnotationGen.CLASS_TYPE_PARAMETER,ta.getTargetType());
  305. assertEquals(expectedTypeParameterIndex,ta.getTypeParameterIndex());
  306. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  307. }
  308. private void checkTypeAnnotationClassTypeParameterBound(TypeAnnotationGen ta, int expectedTypeParameterIndex, int expectedBoundIndex, String expectedAnnotationText) {
  309. assertEquals(TypeAnnotationGen.CLASS_TYPE_PARAMETER_BOUND,ta.getTargetType());
  310. assertEquals(expectedTypeParameterIndex,ta.getTypeParameterIndex());
  311. assertEquals(expectedBoundIndex,ta.getBoundIndex());
  312. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  313. }
  314. private void checkTypeAnnotationMethodTypeParameterBound(TypeAnnotationGen ta, int expectedTypeParameterIndex, int expectedBoundIndex, String expectedAnnotationText) {
  315. assertEquals(TypeAnnotationGen.METHOD_TYPE_PARAMETER_BOUND,ta.getTargetType());
  316. assertEquals(expectedTypeParameterIndex,ta.getTypeParameterIndex());
  317. assertEquals(expectedBoundIndex,ta.getBoundIndex());
  318. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  319. }
  320. private void checkTypeAnnotationMethodTypeParameter(TypeAnnotationGen ta, int expectedTypeParameterIndex, String expectedAnnotationText) {
  321. assertEquals(TypeAnnotationGen.METHOD_TYPE_PARAMETER,ta.getTargetType());
  322. assertEquals(expectedTypeParameterIndex,ta.getTypeParameterIndex());
  323. assertEquals(expectedAnnotationText,ta.getAnnotation().toShortString());
  324. }
  325. }