Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

AjType.java 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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.lang.reflect;
  13. import java.lang.reflect.AnnotatedElement;
  14. import java.lang.reflect.Constructor;
  15. import java.lang.reflect.Field;
  16. import java.lang.reflect.Method;
  17. import java.lang.reflect.Type;
  18. import java.lang.reflect.TypeVariable;
  19. /**
  20. * The runtime representation of a type (Aspect, Class, Interface, Annotation, Enum, or Array) in an AspectJ
  21. * program.
  22. */
  23. public interface AjType<T> extends Type, AnnotatedElement {
  24. /**
  25. * The name of this type, in the same format as returned by Class.getName()
  26. */
  27. public String getName();
  28. /**
  29. * The package in which this type is declared
  30. */
  31. public Package getPackage();
  32. /**
  33. * The interfaces implemented by this type
  34. */
  35. public AjType<?>[] getInterfaces();
  36. /**
  37. * The modifiers declared for this type. The return value can be interpreted
  38. * using java.lang.reflect.Modifier
  39. */
  40. public int getModifiers();
  41. /**
  42. * The java.lang.Class that corresponds to this AjType
  43. */
  44. public Class<T> getJavaClass();
  45. // scope
  46. /**
  47. * The supertype of this type. If this type represents Object or a primitive type
  48. * then null is returned.
  49. */
  50. public AjType<?> getSupertype();
  51. /**
  52. * The generic supertype of this type, as defined by Class.getGenericSupertype
  53. */
  54. public Type getGenericSupertype();
  55. /**
  56. * If this type represents a local or anonymous type declared within a method, return
  57. * then enclosing Method object.
  58. */
  59. public Method getEnclosingMethod();
  60. /**
  61. * If this type represents a local or anonymous type declared within a constructor, return
  62. * then enclosing Method object.
  63. */
  64. public Constructor getEnclosingConstructor();
  65. /**
  66. * Returns the immediately enclosing type of this type.
  67. */
  68. public AjType<?> getEnclosingType();
  69. /**
  70. * If this type is a member of another type, return the AjType representing the type
  71. * in which it was declared.
  72. */
  73. public AjType<?> getDeclaringType();
  74. /**
  75. * If this type represents an aspect, returns the associated per-clause.
  76. * Returns null for non-aspect types.
  77. */
  78. public PerClause getPerClause();
  79. // inner types
  80. /**
  81. * Returns an array containing all the public types that are members of this type
  82. */
  83. public AjType<?>[] getAjTypes();
  84. /**
  85. * Returns an array containing all the types declared by this type
  86. */
  87. public AjType<?>[] getDeclaredAjTypes();
  88. // constructors
  89. /**
  90. * Returns the constructor object for the specified public constructor of this type
  91. */
  92. public Constructor getConstructor(AjType<?>... parameterTypes) throws NoSuchMethodException;
  93. /**
  94. * Returns all of the public constructors of this type
  95. */
  96. public Constructor[] getConstructors();
  97. /**
  98. * Returns the constructor object for the specified constructor of this type
  99. */
  100. public Constructor getDeclaredConstructor(AjType<?>... parameterTypes) throws NoSuchMethodException;
  101. /**
  102. * Returns all the constructors declared in this type
  103. */
  104. public Constructor[] getDeclaredConstructors();
  105. // fields
  106. /**
  107. * Return the field declared in this type with the given name
  108. */
  109. public Field getDeclaredField(String name) throws NoSuchFieldException;
  110. /**
  111. * Returns all the fields declared in this type
  112. */
  113. public Field[] getDeclaredFields();
  114. /**
  115. * Return the public field with the given name
  116. */
  117. public Field getField(String name) throws NoSuchFieldException;
  118. /**
  119. * Return the public fields declared by this type
  120. */
  121. public Field[] getFields();
  122. // methods
  123. /**
  124. * Return the method object for the specified method declared in this type
  125. */
  126. public Method getDeclaredMethod(String name, AjType<?>... parameterTypes) throws NoSuchMethodException;
  127. /**
  128. * Return the method object for the specified public method declared in this type
  129. */
  130. public Method getMethod(String name, AjType<?>... parameterTypes) throws NoSuchMethodException;
  131. /**
  132. * Return all the methods declared by this type
  133. */
  134. public Method[] getDeclaredMethods();
  135. /**
  136. * Returns all the public methods of this type
  137. */
  138. public Method[] getMethods();
  139. // pointcuts
  140. /**
  141. * Return the pointcut object representing the specified pointcut declared by this type
  142. */
  143. public Pointcut getDeclaredPointcut(String name) throws NoSuchPointcutException;
  144. /**
  145. * Return the pointcut object representing the specified public pointcut
  146. */
  147. public Pointcut getPointcut(String name) throws NoSuchPointcutException;
  148. /**
  149. * Returns all of the pointcuts declared by this type
  150. */
  151. public Pointcut[] getDeclaredPointcuts();
  152. /**
  153. * Returns all of the public pointcuts of this type
  154. */
  155. public Pointcut[] getPointcuts();
  156. // advice
  157. /**
  158. * Returns all of the advice declared by this type, of an advice kind contained in the
  159. * parameter list.
  160. */
  161. public Advice[] getDeclaredAdvice(AdviceKind... ofTypes);
  162. /**
  163. * Returns all of the advice for this type, of an advice kind contained in the parameter
  164. * list.
  165. */
  166. public Advice[] getAdvice(AdviceKind... ofTypes);
  167. /**
  168. * Returns the advice with the given name. For an @AspectJ declared advice member,
  169. * this is the name of the annotated method. For a code-style advice declaration, this
  170. * is the name given in the @AdviceName annotation if present.
  171. */
  172. public Advice getAdvice(String name) throws NoSuchAdviceException;
  173. /**
  174. * Returns the advice declared in this type with the given name. For an @AspectJ declared advice member,
  175. * this is the name of the annotated method. For a code-style advice declaration, this
  176. * is the name given in the @AdviceName annotation if present.
  177. */
  178. public Advice getDeclaredAdvice(String name) throws NoSuchAdviceException;
  179. // inter-type declarations
  180. /**
  181. * Return the inter-type method declared by this type matching the given specification
  182. */
  183. public InterTypeMethodDeclaration getDeclaredITDMethod(String name, AjType<?> target, AjType<?>... parameterTypes) throws NoSuchMethodException;
  184. /**
  185. * Return all of the inter-type methods declared by this type
  186. */
  187. public InterTypeMethodDeclaration[] getDeclaredITDMethods();
  188. /**
  189. * Return the public inter-type method of this type matching the given specification
  190. */
  191. public InterTypeMethodDeclaration getITDMethod(String name, AjType<?> target, AjType<?>... parameterTypes) throws NoSuchMethodException;
  192. /**
  193. * Return all of the public inter-type declared methods of this type
  194. */
  195. public InterTypeMethodDeclaration[] getITDMethods();
  196. /**
  197. * Return the inter-type constructor declared by this type matching the given specification
  198. */
  199. public InterTypeConstructorDeclaration getDeclaredITDConstructor(AjType<?> target, AjType<?>... parameterTypes) throws NoSuchMethodException;
  200. /**
  201. * Returns all of the inter-type constructors declared by this type
  202. */
  203. public InterTypeConstructorDeclaration[] getDeclaredITDConstructors();
  204. /**
  205. * Return the public inter-type constructor matching the given specification
  206. */
  207. public InterTypeConstructorDeclaration getITDConstructor(AjType<?> target, AjType<?>... parameterTypes) throws NoSuchMethodException;
  208. /**
  209. * Return all of the public inter-type constructors of this type
  210. */
  211. public InterTypeConstructorDeclaration[] getITDConstructors();
  212. /**
  213. * Return the inter-type field declared in this type with the given specification
  214. */
  215. public InterTypeFieldDeclaration getDeclaredITDField(String name, AjType<?> target) throws NoSuchFieldException;
  216. /**
  217. * Return all of the inter-type fields declared in this type
  218. */
  219. public InterTypeFieldDeclaration[] getDeclaredITDFields();
  220. /**
  221. * Return the public inter-type field matching the given specification
  222. */
  223. public InterTypeFieldDeclaration getITDField(String name, AjType<?> target) throws NoSuchFieldException;
  224. /**
  225. * Return all of the public inter-type fields for this type
  226. */
  227. public InterTypeFieldDeclaration[] getITDFields();
  228. // declare statements
  229. /**
  230. * Returns all of the declare error and declare warning members of this type,
  231. * including declare error/warning members inherited from super-types
  232. */
  233. public DeclareErrorOrWarning[] getDeclareErrorOrWarnings();
  234. /**
  235. * Returns all of the declare parents members of this type, including
  236. * declare parent members inherited from super-types
  237. */
  238. public DeclareParents[] getDeclareParents();
  239. /**
  240. * Return all of the declare soft members of this type, including declare
  241. * soft members inherited from super-types
  242. */
  243. public DeclareSoft[] getDeclareSofts();
  244. /**
  245. * Return all of the declare annotation members of this type, including declare
  246. * annotation members inherited from super-types
  247. */
  248. public DeclareAnnotation[] getDeclareAnnotations();
  249. /**
  250. * Return all of the declare precedence members of this type, including declare
  251. * precedence members inherited from super-types
  252. */
  253. public DeclarePrecedence[] getDeclarePrecedence();
  254. // misc
  255. /**
  256. * Returns the elements of this enum class, or null if this type does not represent
  257. * an enum type.
  258. */
  259. public T[] getEnumConstants();
  260. /**
  261. * Returns an array of TypeVariable objects that represent the type variables declared by
  262. * this type (if any)
  263. */
  264. public TypeVariable<Class<T>>[] getTypeParameters();
  265. /**
  266. * True if this is an enum type
  267. */
  268. public boolean isEnum();
  269. /**
  270. * True if the given object is assignment-compatible with an object of the type represented
  271. * by this AjType
  272. */
  273. public boolean isInstance(Object o);
  274. /**
  275. * True if this is an interface type
  276. */
  277. public boolean isInterface();
  278. /**
  279. * Returns true if and only if the underlying type is a local class
  280. */
  281. public boolean isLocalClass();
  282. /**
  283. * Returns true if and only if the underlying type is a member class
  284. */
  285. public boolean isMemberClass();
  286. /**
  287. * Return true if this is an array type
  288. */
  289. public boolean isArray();
  290. /**
  291. * Return true if this object represents a primitive type
  292. */
  293. public boolean isPrimitive();
  294. /**
  295. * Return true if this is an aspect type
  296. */
  297. public boolean isAspect();
  298. /**
  299. * Returns true if and only if the underlying type is a member aspect
  300. */
  301. public boolean isMemberAspect();
  302. /**
  303. * Returns true if and only if the underlying type is a privileged aspect
  304. */
  305. public boolean isPrivileged();
  306. }